Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys, stalwar1
Suppose I have a table containg a field Alert:
load Alert inline [
Alert
alert1
alert2
alert3
];
How to do to store all of the alerts (alert1, alert2 and alert3) into a variable?
the goal is to store all this values ito a database as a final objectif; for this, I want to be able to loop all the alerts one by one, and everytime store one value into the destination column, till all the values are stored.
Hope my question is clear enough?
Yes you can;
see :
alerts:
load Alert inline [
Alert
alert1
alert2
alert3
];
For i = 1 to FieldValueCount('Alert')
LET vAlert = FieldValue('Alert', $(i));
Table:
//LOAD $(vAlert) as alert AutoGenerate 1 ;
load FieldValue('Alert', $(i)) as alert resident alerts;
STORE alert FROM Table INTO [lib://OBS/class.txt]
(txt);
NEXT i;
But the loop logic (the next i is false)
Now when I try your code:
I have this error
Thanks, I'm trying to store it in database table, so I need to have each value apart
May be DROP Table Table after every loop?
alerts:
load Alert inline [
Alert
alert1
alert2
alert3
];
For i = 1 to FieldValueCount('Alert')
LET vAlert = FieldValue('Alert', $(i));
Table:
//LOAD $(vAlert) as alert AutoGenerate 1 ;
load FieldValue('Alert', $(i)) as alert resident alerts;
STORE alert FROM Table INTO [lib://OBS/class.txt]
(txt);
DROP Table Table;
NEXT i;
Try it like this Sunny ! It works !
alerts:
load Alert inline [
Alert
alert1
alert2
alert3
];
FOR Each a in FieldValueList('Alert')
dim:
let vAlert = a;
LOAD '$(vAlert)' as Alerts AutoGenerate 1;
Store dim into [lib://OBS/class.txt] (txt);
NEXT a
You want to store alert1 alert2 and alert3 in a text file? why loop?
As I told, I want to store all of my alerts into a database; for that, I'll have to loop each value, put into a variable, store it into the database using a procedure and so on; so I had to do it using variables.
I can't directly use the field Alert..
It would be sthing like this:
lib Connect To databaseName;
FOR Each a in FieldValueList('Alert')
let vAlert=a;
sql use databaseName
exec writeBack'$(vAlert)';
next a
This worked for me
alerts:
LOAD * INLINE [
Alert
alert1
alert2
alert3
];
For i = 1 to FieldValueCount('Alert')
LET vAlert = FieldValue('Alert', $(i));
Table:
NoConcatenate
LOAD '$(vAlert)' as alert
AutoGenerate 1;
STORE alert FROM Table INTO [class$(i).txt] (txt);
DROP Table Table;
NEXT i;