dataport - Importing identical records problem

TomasStulpinasTomasStulpinas Member Posts: 7
hi,

i've got a file for import which contains identical lines. when i import, i want all records (including identical) appear in my table. i've added an extra column in table, named it 'No.' and made it primary key. Still, navision removes duplicated lines.

what can be done about this?

Comments

  • DenSterDenSter Member Posts: 8,305
    In addition to adding a column and making it the primary key, you also need to generate unique values for this field.
  • TomasStulpinasTomasStulpinas Member Posts: 7
    I've set 'No.' property 'AutoIncrement' to 'yes', too. this did not help.
  • DenSterDenSter Member Posts: 8,305
    I haven't gotten autoincrement to work, so I wouldn't even try that again. Since it is REALLY easy to program it yourself, I didn't really give it much effort either.
  • TomasStulpinasTomasStulpinas Member Posts: 7
    DenSter wrote:
    I haven't gotten autoincrement to work, so I wouldn't even try that again. Since it is REALLY easy to program it yourself, I didn't really give it much effort either.

    well, i simply wrote a trigger in my dataport. next time i simply won't bother with autoincrement (by the way, if i try to enter data in my table manually, autoincrement works fine)
  • bbrownbbrown Member Posts: 3,268
    When the dataport runs it uses Rec.INIT to initialize each new record. INIT does not reset the primary key fields.

    Result:

    First Record (before insert):

    Key Field = NULL

    First Record (after insert):

    Key Field = 1

    Second Record (before insert):

    Key Field = 1

    Second Record (on insert):

    Error - Primary key exist

    You must clear the primary key values (CLEAR(Rec)) for each new record.
    There are no bugs - only undocumented features.
  • andy76andy76 Member Posts: 616
    Hello,

    In which trigger should I write CLEAR(Rec) for reset Autoincrement?

    I have a text file tab delimited with 3 records, NAV 5.0 and SQL 2005.
    When I import it I don't have any error message but only the last record is in the table.
    Is this the problem?

    Thank you
  • SavatageSavatage Member Posts: 7,142
    why not onimport record

    UniqueKey := UniqueKey +1;

    is it a one time import or something you are going to use alot?
  • andy76andy76 Member Posts: 616
    I solved the problem with this code in onBeforeImportRecord

    XXX_Rec - OnBeforeImportRecord()
    CLEAR(XXX_Rec);

    Thank you
Sign In or Register to comment.