0
votes

I come from a heavy T-SQL background, have been familiarizing myself with IBM Netezza appliance for a customer. I have played with the Netezza emulator 7.1 on Windows, ran DDL, DML, Control, and Transaction statements. Also, I signed up for a trial DashDB on Bluemix cloud.

ISSUE:

I am facing hurdles with the syntax on both Aginity workbench for DashDB and also the RunSQL on Bluemix

These prevent me from writing more complex SQL beyond simple DDL, DML statements. I am quite frustrated about this.

  1. variable declarations

T-SQL:

DECLARE @I AS INTEGER;

I tried this

DECLARE VARIABLE i INTEGER ; 

ERROR [42601] [IBM][DB2/LINUXX8664] SQL0104N An unexpected token "INTEGER" was found following "DECLARE i ". Expected tokens may include: "END-OF-STATEMENT".

DECLARE i AS INTEGER;

ERROR [42601] [IBM][DB2/LINUXX8664] SQL0104N An unexpected token "INTEGER" was found following "DECLARE i AS ". Expected tokens may include: "END-OF-STATEMENT".

DECLARE i INTEGER;

ERROR [42601] [IBM][DB2/LINUXX8664] SQL0104N An unexpected token "INTEGER" was found following "DECLARE i ". Expected tokens may include: "END-OF-STATEMENT".

none of these work...I am simply baffled!

  1. this very simple stored procedure sample from does not compile for me

Code:

CREATEPROCEDURE DASH6441.FOO (IN ORDER_DETAIL_CODE_IN VARCHAR(16), IN SALES_STAFF_CODE_IN INTEGER)
LANGUAGESQL
BEGIN
SELECT*FROM DASH6441.EMP;
END;

Error:

ERROR [42601] [IBM][DB2/LINUXX8664] SQL0104N An unexpected token "EMP" was found following "ECT * FROM DASH6441.". Expected tokens may include: "END".

Questions:

  • is there anything I am missing?

  • like T-SQL is there any structure for a SQL script, or preliminary directives (e.g. USING <db_name> in T-SQL) the compiler is expecting? I doubt it, but just asking

  • If you can share a skeleton of a variable declaration, stored procedure, or generic script with all those elements, which you know compiles successfully for you? Maybe I can inspire myself from that

I am facing a showstopper right now with this syntax issue.

2

2 Answers

0
votes

You might need to change the default statement separator in runSQL to be something other than the ; character, so that procedures will be processed correctly.

More info on the use of SQL PL in dashDB is here.

0
votes

for the create procedure issue the problem is as Margriet described the ambiguous statement delimiter. Just use e.g. delimiter '@' after the END statement and set this character in the RunSQL Page before executing the statement.

Regarding your problems with variable declarations: RunSQL allows to run individual SQL statements. Variable declarations are not valid as standalone SQLs, but only within the context of routines, e.g. within the BEGIN..END block of a stored procedure that you create. E.g. see the examples here: https://www.ibm.com/support/knowledgecenter/SS6NHC/com.ibm.swg.im.dashdb.sql.ref.doc/doc/r0004239.html