I have an XML which is being called as part of software installer code. In the XML, I am executing SQL files using JDBC framework. The installer is failing at a point wherein the JDBC gets hole of the below statement inside a SQL file:-
Create or replace procedure test
as
Begin
...
End;
/
show errors
/
At the occurennce of "Show Errors" , the JDBC fails and installer execution finishes.
I have tried using the below syntax, but still JDBC fails.
Begin
show errors;
End;
/
When I remove "Show errors" from the SQL file, the installer finishes successfully. But I need to have "Show errors" in the SQL file.
Looking for some assistance here on how to use it without JDBC failing.
Thanks.
show errors is not a SQL statement, it's a SQL*Plus command, so it only works in SQL*Plus and cannot be used through JDBC.
Under the hood show errors simply queries the view ALL_ERRORS which you can do through JDBC as well:
SELECT line, position, text
FROM all_errors
WHERE owner = user
AND name = 'TEST' -- replace this with the name of your procedure
Related
I am trying to develop an SSIS package that truncates a table in Oracle db. Unfortunately i am getting an error
When i am trying to do select from the truncated table, it works fine - connection manager is setup correctly. I've recreated connection manager just in case but that did help.
Truncated table is in the same schema as the user on which ETL is runned.
Despite an error message, task does it's job. Table get's truncated but error message still appears.
Any ideas what could be the reason?
Regards,
Lukas
2.
Component that i used is Oracle Source task inside of DFT.Oracle source is using a query "TRUNCATE TABLE schema_Name.TableName":
When i use "SELECT * FROM schema_Name.TableName" works fine.
I have the solution.
Instead of using "SQL command" inside of Oracle Source task i used "Execute SQL Task" with the same query. I connected to Oracle db using OLE DB.
I am taking an existing SQL Server 2016 SSIS package and trying to add an Execute SQL Task. I'm suspicious that the task itself isn't the problem, but just in case, I'll explain it.
It is a simple task to query the count in a table, using an existing OLE connection. I create a user variable, set the ResultSet to Single Row, and put in my statement: "SELECT COUNT(fld) FROM MY_TABLE" It shows no errors, but when I try to execute it, I get the error in the title. I can change it to a BEGIN SELECT COUNT(fld) FROM MY_TABLE; END; or add a GO on the 2nd line - it makes no difference. I can set the ResultSet to None, and it makes no difference. I can create a new OLE Connection and use that, and it makes no difference.
I'm pretty sure it has to do with the Oracle driver, because nothing in the paragraph above makes any sense. I can test the connection and it works, however, and when I use the existing connection, it is parameterized for the project.
So what next? Reinstall the Oracle drivers? Or is there anything less drastic?
I started a new project, make a new OLE connection, a new Execute SQL task, and call an Oracle procedure. It works just fine. It's just trying to edit an existing project that doesn't work. Sometimes.
Oh, I'm also using Visual Studio 2019.
I was trying to create a procedure within one of the Oracle DBs. Procedure is intended for my colleagues, so that everybody could export the result of the query in a csv-file.
I was using "spool" commands. When running the code between BEGIN and END separately in Oracle SQL Developer (running as script, F5) - it worked, and created the file locally.
Then I tried to put it in the procedure, and that is where issue began. Some compilation errors come out. Most of them have code "PLS-00103". I tried searching for it, but not successful so far. I even tried EXECUTE IMMEDIATE statement, putting some script blocks inside it - not working so far.
I will appreciate any hints/help on approaching my situation.
P.s. one of my first attempts is below:
CREATE OR REPLACE PROCEDURE export_to_csv (SOURCE IN VARCHAR2, EXPORT_PATH IN VARCHAR2) is
BEGIN
spool on;
set feedback off;
set heading off;
set sqlformat csv;
spool EXPORT_PATH;
select * from SOURCE;
spool off;
END export_to_csv;
Nope, that won't work. SPOOL, as well as all SET commands you use, are SQL*Plus.
Stored procedure is PL/SQL, so - if you want to do it from there, you'll have to use UTL_FILE package. The result will be on the database server, not your local PC.
Alternatively:
put those SPOOL, SET, SELECT, ... commands into a .SQL file on the database server
create a database job using DBMS_SCHEDULER package which is capable of running operating system files. On MS Windows, you'd call CMD which establishes connection to the database using SQLPLUS executable and calls your .SQL script (using #)
just like in the previous option, the result will be on the database server, not on a local PC
See which option you prefer.
Maybe it would be simpler to create that .SQL file and give it to all your colleagues who'd then run it on their PCs and get the result locally.
I'm facing the below mentioned issue while executing a sql script through Java but the same script executes fine in Oracle sql developer.
Reason is not clear to me.
java.sql.SQLException: ORA-00900: invalid SQL statement
Could anyone suggest on how to resolve this issue ?
I tried importing this sql script into sql developer and it worked fine.
But when i try to execute it through java it fails.
CREATE OR REPLACE TRIGGER <SCHEMA_USERNAME>.TR$BIR_TSTATE_INFO BEFORE INSERT
ON <SCHEMA_USERNAME>.TSTATE_INFO
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
BEGIN
:NEW.CID := <SCHEMA_USERNAME>.SEQ_TSTATE_INFO_CID.NEXTVAL;
END;
I am beginner to liquibase usage and also to deployIT.
My question is when we run sql statements in sql developer editor we get output like anonymous block completed and also we see output of statements dbms_output.put_line....
If we run same scripts from liquibase,deployIt it does not show whatever shown in sqldeveloper editor like anonymous block completed etc
can any one please suggest what all can be done ?