How to detect SQL Server stored procedure failure from JDBC client? - jdbc

I have some Java code that uses JDBC to execute a "CREATE PROCEDURE" statement on a SQL Server 2008 instance. The create proc is failing due to an error ("Implicit conversion from data type xml to varchar(max) is not allowed. Use the CONVERT function to run this query.").
This error is not being raised to the JDBC client and so I have no indication that the sproc creation failed. As far as the JDBC statement and connection are concerned, after executing the CREATE PROC statement, there were no problems.
So does anyone know how to detect this problem from the JDBC client?
TIA!

I discovered that using PreparedStatement rather than Statement gets sproc compilation warnings raised as SQLExceptions.

Related

How do I get the exact Sybase ASE version using JDBC?

It turned out, that the SQL syntax for creating a trigger has changed between ASE 15.7 and 16.0. While in the former
CREATE TRIGGER ...
must be used, the later await
CREATE OR REPLACE TRIGGER ...
must be used.
I know, on SQL it's SELECT ##version or using sp_version, but with JDBC?
Running select##version through a JDBC connection should work and yield the same information as returned through isql.
Sample Code from SAP/Sybase documentation.

MobileFirst SQL adapter raising an error

Sometimes we are receiving following error while calling sql adapter
ORA-06508: PL/SQL: could not find program unit being called.
All objects are valid /compiled and available in oracle DB.
If we change any package or procedure on oracle database we receive that error. So the question is: Do we need to re-deploy that SQL adapter which calls that database object again?
It happens because your connection is holding on to a pointer to a procedure that no longer exists in RAM because it was recompiled.
I have seen this for many years and you can recreate this on the fly.
Call an Oracle Procedure
Recompile that procedure
Call it again you will get "could not find program unit being called."
Call it again and it will work.
If you closed the connection after #2 and then opened the connection and called the procedure you would never get that error.
After you make the call to that proc and you are done, close out your connection before calling it again.

view sql generated by WSO2 DSS service

We have a very large SQL statement in our WSO2 DSS service which is executing a query against an Oracle database. With some parameters the query works. With others it fails and the Oracle error indicates there is a missing right ")" in the SQL statement. How can we see the actual SQL being sent to Oracle when the DSS executes. We've tried enabling DEBUG on any relevant looking logger and no luck.
You need to turn debug level in you DSS/Configure/Logging for
org.wso2.carbon.dataservices.core.description.query.SQLQuery
Then in Monitor/System Logs - you can see queries that was called and it's exceptions.
You can use log4jdbc to log every jdbc query that goes from DSS to Oracle. Here is a tutorial you can follow.

How do I set the SDE version in SSIS dataflow source

I have a GIS oracle database and I am needing to reference in a SSIS dataflow task. Ideally I would normally do something like this (which works perfectly in Oracle SQL Developer):
execute sde.version_util.set_current_version('SAFE.mvedits')
SELECT CAD_EVENTID
FROM SAFE.INCIDENT_POINT_MV
however when I try to use that as the SQL command of my OLE DB Datasource it throws me an "Invalid SQL" error.
How do I set the SDE version in a SSIS dataflow task data source?
Knowing nothing of nothing on Oracle, what you might try is
In your Oracle Connection Manager, change the property RetainSameConnection to True. This means that all connections will Oracle will use the same thread.
Add an Execute SQL Task before your Data Flow that talks to Oracle. Use your query there to modify the current version thing. This setting should be persisted on the connection.
In your OLE DB Datasource, start with the SELECT statement.
You might need to set DelayValidation to true as well.
If that's not working, let me know and I'll see if I can come up with anything else.
As it turns out this is a shortfall of interacting with GIS Oracle databases through thirdparty applications. In my situation we addressed it by just bundling the change up in a stored procedure that lives on the oracle server and invoking that stored procedure from inside SSIS.

How to convert Sybase error message offset to a Stored Procedure line number

I am trying to debug a long stored procedure in Sybase and I get an error message like:
Number (257) Severity (16) State (1) Server (DZUCRINSI225) Procedure (Calculate_FX_Haircut) Implicit conversion from datatype 'CHAR' to 'NUMERIC' is not allowed. Use the CONVERT function to run this query. (4068EE10)
I don't know where the error is occurring in the SP. How can I locate it? I guess that the '4068EE10' in the message may be an offset, but I don't know how to make use of it to find the line number. Can anyone help?
I should add that I am using Embarcadero Rapid SQL as an interface to the Sybase server. I'm not certain whether the '4068EE10' is added by Sybase or Embarcadero.
I haven't used Rapid Sql for a long while, but Open Client, the Sybase client interface, definitely has messages to the client that contain the line number when the SQL failing is an SP. Perhaps Rapid SQL is unsing an ODBC connection and the middleware discards Sybase specific things in server message handling?
Can you change your datasource to use a native Sybase connection - I'd expect Rapid Sql to be able to manage?
Why don't you try running this SP in the Sybase sql client isql?
You'll find you get a message that includes the SP name and line number.

Resources