Can't insert record in temporary RecordRef :(

arcullarcull Member Posts: 191
Hi, I would like to insert some records from real table to temporary table using RecordRef, but unfortunately it doesn't work, It says the record already exists in table already the first time it enters the loop. The real table 13010988 is not empty, but since I want to store records in temporary instance of it, that shouldn't matter. Does anyone know what could be the problem, thanks.
      FERecR2.OPEN(13010988,TRUE);
      //FERecR2.SETTABLE(FERecTmp);
      REPEAT
        MESSAGE(FORMAT(FERecR2.COUNT));
        FERecR2 := FERecR;
        FERecR2.INSERT;
      UNTIL FERecR.NEXT = 0;
      MESSAGE('%1',FERecTmp.COUNT);

Comments

  • PeterDPeterD Member Posts: 66
    For a temporary table you make a variable of DataType Record AND set the property Temporary to Yes. But if you make a variable of DataType RecordRef there is no property Temporary. I guess what you want to do isn't possible.

    The error you get is because your RecordRef is pointing to the actual table.
  • krikikriki Member, Moderator Posts: 9,110
    You need to use the DUPLICATE-function of recordref.

    A recordreference is like a pointer to some data and you just assign the pointer to another variable BUT THEY BOTH POINT TO THE SAME DATA!
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • arcullarcull Member Posts: 191
    Thanks, I thought of that already, but why is there the option to open RecordRef as Temp when associating it with a table FERecR2.OPEN(13010988,TRUE); ? Because if you use the TRUE switch and try to count the records in RecordRef you get 0, while without it you get the actual number of records in physical table. So I thought it may be used this way.
          FERecR2.OPEN(13010988,TRUE);
          FERecR2.SETTABLE(FERecTmp);
    
    In order to get records inserted in Record variable. Where FERecTmp is the same table but marked as temporary. But now I guess it can't be done this way. Thanks anyway.
Sign In or Register to comment.