Hi folks,
I have a script file with the following code that runs great in Hana Studio that times the execution of statements that looks like this
DO
BEGIN
DECLARE starttime timestamp;
DECLARE endtime timestamp;
starttime = CURRENT_UTCTIMESTAMP;
select count(*) FROM sflight.sairport;
endtime = CURRENT_UTCTIMESTAMP;
SELECT
:starttime AS "Start Time"
, :endtime AS "End Time"
, NANO100_BETWEEN( :starttime, :endtime)/10000 AS "Elapsed Time (ms)" FROM DUMMY;
END
I end up with my two desired result sets - the first with the results of the main query and the second with the start, end and elapsed time. I then saved the file and called it Airport_Count.sql
When I try to run the file using HDBSQL on my Windows system, I get the following syntax errors related to the DECLARE statements - output using -t debug option
DO
BEGIN
DECLARE starttime timestamp
* 257: sql syntax error: line 4 col 20 (at pos 30) SQLSTATE: HY000
DECLARE endtime timestamp
* 257: sql syntax error: incorrect syntax near "DECLARE": line 1 col 1 (at pos 1) SQLSTATE: HY000
starttime = CURRENT_UTCTIMESTAMP
* 257: sql syntax error: incorrect syntax near "starttime": line 1 col 1 (at pos 1) SQLSTATE: HY000
select count(*) FROM sflight.sairport
| COUNT(*) |
| -------------------- |
| 53 |
endtime = CURRENT_UTCTIMESTAMP
* 257: sql syntax error: incorrect syntax near "endtime": line 1 col 1 (at pos 1) SQLSTATE: HY000
SELECT
:starttime AS "Start Time"
, :endtime AS "End Time"
, NANO100_BETWEEN( :starttime, :endtime)/10000 AS "Elapsed Time (ms)" FROM DUMMY
* 467: cannot use parameter variable: STARTTIME: line 2 col 3 (at pos 10) SQLSTATE: HY000
END
Other than encapsulating this code into a stored procedure and running the queries as a call statement to the stored procedure, does anyone have any ideas on how to run scripts with HDBSQL that includes DO BEGIN ... END blocks - see DO BEGIN ... END - SAP HANA SQL and System Views Reference - SAP Library
I see in the debug information that the batch option is "FALSE", but I don't see a command line parameter to set the batch option on. Here is the command line I'm using.
C:\Queries>"C:\Program Files\sap\hdbclient\hdbsql.exe" -i 00 -n awshana:30015 -u SYSTEM -p password -I "Airport_Count.sql" -A -f -t -z -j -c ";"
Thanks in advance!
Bill