I'm trying to query an external SQL database and return a subset of data based on the fact it is data that was generated in the last twenty minutes. I can return data and get most SQL queries to work but for some reason I can't get this to do what I want.
I construct the date/time and store it in LeadsDateTime variable - my suspiscion is that when the DBQuery> line is passed it isn't resolving the %LeadsDateTime% variable before passing and the database doesn't know what to do with it?
The error message is
"Error in : Database - Line:17 - Parameter object is improperly defined. Inconsistent or incomplete information was provided"
Thanks in advance for any help.
Code: Select all
GetDate>Today
GetTime>TheTimeNow
TimeAdd>TheTimeNow,M,-20,LeadsTime
Let>LeadsDateTime={(%Today%+" "+%LeadsTime%)}
GoSub>GetDatabaseData
GoSub>GetExcelReadyAndUpdate
SRT>GetDatabaseData
DBConnect>Provider=MSDASQL.1;Persist Security Info=False;User ID=USERID;Data Source=DATASOURCE,dbH
DBQuery>dbH,select * FROM tos_data WHERE data_date>%LeadsDateTime% ORDER BY data_date DESC,ReturnedData,NumRecs,NumFields,0
//Check For Data
If>{(%NumRecs%=0) OR (%NumFields%=0)}
MDL>The Database Is Currently Empty Please Try Again Later.
DBClose>dbH
Exit>1
EndIf
//Let>SQL=TRUNCATE tos_data
//DBExec>dbH,SQL,NotNeeded
DBClose>dbH
END>GetDatabaseData