Alpha Video Training
Results 1 to 6 of 6

Thread: import a numeric field into a character field

  1. #1
    Member
    Real Name
    David Corcoran
    Join Date
    Oct 2001
    Posts
    218

    Default import a numeric field into a character field

    I am importing from another database a numeric field with a lenth of 3 into a character field in Alpha which is my customer_id field the database has 516 records. The customer_id field has the field rule autoincrement, when I press the button for new record I get 990000 as the next record instead of 517.

    I know you can put a default value in the autoincrement by a simple expression, I have put in Str(517) but still get 990000. Any one got and suggestions.

    Kind regards
    David

  2. #2
    Member
    Real Name
    Sh
    Join Date
    Feb 2005
    Location
    Connecticut
    Posts
    53

    Default RE: import a numeric field into a character field

    Don't use a character field.

    See this thread: http://msgboard.alphasoftware.com/alphaphorum/read.php3?sortby=lastreply&direction=desc&num=15&id=10477&thread=10476

    Shirley

  3. #3
    "Certified" Alphaholic Keith Hubert's Avatar
    Real Name
    Keith Hubert
    Join Date
    Jul 2000
    Location
    London, UK
    Posts
    6,930

    Default RE: import a numeric field into a character field

    David,

    Consider adding another character field. Do the import as numeric then do an update to the new field and convert number field to character.

    Let us know how you get on.

    RegardsKeith HubertGuild MemberLondon.KHDB Management Systems

  4. #4
    Volunteer Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,617

    Default RE: import a numeric field into a character field

    David

    The default value only applies to the first and only record in a table when used with autoincrement field.

    After that, the next value (in your case the next customer_id) is 1 more than the largest value that is in the table.

    Since you've made this an autoincrement field, there is now an index named customer_id. Open a browse to that table, select the index, and then look at the last record. I'm betting that you'll see 989999.

    The previous values in the table are part of the auto increment process.

    Also, since you are doing an import, you want to get your customer_id's from the import table rather than a new id assigned by the autoincrement process.

    So you'll have to have the field rule for customer_id be defined as a user entered field until the import is done. Otherwise you'll get the values assigned to it rather than keeping what you're transferring in.

    The last part is that it looks like you are converting from a 3 digit numeric to a size 6 character field. You'll need to consider how to convert that numeric id to a character.

    Here are some examples of the functions that you might consider for the conversion.

    dim customer_id as N =123
    ?str(customer_id)
    = " 123"
    ?str(customer_id,6)
    = " 123"
    ?padl(alltrim(str(customer_id,6)),6,"0")
    = "000123"

    Then make sure that all child records of any links follow the same process.

  5. #5
    VAR davej's Avatar
    Real Name
    Dave Jampole
    Join Date
    Apr 2000
    Location
    Haughton, LA ( just east of Shreveport, Louisiana)
    Posts
    2,524

    Default RE: import a numeric field into a character field

    David,

    A general rule of thumb that will serve you well is: if you don't do math with it, make it a character field.

    Dave

  6. #6
    Member
    Real Name
    David Corcoran
    Join Date
    Oct 2001
    Posts
    218

    Default RE: import a numeric field into a character field

    I designed the database on the alphasports model which has all the linking fields as character. When I found the problems with getting the data from the dbase program ( which by the way I did not import but added the dbf tables and then appended the records)I tried changing the linking field to numeric which I did successfully. But then when I went into my invoice form I had 14 fields in the trace window which were not linked to a field, I don't know why this happened?. I was then going to make my own lookup table to which I would post the invoice numer and have a second field which would add 1 to the invoice number and the lookup would fill in the next number. I hope this makes sense and would appreciate any suggestions as I am delivering the program on monday updating the tables from the old program for the client to continue invoiceing in the new program Tuesday morning.

    Kind regards
    David

Similar Threads

  1. Copying Calculated Field to a Numeric Field
    By Alastair in forum Alpha Five Version 5
    Replies: 14
    Last Post: 10-07-2004, 07:34 AM
  2. Transform character field to date field, how ?
    By mronck in forum Alpha Five Version 5
    Replies: 9
    Last Post: 11-11-2003, 12:38 PM
  3. Import 1 digit or blank into numeric or character
    By Barbara Taam in forum Alpha Five Version 5
    Replies: 5
    Last Post: 09-04-2003, 07:02 AM
  4. Keeping numeric field numeric upon importing
    By David Farr in forum Alpha Five Version 5
    Replies: 2
    Last Post: 03-19-2003, 10:01 AM
  5. if( expression with character and numeric field -
    By J. Michael Rembor in forum Alpha Four Version 6 and Prior
    Replies: 6
    Last Post: 10-11-2000, 06:04 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •