Plsql statements not working with ANT - sql

I have a file with the following content:
-- KERNEL72 - SWIFT Silver changes start
/*
drop synonym ispkss_vals
/
create synonym ispkss_vals for ispks_vals
/
*/-- KERNEL72 - SWIFT Silver changes ends after the below line
create or replace synonym ispkss_vals for ispks_vals
/
This is compiling properly in SQL Plus. But while compiling using ANT, I am getting the following error:
[sql] Failed to execute:
[sql] -- KERNEL72 - SWIFT Silver changes start
[sql] /*
[sql] drop synonym ispkss_vals
[sql] java.sql.SQLException: Invalid SQL type
[sql] Failed to execute:
[sql] create synonym ispkss_vals for ispks_vals
[sql] java.sql.SQLSyntaxErrorException: ORA-00955: name is already used by an existing object
[sql] Failed to execute:
[sql] */-- KERNEL72 - SWIFT Silver changes ends after the below line
[sql] create or replace synonym ispkss_vals for ispks_vals
[sql] java.sql.SQLSyntaxErrorException: ORA-00900: invalid SQL statement
Im using the following ANT scripts for compilation:
<sql driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:#10.184.1.13:1521:UPP"
userid="${UsernameB}"
password="${PasswordB}"
onerror="continue"
strictDelimiterMatching="false"
delimiter="/"
keepformat="yes">
Please advice on why ANT compilations are not proper.

Perhaps the problem is that you are using / as the statement delimiter and also trying to comment with /* ... */?
It may be treating the comment opening and closing as delimiters, creating sql statements that don't make sense. (one would start with *, etc.)

Related

DB2 stored procedure gave syntax errors

I am creating a stored procedure for db2. But it is giving an error saying that
"SQL Error [42601]: An unexpected token "END-OF-STATEMENT" was found
following "SS_TOKEN_BAK". Expected tokens may include: " END IF"..
SQLCODE=-104, SQLSTATE=42601, DRIVER=4.23.42".
Following is my stored procedure.
CREATE OR REPLACE PROCEDURE TOKEN_CLEANUP_SP
BEGIN
DECLARE batchSize INTEGER;
-- ------------------------------------------
-- CONFIGURABLE ATTRIBUTES
-- ------------------------------------------
SET batchSize = 10000; -- SET BATCH SIZE FOR AVOID TABLE LOCKS [DEFAULT : 10000]
-- ------------------------------------------------------
-- BACKUP IDN_OAUTH2_ACCESS_TOKEN TABLE
-- ------------------------------------------------------
IF EXISTS (SELECT TABLE_NAME FROM TABLES WHERE TABLE_NAME = 'IDN_OAUTH2_ACCESS_TOKEN_BAK')
THEN
DROP TABLE IDN_OAUTH2_ACCESS_TOKEN_BAK;
END IF;
END/
Is anyone face this type of issue. Any help on this would be much appreciated.
Verify that you have the end-of-statement delimiter configured correctly for whatever tool submits the 'CREATE OR REPLACE' procedure. Different tools have different ways to configure the block terminator (alternatively known end of statement delimiter). For command line scripts, use --#SET TERMINATOR / at the start of the file, other ways are possible.
Your code sample shows / as the block terminator, so you might want to use that character as the block delimiter. The semi-colon terminates statements inside the block.
Separately you should see that your code won't compile if the specified table does not exist in the implied schema at compilation time, because you are using static SQL. You may want to use dynamic SQL instead for the drop table statement (search for 'EXECUTE IMMEDIATE' examples).

db2 stored procedure format

I'm using db2 and SQuirreL SQL
I'm trying to create a stored procedure with a simple select statement inside of it. When I omit the select statement in the following below and run the code, the procedure is created. Also this procedure can be dropped and called.
CREATE PROCEDURE test_procedure
LANGUAGE SQL
BEGIN
END
When I add in the select statement, I get Error: DB2 SQL Error: SQLCODE=-102, SQLSTATE=42601,...
CREATE PROCEDURE test_procedure
LANGUAGE SQL
BEGIN
SELECT column_name FROM table_name
END
If you go to IBM iseries information center is says:
SQL0104 SQLCODE -104 SQLSTATE 42601
Explanation: Token &1 was not valid. Valid tokens: &2.
It appears that I wasn't given the right permissions to execute the stored procedure. SQL0551N This link explains more about the issue.
The statement terminator in SQuirreL is called "Statement separator" and it can be defined in:
Menu Session > Session Properties... > tab SQL > at the end of the SQL square, the option Statement Separator.
This is valid in version 3.5.3

PLS-00306: wrong number or types of arguments in call to - Error

I am getting following error when calling a oracle plsql procedure using spring jdbc in java.
org.springframework.jdbc.BadSqlGrammarException: CallableStatementCallback; bad SQL grammar [{call "Procedure name"; nested exception is java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'procedure_name'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
This procedure exist under a package A in schema S1. I have created a synonym in schema S2 for this package A and trying to execute this procedure using spring SimpleJdbcCall, with schema name S2 but it's giving me the above error.
But when i execute this query using SqlPlus in schema S2, this procedure executes fine, it means there is no grant issue with this.
When i execute the same procedure with the Schema name where it actually exists (S1) then also it executes fine using spring-java.
Is there any issue related to synonym created in Schema S2 for this package A??
Am i missing anything here?
I hit the same issue and like you explicitly declared the parameters. The fix was to additionally specify:
new SimpleJdbcCall(dataSource)
.withoutProcedureColumnMetaDataAccess()
...
My assumption is that the synonym is preventing the parameter inference from working without actually stopping it happening and as a result the driver concludes that the stored procedure does not accept any parameters and therefore does not send any.
Old question so I know this won't help the OP but hopefully it helps someone.
Without seeing your code (both the PLSQL and Java side), I would have to say that the procedure has required parameters (no DEFAULT value for a parameter) that you are not supplying in the Java code or the name of the parameter in the procedure does not match the name you used in Java.
Procedure Spec
PROCEDURE procedure1(value OUT NUMBER,
userId IN NUMBER,
returnCursor OUT PackageA.Types.cursorType);
Java-Code
SimpleJdbcCall optOutCall = new SimpleJdbcCall(dataSource)
.withSchemaName("Schema-A")
.withCatalogName("PackageA")
.withProcedureName(procedure1)
.declareParameters(new SqlOutParameter("value", Types.NUMERIC),
new SqlParameter("userId", Types.NUMERIC))
.returningResultSet("returnCursor", new UserMapper(EnumType.EMAIL, userId));
This "procedure1" exists in Schema-B but i have created a synonym for this procedure in Schema-A and i am trying to execute this procedure
using 'Schema-A' but it throws error, if i give the schema name "Schema-B" in java code then it executes correctly and returns the results.

How to Truncate Multiple Table in SSIS ( using ADO.NET Destination and Oracle Database)

I got a little trouble in SSIS. I have multiple table and i want adding Truncate statement so that table can't create double data.
This is the image of package that I made :
each Data Flow, i used Flat File Source and ADO NET Destination.
And then, in Execute SQL Task i want to apply Truncate Table
After that, i have error message :
"[Execute SQL Task] Error: Executing the query "truncate table Table1
truncate table Tabl..." failed with the following error: "ERROR
[HY000] [Oracle][ODBC][Ora]ORA-00911: invalid character". Possible
failure reasons: Problems with the query, "ResultSet" property not set
correctly, parameters not set correctly, or connection not established
correctly."
What i must suppose to do?
P.S
Sorry if my english is not good
Since the destination is an Oracle Database you should use this syntax:
begin
execute immediate 'truncate table t1';
execute immediate 'truncate table t2';
end;
Does this syntax work:
truncate table table1;
truncate table table2;
Note the semi colons.

Oracle 10gR2 trigger error

I have Oracle 10gR2. I am trying to create autoincrement trigger.
Here is the sample:
CREATE SEQUENCE TEST_SEQ
INCREMENT BY 1
START WITH 1
NOMAXVALUE
/
CREATE TABLE TESTER (
ID_TESTER INTEGER NOT NULL,
VAL VARCHAR2(20) NOT NULL
)
/
CREATE OR REPLACE TRIGGER TIB_TESTER BEFORE INSERT
ON TESTER FOR EACH ROW
BEGIN
SELECT TEST_SEQ.NEXTVAL
INTO :NEW.ID_TESTER
FROM DUAL;
END;
/
Trigger creation gives warning:
warning : ORA-24344: success with
compilation error
And when I get error value:
select OCI_SUCCESS_WITH_INFO;
/
It gives error:
error : ORA-00923: FROM keyword not
found where expected
What client are you using to issue these commands? ORA-24344 is a perculiar error.
In SQL*PLus we can get more information about compilation errors like this:
SQL> show errors
As for the ORA-00923 error, that is because in Oracle's version of SQL we always have to select from a table. So you should execute
select OCI_SUCCESS_WITH_INFO
from dual
/
I'm not sure how much sense that makes, but at least you won't get the error.
"It was Navicat problem"
That doesn't surprise me, as I ran your code against my database and it built without a hitch.
Maybe it will be useful for somebody:
If you are using Oracle 10g and OCI driver, ORA-24344 shows when trigger have carriage return sign (\r) in code eg. file was created with Windows end of line style.