Rename Rec with empty value

JoeriJoeri Member Posts: 75
Hi,

I'm trying to rename records in the Job Budget Line table. The primary key of this table is:
Job No.,Phase Code,Task Code,Step Code,No.

In all records the "Phase Code" is filled but it has to be modified to an empty value. I tried ofcourse using the rename function but here i got the following error:

You cannot rename a record because the new value for the field below is '',
Field: Phase Code
Table: Job Budget Line

I already disabled the onrename trigger, i also removed the tablerelation to Phase Code.
I also tried adding the tablerelation again, adding an empty record to the phase table, and the renaming it. It all didn't work.

I know it can be done using other means for example creating for each line in this table a new line without a phase code, and then deleting the old line, but this takes too much time.

The table holds 12.034.312 records, and using the method described above takes about 8 hours, which is too long.

So, is there any other way of doing this ? Preferably using the rename trigger, else some other way that doesn't take this much time.

Thanks.

Comments

  • MalajloMalajlo Member Posts: 294
    Add new records with different values in prim. key.
    Dont forget to set filter, otherwise it will go through newly added records also.
    Delete old records. (but why are you trying to do that? This way you should change also all related tables)
  • JoeriJoeri Member Posts: 75
    Hi Malajlo,

    I already tried your solution
    I know it can be done using other means for example creating for each line in this table a new line without a phase code, and then deleting the old line, but this takes too much time.

    This takes more than 8 hours, and i don't have that much time.
    Other tablerelations don't matter because it's part of a much larger conversion process, and those other tables already have the correct data.
  • MalajloMalajlo Member Posts: 294
    huh, I missed no of records...
    create new temp key, integer (as entry no.).
    change primary key.
    disable original primary key.
    rename records using newly created key.
    restore keys back, delete temp key.
    But i'm affraid creating key back will take time too.
  • tinoruijstinoruijs Member Posts: 1,226
    Hi Joeri,

    My first thought is; Do you really need the 12.034.312 records? Can't you delete some of the records? Or compress them for certain old jobs?
    In all records the "Phase Code" is filled but it has to be modified to an empty value.

    Why is this? Because you want to modify the primary key to a key without Phase Code?

    Can't you just delete Phase Code from the primary key?

    Tino Ruijs
    Microsoft Dynamics NAV specialist
  • JoeriJoeri Member Posts: 75
    Hi Tino,

    No we probably don't need that many records, but i'm afraid it's a small project to sort out what they do or don't need anymore. So we have to make do with what we have.

    It's filled because in the old version it had to be filled in with data, now in the new version of the software the default value is empty and the tablerelation and function of this field has changed (don't ask me why). So the data in it isn't relevant anymore, and for everything to work as designed it has to be empty.

    We cannot remove the field from the primary key because this field WILL be used in the future, and there are tablerelations and codeunits pointing to this key.


    Malajlo,

    I also considered to do this, but I can't time-test this easily without actually doing this. And like you said, the rebuilding of the key will take some time.


    But, there isn't any way to just use the Rename trigger?
  • tinoruijstinoruijs Member Posts: 1,226
    Joeri,

    Is this an option? Read it in http://www.mibuso.com/forum/viewtopic.php?t=11222.

    You could also create another field called EntryNo, fill it in with a unique integer for each record, then change the primary key for the table to EntryNo, make your changes, set the primary key back to the default, and delete and remove the EntryNo field.

    Tino Ruijs
    Microsoft Dynamics NAV specialist
Sign In or Register to comment.