Quantcast
Channel: SCN : Discussion List - SAP HANA and In-Memory Computing
Viewing all articles
Browse latest Browse all 5653

SQLScript procedure: Strange problem when declaring a cursor

$
0
0

Hello,

 

I have a very strange problem when creating a SQLScript procedure in HANA that declares a cursor.

The following procedure creation statement:

CREATE PROCEDURE example_proc( IN input_name VARCHAR,                                                                         OUT output_table tt_links)
LANGUAGE SQLSCRIPT READS SQL DATA AS
BEGIN          texta = SELECT TEXT FROM SEARCH.TABLE_A WHERE GENE = :input_name;          DECLARE Cursor C FOR SELECT * FROM SEARCH.TABLE_B;          OPEN C;          CLOSE C;            output_table = SELECT 123456 AS id, 'Title' AS title FROM SEARCH.TABLE_A ;
END;

 

fails with:

Could not execute 'CREATE PROCEDURE example_proc( IN input_name VARCHAR, OUT output_table tt_links) LANGUAGE SQLSCRIPT ...' in 5 ms 162 µs . SAP DBTech JDBC: [257] (at 204): sql syntax error: incorrect syntax near "DECLARE": line 6 col 2 (at pos 204)

 

The strange thing is that if I exclude the Cursor lines like that:

CREATE PROCEDURE example_proc( IN input_name VARCHAR,                                                                         OUT output_table tt_links)
LANGUAGE SQLSCRIPT READS SQL DATA AS
BEGIN          texta = SELECT TEXT FROM SEARCH.TABLE_A WHERE GENE = :input_name;            output_table = SELECT 123456 AS id, 'Title' AS title FROM SEARCH.TABLE_A ;
END;

all runs well.

 

And if I exclude the first line like that:

CREATE PROCEDURE example_proc( IN input_name VARCHAR,                                                                         OUT output_table tt_links)
LANGUAGE SQLSCRIPT READS SQL DATA AS
BEGIN          DECLARE Cursor C FOR SELECT * FROM SEARCH.TABLE_B;          OPEN C;          CLOSE C;            output_table = SELECT 123456 AS id, 'Title' AS title FROM SEARCH.TABLE_A ;
END;

all runs perfectly as well.

 

Both parts are completely independent and run well alone. Why don't they work together? I would very much appreciate if somebody had a hint or an answer.

 

Thank you very much in advance!

David Heller


Viewing all articles
Browse latest Browse all 5653

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>