Pirx
Pirx

Reputation: 45

Squirrel Client DB2 Stored Procedure Session Delimiter

I am facing a tricky problem while I am trying to run stored procedure via Squirrel against DB2 database. In the stored procedure have part where combine an sql statement like this:

SET V_SQL = 'SELECT DISTINCT ' || PARAM_COLUMNNAME || ' FROM '||PARAM_TABLENAME||' WHERE '||PARAM_COLUMNNAME||'<'||PARAM_NUMBER||';';

I changed the session statement paramater ; --> @ to run properly the procedure call, but I get error message:

An unexpected token "" was found following "". Expected tokens may include: "WHERE REP_ID<201506".. SQLCODE=-104, SQLSTATE=42601, DRIVER=3.59.81 SQL Code: -104, SQL State: 42601

I guessed it is because of the delimeter ';' of the inside sql script so I changed the code like this:

SET V_SQL = 'SELECT DISTINCT ' || PARAM_COLUMNNAME || ' FROM '||PARAM_TABLENAME||' WHERE '||PARAM_COLUMNNAME||'<'||PARAM_NUMBER||'@';

Then I get this message:

The numeric literal "201506@" is not valid.. SQLCODE=-103, SQLSTATE=42604, DRIVER=3.59.81 SQL Code: -103, SQL State: 42604

Do you have any idea?

Squirrel: SQuirreL SQL Client snapshot-20150623_2101 DB2: 9.5

Thanks and Cheers.

Upvotes: 1

Views: 1028

Answers (1)

Pirx
Pirx

Reputation: 45

So finally what for me worked it was the comment sign: SET V_SQL = 'SELECT DISTINCT ' || PARAM_COLUMNNAME || ' FROM '||PARAM_TABLENAME||' WHERE '||PARAM_COLUMNNAME||'<'||PARAM_NUMBER||';';--

The explanation I am not sure why pass through in this way the database engine, but worked. Thanks!

Upvotes: 0

Related Questions