I'm trying to determine how to assign the results of a query to a variable. No problem connecting to the database or running the query. I just can't figure out where the query results are going. After I determine how to get at that data, then I'll be looking for a way to test it for an IF/Else condition. That's probably the hardest part of this project. Everything else if fairly straightforward. If I can get this done quickly I'll purchase the product and be done.
Can anyone provide guidance/examples?
Thanks!
SQL Query Results
SQL Query Results
What SQL guery do you use? May be you need to use a dataset loop action.
For example:
SQL Query is: select max(fieldname) from mytable
This query contain one field an one record. In dataset loop you can assign result to user variable. If you have many fields in you query you can access to field value using expression {FieldValues(N)} where N is a field number (beginning from 0).
See example below.
;**********************
;* RoboTask Task file *
;* Do not edit! *
;**********************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|565106205
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task209"
Hide=INTEGER|0
ID=INTEGER|518922914
Name=STRING|"Dataset Loop..."
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
[Actions\Action1]
ActionID=STRING|"A_LOOP_DATASET"
Enabled=INTEGER|-1
Name=STRING|"Dataset Loop"
Params=FOLDER
[Actions\Action1\Params]
commatext=STRING|"0"
connectionstring=STRING|"Provider=MSDASQL.1;Persist Security Info=False;Data Source=MetaDBDemo"
override=STRING|"0"
password=STRING|"1928818827198531985664660"
sql=STRING|"""select * from emp"""
var1=STRING|"FIELDNAMES"
var2=STRING|"FIELDVALUES"
withmemo=STRING|"0"
[Actions\Action2]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{FieldNames(0)}={FieldValues(0)}"""
Params=FOLDER
[Actions\Action2\Params]
icon=STRING|"1"
msg0=STRING|"{FieldNames(0)}={FieldValues(0)}"
msg1=STRING|"{FieldNames(1)}={FieldValues(1)}"
msg2=STRING|"{FieldNames(2)}={FieldValues(2)}"
msg3=STRING|"{FieldNames(3)}={FieldValues(3)}"
msgcount=STRING|"4"
playsound=STRING|"0"
showmessage=STRING|"1"
[Actions\Action3]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"
For example:
SQL Query is: select max(fieldname) from mytable
This query contain one field an one record. In dataset loop you can assign result to user variable. If you have many fields in you query you can access to field value using expression {FieldValues(N)} where N is a field number (beginning from 0).
See example below.
;**********************
;* RoboTask Task file *
;* Do not edit! *
;**********************
[Root]
ActionAfterRun=INTEGER|0
Actions=FOLDER
Automat=INTEGER|-1
CatID=INTEGER|565106205
ContinueOnError=INTEGER|0
ExternalName=STRING|"Task209"
Hide=INTEGER|0
ID=INTEGER|518922914
Name=STRING|"Dataset Loop..."
Priority=INTEGER|3
RunOnClose=INTEGER|0
RunOnStartup=INTEGER|0
ToLog=INTEGER|3
[Actions]
Action1=FOLDER
Action2=FOLDER
Action3=FOLDER
[Actions\Action1]
ActionID=STRING|"A_LOOP_DATASET"
Enabled=INTEGER|-1
Name=STRING|"Dataset Loop"
Params=FOLDER
[Actions\Action1\Params]
commatext=STRING|"0"
connectionstring=STRING|"Provider=MSDASQL.1;Persist Security Info=False;Data Source=MetaDBDemo"
override=STRING|"0"
password=STRING|"1928818827198531985664660"
sql=STRING|"""select * from emp"""
var1=STRING|"FIELDNAMES"
var2=STRING|"FIELDVALUES"
withmemo=STRING|"0"
[Actions\Action2]
ActionID=STRING|"A_DIALOG_MESSAGE"
Enabled=INTEGER|-1
Name=STRING|"Show ""{FieldNames(0)}={FieldValues(0)}"""
Params=FOLDER
[Actions\Action2\Params]
icon=STRING|"1"
msg0=STRING|"{FieldNames(0)}={FieldValues(0)}"
msg1=STRING|"{FieldNames(1)}={FieldValues(1)}"
msg2=STRING|"{FieldNames(2)}={FieldValues(2)}"
msg3=STRING|"{FieldNames(3)}={FieldValues(3)}"
msgcount=STRING|"4"
playsound=STRING|"0"
showmessage=STRING|"1"
[Actions\Action3]
ActionID=STRING|"A_LOOP_END"
Enabled=INTEGER|-1
Name=STRING|"End Loop"