Insert data in 2 tables MyBatis Error Command not properly ended - oracle

I´m trying to insert data in 2 tables, I have mybatis method with 2 single inserts but when I execute it it throws:
Error updating database. Cause: java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
Any idea?

solve using in mybatys method pl/sql
{call
declare
begin
end
}

Related

Java.sql.SQLException: operation not allowed with Oracle procedure and mybatis

I am using Mybatis with springboot to connect with an Oracle database. In that process I need to update multiple fields in bulk.
I have created a procedure to implement that functionality on the database side. When calling that procedure from the DAO layer, the following exception occurs:
org.springframework.jdbc.UncategorizedSQLException:
Error getting generated key or setting result parameter object.
Cause
Java.sql.SQLException: operation not allowed.
<insert id="update" parameter="java.util.map" statement="callable">
{ call test.bulk_update_procedure(#{customerid, mode=IN , jdbcType= varchar},#{firstname, mode= IN, jdbcType= varchar},#{age,mode=IN, jdbcType=varchar})
</insert>

DB2 Problem inserting data in Stored Procedure

I need to insert data to 3 tables. I'm trying to use a SP. I know I could use Triggers instead but, for integrity reasons, I can't.
When I execute the INSERT statement in an independient Script, I works fine.
The problem is I'm trying to do the insert statement in the SP but it throws me
[SQL7008] error.
I don't know why it throws me this error only in the SP and not (using the same insert statement) in an independient script.
It's good to provide the DB2 version.
If it's DB2 for IBM i (aka iSeries, OS/400), then:
Received an SQL7008 error when attempting to INSERT data into an AS/400 table. "REXX variable '' contains inconsistent data".

Error running SQL queries with Liquibase

I'm using Liquibase to create tables in DB2. I have a simple example changelog that tries to drop and then create a table.
The SQL statements work fine via my DbVisualizer tool (which uses the same JDBC driver as Liquibase) and also works fine when submitted via the db2 command line tool.
Here's the Liquibase input file:
--changeset dank:1 runAlways=true failOnError:false
DROP TABLE AAA_SCHEMA.FOO
--changeset dank:2 runAlways=true
CREATE TABLE AAA_SCHEMA.FOO ( MYID INTEGER NOT NULL )
Here's the error message I get:
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error:
SQLCODE=-104, SQLSTATE=42601, SQLERRMC=DROP TABLE AAA_SCHEMA.FOO;
;, DRIVER=4.18.60
The IBM error code -104 is about syntax problems. Based on looking at the error message my guess is that it has something to do with the end of line character ";". But I've tried the query with and without the semi-colon. The semi-colon is accepted by IBM's own db2 too, so it seems like a valid choice.
Any help in figuring out the cause of this error is much appreciated.
The problem was me forgetting to start my native sql file with this required line:
--liquibase formatted sql
Doh!

Execute two DML statements in DB2 using JDBC

I'm trying to execute two DML statements in DB2 using JDBC and I keep getting a syntax error:
ALTER TABLE "TEST" ALTER COLUMN "COL1" SET DATA TYPE INT;
ALTER TABLE "TEST" ALTER COLUMN "COL1" SET NOT NULL;
If I execute them one by one everything is OK.
I've tried with no semicolons, only one semicolon on the first statement. I also tried with several \r\n and I really can't understand what the problem is.
The exception is the following:
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-104, SQLSTATE=42601, SQLERRMC=;
ALTER TABLE "TEST";1" SET DATA TYPE INT;<space>, DRIVER=3.65.77
Does anyone know what might be the problem?
Obviously, the execute() method accepts only a single statement, not multiple statements delimited by whatever you might try. It's clearly stated in the API documentation: "Executes the given SQL statement".
You can wrap multiple statements into a (single) compound statement:
begin execute immediate 'alter ...'; execute immediate 'alter ...'; end

How to deploy Oracle Dimension table for OLAP Cubes

I followed First Example as well as Second Example to create Cubes in Oracle 10g.
I tried to create cube using query rewrite mechanism in Oracle 10g.
(Intailly tried to create using Analystic workspace manager we got error in that too so only we went for query rewrite mechansism)
We succeded in creating table "PRODUCTS"
Also we succedded in creating Dimension for that table "PRODUCTS"
But when we try to create Attribute for the above "PRODUCTS" table like below
BEGIN
cwm_classify.remove_entity_descriptor_use(28, cwm_utility.DIMENSION_TYPE, 'SH', 'PRODUCTS');
COMMIT;
END
we are getting following error.
Note : We have data inside table too
Error starting at line 1 in command:
begin
cwm_classify.remove_entity_descriptor_use(28, cwm_utility.DIMENSION_TYPE, 'SH', 'PRODUCTS');
commit;
end;
Error report:
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "OLAPSYS.CWM$OLAP$DIMENSION", line 242
ORA-06510: PL/SQL: unhandled user-defined exception
ORA-06512: at "OLAPSYS.CWM$UTIL", line 368
ORA-01403: no data found
ORA-06512: at "OLAPSYS.CWM$CLASSIFY", line 322
ORA-06512: at "OLAPSYS.CWM$CLASSIFY", line 1198
ORA-06512: at line 2
06510. 00000 - "PL/SQL: unhandled user-defined exception"
*Cause: A user-defined exception was raised by PL/SQL code, but
not handled.
*Action: Fix the problem causing the exception or write an exception
handler for this condition. Or you may need to contact your
application administrator or DBA.
When i googled i got suggestion like we have to deploy Dimension also before deploying Cubes.
So i'm trying to create OLAP Cubes for this i need to to deploy Dimension Tables in Oracle.
Is there any way to deploy Dimension is that possible actually?
Suggest me how to do this?
Assuming you are using Analytic Workspace Manager, the OLAP documentation would be a good place to start:
http://download.oracle.com/docs/cd/E11882_01/olap.112/e17123/cubes.htm#BGBDJAAG

Resources