Options

How to write from Temp table to persistent table

KenmuKenmu Member Posts: 3
I have created a temp. table and read data from the jobqueues of multiple companies into it in order to gain easy access to our jobqueues. My issue is that, if fx. a job should be set to "ready" after failing, I want to be able to set the job to "ready" from the page loaded from the temp table.
However, since the ID-GUIDs are no more unique than appearing as ID's in the various companies, I have had to CLEAR the GUIDs and create new ones for the temp table in order to get all the data with unique IDs. The problem about that is of course that I have now lost the original GUID and therefore the reference for the entry in the original table, and thus cannot perform any actions on the original table.

Is the a neat solution to this that I'm missing?

Thanks

I have this code to read data into the temp table:

IF Company.FINDSET THEN REPEAT
IF jobqueueEntry.CHANGECOMPANY(Company.Name) THEN BEGIN
IF jobqueueEntry.FINDSET THEN
REPEAT
Rec := jobqueueEntry;
CLEAR(Rec.ID);
Rec.ID := CREATEGUID;
Rec.Text1 := Company.Name;
Rec.INSERT;
UNTIL jobqueueEntry.NEXT = 0;
END;
UNTIL Company.NEXT = 0;

Best Answers

Answers

  • Options
    JuhlJuhl Member Posts: 724
    Make company a part of PK in your table. You would need that anyway to know witch company to handle job in anyway!
    Follow me on my blog juhl.blog
  • Options
    waitwait Member Posts: 53
    Hi, I find it very strange if you are getting the same guid for more than one record, it should not be possible. Is it possible you need to clean some stuff out of your temp table when running the code? If you really have records with the same guid could you store the original guid in another field?
  • Options
    JuhlJuhl Member Posts: 724
    Standard jobs in NAV and copy company will give you identical guides.
    Follow me on my blog juhl.blog
  • Options
    KenmuKenmu Member Posts: 3
    @Juhl I am not allowed to make changes to our tables as things are at the moment, unfortunately.

    @wait I guess I could save the original guid in some other fields. A guess key:value would be optimal but that doesn't seem to be an option with c/al. Id rather not hardcode 15 variables. Do you have an idea for this?
  • Options
    JuhlJuhl Member Posts: 724
    If you have a datastructure that requires a PK of Company and GUID, and you cant change the table to fit the datastructure, then its hard to fix.
    Follow me on my blog juhl.blog
  • Options
    KenmuKenmu Member Posts: 3
    @Slawek_Guzek
    Neat. Thanks.

    One question, from where would I call PAGE.RUN(...)?
  • Options
    krikikriki Member, Moderator Posts: 9,089
    [Topic moved from 'General Chat' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.