Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
I have a problem with peek function when using a load statement:
Let's say there is a table called 'ListTickets', with one field 'Ticket', and only three values : A, B, and C
I would like to use the peek function with each row one at a time, save the value in a variable, and use the variable in a load statement
My code is:
ListTickets:
LOAD * INLINE [
Ticket
A
B
C
];
for a=0 to 2
let teest = chr(39) & peek('Ticket', $(a), ListTickets) & chr(39);
TableX:
load $(teest) as TicketTest
AutoGenerate(1);
next
Unfortunately, I do not understand the behaviour of the script
If I write :
let teest = peek('Ticket',0, ListeTickets);
let teest = peek('Ticket',1, ListeTickets);
let teest = peek('Ticket',2, ListeTickets);
before any LOAD statement, I have no problem, teest has the expected values (A, B, and C) [:)]
after the LOAD statement, teest has always NULL as value [:@]
Do you know what happens ?
Hello Pierre,
I've done a few changes to your script, and it works fine for me
ListTickets:LOAD * INLINE [TicketABC]; FOR a = 0 TO 2 LET teest = PEEK('Ticket', $(a), 'ListTickets'); // Fields are case sensitive, both field and table name must be quoted TableX: LOAD '$(teest)' as TicketTest // I use single quotes here, instead of using them as chr(39) in the variable above AUTOGENERATE (1); NEXT
Hope this helps
Hello Pierre,
I've done a few changes to your script, and it works fine for me
ListTickets:LOAD * INLINE [TicketABC]; FOR a = 0 TO 2 LET teest = PEEK('Ticket', $(a), 'ListTickets'); // Fields are case sensitive, both field and table name must be quoted TableX: LOAD '$(teest)' as TicketTest // I use single quotes here, instead of using them as chr(39) in the variable above AUTOGENERATE (1); NEXT
Hope this helps
Hi Miguel
Thanks a lot for your help !
It seems the problem is coming from the quotes that I forgot when specifying the table name in the peek function.
In QV help, it is explained that the table name should not be between quotes, and clearly it works with quotes...
Thanks again
Hi Pierre (Miguel),
this is absolutly correct. In the help it looks quite the other way as it is in reality. Don't bother, this is a trap I felt in about 10...... times 😉
Regards, Roland