Error Regarding Running Stored procedure using liquibase - db2

I am try to execute the stored procedure using liquibase having the / delimiter in
sql file the Database Is db2. The problem is it is giving me error as DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=END-OF-STATEMENT;demoTable = ((demovar;) not able to understand the cause as all other stored procedure in same file get executed well..
using the following changeset
and demo.sql has the stored procedure and set demovar declare in it
any suggestion what is cause

Your error message says:
DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601
-104 represents SQL0104N and here is explanation.
SQL0104N An unexpected token token was found following text. Expected tokens may include: token-list.
https://www.ibm.com/support/knowledgecenter/en/SSEPGG_11.5.0/com.ibm.db2.luw.messages.sql.doc/com.ibm.db2.luw.messages.sql.doc-gentopic1.html#sql0104n
Explanation
A syntax error in the SQL statement or the input command string for the SYSPROC.ADMIN_CMD procedure was detected at the specified token following the text text. The text field indicates the 20 characters of the SQL statement or the input command string for the SYSPROC.ADMIN_CMD procedure that preceded the token that is not valid.
As an aid, a partial list of valid tokens is provided in the SQLERRM field of the SQLCA as token-list. This list assumes the statement is correct to that point.
This message can be returned when text is passed to the command line processor (CLP) in command mode and the text contains special characters that are interpreted by the operating system shell, such as single or double quotes, which are not identified with an escape character.
The statement cannot be processed.
So you may need to follow "User response" section of the page and correct SQL statement in demo.sql.
Hope this helps.

Related

Redshift Correlated Subquery within copy command

I am trying to query from a table within a copy command however, I have continually gotten errors. Here is the example SQL statement.
copy schema.table
from 's3://bucket/folder`
iam_role (select value from roles.iam where key = 'IAMRole');
The inner select statement on its own returns a value however, when I run the above, I get the following error:
SQL Error [500310] [42601]: [Amazon](500310) Invalid operation: syntax error at or near "("
The COPY command, as you must suspect, does not support embedded SQL.
If you want to do something like this, you can, but you'll need a procedure.

DB2 query ,throwing an error

My DB2 query is throwing an error while executing it in DB2 visualizer
DB2 Query :
CREATE OR REPLACE PROCEDURE EDH.WBS_ENTITY (IN column_names varchar(2000),
IN filter_by varchar(2000), IN LIMIT_VALUE INT, IN OFFSET_VALUE INT)
DYNAMIC RESULT SETS 1
LANGUAGE SQL
BEGIN
DECLARE v_dynamicSql varchar(2000);
END ;
Error
[Code: -104, SQL State: 42601] An unexpected token "END-OF-STATEMENT" was found following "micSql varchar(2000)". Expected tokens may include: "".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.22.29
This is a FAQ.
Ensure that you configure your dbvis with an alternative statement-delimiter(terminator) , and then use that special delimiter at the end of the procedure. Db2 needs to know the difference between the delimiters used inside the sproc, as distinct from the delimiter that ends the 'create procedure' statement.
dbvis also has the #delimiter command to let you specify this. Refer to the dbvis documentation for details.
For IBM data studio, see this link, or refer to its online documentation.

DB2 query with slash in table name

please I have table name SAPPRD./CS1/TB2_SOPBV and I canĀ“t do this query:
transfer ownership of table SAPPRD./CS1/TB2_SOPBV TO USER SAPQAS preserve privileges;
I am getting error:
DB21034E The command was processed as an SQL statement because it was
not a valid Command Line Processor command. During SQL processing it
returned: SQL0104N An unexpected token "/CS1/" was found following
"hip of table SAPFIP.". Expected tokens may include: "".
SQLSTATE=42601
So I tried to do escaping, I edited query to:
transfer ownership of table SAPPRD.\"/CS1/TB2_SOPBV" TO USER SAPQAS preserve privileges
But It will not escape, I am still getting error:
DB21034E The command was processed as an SQL statement because it was
not a valid Command Line Processor command. During SQL processing it
returned: SQL0007N The statement was not processed because a character
that is not supported in SQL statements was included in the SQL
statement. Invalid character: "\". Text preceding the invalid
character: "hip of table SAPPRD.". SQLSTATE=42601
Is possible to do escaping here and proceed with this query?
Thank you!
Solved!
transfer ownership of table SAPPRD."/CS1/TB2_SOPBV" TO USER SAPQAS preserve privileges

dashDB for Bluemix --#SET TERMINATOR # is not working

By default the statement terminator is ; in dashDB.
I want to execute a statement with terminator as #
--#SET TERMINATOR #;
CREATE TABLE employee (id INT,
name VARCHAR(10),
salary DECIMAL(9,2))#
It fails with below exception :
An unexpected token # was found following salary DECIMAL(9,2)).
Expected tokens may include: "END-OF-STATEMENT".. SQLCODE =-104, SQLSTATE=42601
What SQL client are you using? If you are using the built-in Run SQL GUI in dashDB web console then you can set a custom statement terminator in the by clicking on the blue Options button.
If you are using the DB2 command line processor client, then you can set a custom statement terminator with the -td option, e.g. "-td#". See also https://www-01.ibm.com/support/knowledgecenter/?lang=en#!/SSEPGG_9.7.0/com.ibm.db2.luw.admin.cmd.doc/doc/r0010410.html?cp=SSEPGG_9.7.0%2F3-6-2-0-2
Within the same sql script you can not use different sql termination character. If you do need to use different termination character then you need to use one script for each character and use the db2 -td
Hope this helps.
Murali

An unexpected token "CREATE TRIGGER

CREATE TRIGGER TRG_EFMREFNO
BEFORE
INSERT ON FEEDBACK_CASE_TB
FOR EACH ROW
BEGIN
SELECT SEQ_EFMREFNO.NEXTVAL INTO:NEW.EFMREFNO FROM DUAL;
END;
please help me it's give errors
An unexpected token "CREATE TRIGGER TRG_EFMREFNO
BEFOR" was found following "BEGIN-OF-STATEMENT". Expected tokens may include: "<revoke>".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.12.79
An unexpected token "END-OF-STATEMENT" was found following "END". Expected tokens may include: "JOIN <joined_table>".. SQLCODE=-104, SQLSTATE=42601, DRIVER=4.12.79
Please give the solution for that errors
You have 2 things going on here -
1) When the ";" character is part of the SQL statement, it's necessary to use a different character to terminate the statement. I typically use "#". To tell the "db2" command that you have chosen a different character, use
db2 -td#
or if you want to read from a file
db2 -td# -f <somefile>
2) The correct way to update new row in a trigger is to set an alias for the new row, and use a set clause:
CREATE TRIGGER TRG_EFMREFNO
BEFORE
INSERT ON FEEDBACK_CASE_TB
REFERENCING NEW AS N
FOR EACH ROW
BEGIN
SET N.EFMREFNO = SEQ_EFMREFNO.NEXTVAL;
END
#
There may be other ways to use the sequence with the default clause in the create table statement that will accomplish the same thing: