Executing a stored procedure containing multiple Select statements
Post Author: Beverly
CA Forum: General
I am using Crystal 10.0 against a MS SQL 2000 server.
I am trying to create a report based on a stored procedure that contains multiple select statements. The sp requires a single parameter (Claim number) and contains 17 Select statements that produce results.
I am able to use the Add command and execute the sp with the parameter, but I am only getting the results of the first select statement in the sp back in my data set. Is there a way to have the data from each Select statement returned to my report?
I have used Crystal for a while, but pretty much for straight-forward reporting. I am familiar with the basics of SQL.
I would appreciate any help anyone can offer.
Thanks.
Post Author: BISoftware
CA Forum: General
I believe Crystal Reports can only handle one recordset at a time, which means it can only handle a single select statement. The only way I can see around this would be to break up your stored procedure into multiple stored procedures, so that each only contains a single select statement. Then, use subreports to report on each individual sp. Hope this helps. - Davewww.BusinessSoftwareResource.com
Similar Messages
-
Can we call a stored procedure in a select statement
Hi All
I want to call a stored procedure inside a select statement is this possible.
Regards
SravzYou can create a pipelined function which gathers the data from your stored procedure and then use that in a select statement or directly write your script in any function or pipelined function. ;)
There is no way you can call any stored procedure in a SELECT statement directly - i guess.
Regards.
Satyaki De. -
Use of a stored procedure in a select statement submitted to cx_oracle
Hi,
I am developping under python and I'm using the cx_oracle interface.
I've written a stored procedure that I've tested directly under sqlplus session : it's ok. I've also tested this stored procedure from python by using callproc routine : its also ok.
Now I need to use this procedure within a select statement that I submit to the execute statement of cx_oracle as :
s = "select a.airport_name,gmlpos.ExpLatLong(a.point_name) from airport"
self.db = oracledb('ops/opeope00@ACE2008B')
dbmsg = self.db.execute(s)
IF (dbmsg == "") :
An error occurs :
Message = request = select a.AIRPORT_NAME, gmlpos.ExpLatLong(a.point_name) from airport, errmsg = ORA-00904: "GMLPOS"."EXPLATLONG": invalid identifier
Noting that the execution of any other select (without stored procedure) order from python works fine.
Is anybody has a solution or workaround ?
thanks a lot for your helpThe result gives what is expected :
AIRP
GMLPOS.EXPLATLONG(A.POINT_NAME)
LFLL
-45.71666666666667 -5.08333333333333
As I said the stored procedure works fine.
Thanks for your expertise
PS : why change the login password until nobody says which machine or database is concerned ? -
Executing a Variable in a Stored Procedure containing an Update Statement
Hi,
I have created a Stored Procedure, it has one input parameter. Inside the Stored Procedure there are 5 other variables are declared, based on the input parameter 4 of these variables are populated.
Fifth variable is a a concatenation of text and some of these variables and creates a dynamic Update Statement. Once it is created I want to execute this variable but it is not executing.
Could someone please help me in knowing how to execute a variable within a stored procedure that contains an update statement.
Thanks for your help.
Thanks
Vineesh
vineesh1701If you have set up the variable so that it contains a valid sql update, it should work. For example, see below, which does do an update
use tempdb
go
Create Table #Test(i int);
Insert #Test(i) Values(1);
go
Create Procedure TestProc As
Begin
Declare @SQL nvarchar(250);
Set @SQL = 'Update #Test Set i = 2';
--Print @SQL;
Exec sp_executesql @SQL;
End
go
Exec TestProc
-- Test Result
Select * From #Test;
go
Drop Procedure TestProc;
go
Drop Table #Test;
One thing I would recommend while testing is that you print out or select the variable that contains the dynamic sql. (Like the above code where I have a print statement. That lets you see exactly what you are executing and if there is any problem
with the update command.
As Naomi said, to get anything more than general help, you will probably have to show us your code and the parameter values you are passing when you execute the stored proc.
Tom -
Multiple Select statements in EXECUTE SQL TASK in SSIS
Can we write multiple select statements in execute sql task(SSIS).
If possible how to assign them to variables in result statementHi ,
You can use below steps to set result set to variable.
1.In the Execute SQL Task Editor dialog box, on the General page, select the Single row, Full result set, or XML result set type(According to your result set).
2.Click Result Set.
3.To add a result set mapping, click Add.
4.From the Variables Name list, select a variable or create a new variable.
What is multiple selection ? May be below can be used in your scenario !
http://stackoverflow.com/questions/17698908/how-to-set-multiple-ssis-variables-in-sql-task
What you want to achieve ?
Thanks
Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com -
How to return the result set of multiple select statements as one result set?
Hi All,
I have multiple select statements in my stored procedure that I want to return as one result set
for instance
select id from tableA
union
select name from table b
but union will not work because the result sets datatypes are not identical so how to go about this ?
ThanksYou have to CAST or CONVERT (or implicitly convert) the columns to the same datatype. You must find a datatype that both columns can be converted to without error. In your example I'm guessing id is an int and name is a varchar or nvarchar.
Since you didn't convert the datatypes, SQL will use its data precedence rules and attempt to convert name to an int. If any row contains a row that has a value in name that cannot be converted to an int, you will get an error. The solution is
to force SQL to convert the int to varchar. So you want something like
select cast(id as varchar(12)) from tableA
union
select name from tableb
If the datatypes are something other that int or varchar, you must find a compatable datatype and then convert one (or both) of the columns to that datatype.
Tom -
Is it possible to execute a stored procedure using the JDBC adapter?
Hi all,
Can anybody confirm whether we can execute a stored procedure created in a database using the processing parameters of a JDBC adapter of a communication channel?
If yes, then please let me know how (may be with an example)
Thanks.Yes, that is possible. You have to chose EXECUTE in the action field to execute the stored procedure. Here's a little piece on the JDBC receiver:
JDBC Receiver
For writing data to an SQL database you also need to define a strict data type. The general format is like this:
<ns:MT_RECORDSET>
<STATEMENT>
<TABLE_NAME ACTION="">
<TABLE/>
<ACCESS>
<FIELD1/>
<FIELD2/>
<FIELDn/>
</ACCESS>
<KEY>
<ID compareOperation=""/>
<FIELDx compareOperation=""/>
</KEY>
</TABLE_NAME>
</STATEMENT>
</ns:MT_RECORDSET>
This recordset represents an SQL statement like "update TABLE1 set FIELD1=123, FIELD2=456, FIELDn='xyz' where ID=12345 and FIELDx is NULL"
MT_RECORDSET is the name of the Message Type used.
For the value of the attribute ACTION you can choose from the following values:
UPDATE : updates the given fields in the table with their new values
INSERT : insert the given fields as a new row in the table
UPDATE_INSERT : insert rows in the table when update is not possible
DELETE : deletes given fields from the table
SELECT : selects given fields from the table. Note that this option returns a response in the JDBC Sender form!
EXECUTE : execution of a stored SQL procedure
SQL_QUERY | SQL_DML : option to transfer more complex SQL statements to the database
The attribute compareOperation can have the following values:
EQ : equal
NEQ : not equal
LT : less than
LTEQ : less than or equal to
GT : greater than
GTEQ : greater than or equal to
LIKE : used to compare strings -
How can i retrieve the output of procedure using a select statement ?
Hi every one.
this mite be dumm ?
how can i use the output of the a procedure containing multiple rows of data in a select statement ?This is not a SQL Developer question. You should ask it in the SQL and PL/SQL forum.
The short answer is you can't. Sounds is if you are trying to use MSSQL techniques in oracle. Learn oracle techniques -
Execute oracle stored procedure in CF8
I am executing a stored procedure like this.
<cfstoredproc procedure="GetAction"
datasource="test_DSN">
<cfprocparam cfsqltype="CF_SQL_INTEGER"
dbvarname="actionId" type="in" value="1">
<cfprocresult name="actions" resultset="1" >
</cfstoredproc>
and my stored procedure in oracle is,
create or replace function GetAction(actionId IN
ACTION.ID%TYPE)
RETURN ACTION%ROWTYPE
IS
actions
ACTION%ROWTYPE;
begin
select *
INTO actions
FROM ACTION WHERE ID = actionId;
RETURN actions;
end GetAction;
then I get the error message like,
ORA-01008: not all variables bound
Please help me on this.
ThanxIf you want to return a result set (result of a query) from
your PL/SQL, you will have to do what Daverms suggested and convert
your function to a procedure
and use a reference cursor to return your result set. Your
procedure will have to be contained in a package in order for you
to declare a ref cursor "globally" so that it can be accessed by
CF.
Oh, and be sure to change your cfstoredproc procedure
parameter to add the package name to the proc name.
<cfstoredproc procedure="your_pkg.GetAction"
datasource="test_DSN">
Phil -
Executing the stored procedure with output which is a collection of objects
Hello,
I have the objects and collection of objects within an objects as below:
CREATE OR REPLACE TYPE SHARE_OUTST_T
AS OBJECT
SHR_OUTST_AMT number
CREATE OR REPLACE TYPE SECURITY_T
AS OBJECT
VOTE_PER_SHR number
, CUSIP varchar2(12)
, EXCHANGE varchar2(10)
, IV_TYPE_CD varchar2(10)
, SEC_TICKER_SYMB varchar2(20)
CREATE OR REPLACE TYPE ALTERNATE_ID_T
AS OBJECT
( ALT_ID_TYPE varchar2(20)
CREATE OR REPLACE TYPE ISSUE_MAINT_VERSION_T
AS OBJECT
IM_KEY_ID number
, IM_VER_NUM number
, EFF_TMSTMP timestamp
, EXP_TMSTMP timestamp
, NEXT_REVIEW_TMSTMP timestamp
, APPR_STATUS_REF_ID number
, VOTE number
, ADD_USR_ID varchar2(20)
, ADD_TMSTMP timestamp
, UPD_USR_ID varchar2(20)
, UPD_TMSTMP timestamp
, LOCK_LEVEL_NUM number
, ACTION VARCHAR2(1)
CREATE OR REPLACE TYPE ISSUE_SHARE_MAINT_T
AS OBJECT
IM_KEY_ID number
, IM_VER_NUM number
, SHR_OUTST_AMT number
, CURR_OUTST_AMT number
, ADD_USR_ID varchar2(20)
, ADD_TMSTMP timestamp
, UPD_USR_ID varchar2(20)
, UPD_TMSTMP timestamp
, LOCK_LEVEL_NUM number
, ACTION VARCHAR2(1)
CREATE OR REPLACE TYPE ISSUE_MAINT_COMMENT_T
AS OBJECT
IM_KEY_ID number
, IM_VER_NUM number
, COMMENT_TXT varchar2(400)
, ADD_USR_ID varchar2(20)
, ADD_TMSTMP timestamp
, UPD_USR_ID varchar2(20)
, UPD_TMSTMP timestamp
, LOCK_LEVEL_NUM number
, ACTION VARCHAR2(1)
CREATE OR REPLACE TYPE ISSUE_MAINT_COMMENT_COL_T AS TABLE OF ISSUE_MAINT_COMMENT_T;
CREATE OR REPLACE TYPE ISSUE_VERSION_T
AS OBJECT
SHARE_OUTST SHARE_OUTST_T
, SECURITY SECURITY_T
, ALTERNATE_ID ALTERNATE_ID_T
, ISSUER ISSUER_T
, ISSUE_MAINT_VERSION ISSUE_MAINT_VERSION_T
, ISSUE_SHARE_MAINT ISSUE_SHARE_MAINT_T
, ISSUE_MAINT_COMMENT_COL ISSUE_MAINT_COMMENT_T
CREATE OR REPLACE TYPE ISSUE_VERSION_COL_T AS TABLE OF ISSUE_VERSION_T;
And the stored procedure as :
=======================================
PROCEDURE get_all_issue_version_col
( pv_issue_version_col OUT issue_version_col_t
AS
CURSOR cur_issue_version
IS
SELECT
issue_version_t (
SHARE_OUTST_T (so.shr_outst_amt )
, SECURITY_T ( s.vote_per_shr
, s.sec_cusip
, s.PRI_MKT_EXCH_CD
, s.IV_TYPE_CD
, s.SEC_TICKER_SYMB )
, ALTERNATE_ID_T (a.ALT_ID_TYPE)
, ISSUER_T (i.ISSR_ID )
, ISSUE_MAINT_VERSION_T (imv.im_key_id
, imv.im_ver_num
, imv.eff_tmstmp
, imv.exp_tmstmp
, imv.next_review_tmstmp
, imv.appr_status_ref_id
, imv.vote
, imv.add_usr_id
, imv.add_tmstmp
, imv.upd_usr_id
, imv.upd_tmstmp
, imv.lock_level_num
, NULL )
, ISSUE_SHARE_MAINT_T (ism.im_key_id
, ism.im_ver_num
, ism.shr_outst_amt
, ism.curr_outst_amt
, ism.add_usr_id
, ism.add_tmstmp
, ism.upd_usr_id
, ism.upd_tmstmp
, ism.lock_level_num
, NULL)
, ISSUE_MAINT_COMMENT_T(imc.im_key_id
, imc.im_ver_num
, imc.comment_txt
, imc.add_usr_id
, imc.add_tmstmp
, imc.upd_usr_id
, imc.upd_tmstmp
, imc.lock_level_num
, NULL )
FROM
share_outst so
, security s
, alternate_id a
, issuer i
, issue_maintenance_version imv
, issue_share_maintenance ism
, issue_maintenance_comment imc
WHERE
s.sec_key_id = so.SEC_KEY_ID
and s.SEC_KEY_ID = a.SEC_KEY_ID
and s.MSTR_ISSR_KEY_ID = i.ISSR_KEY_ID
and s.SEC_CUSIP = imv.SEC_CUSIP (+)
and s.SEC_CUSIP = ism.SEC_CUSIP (+)
and imv.IM_KEY_ID = imc.IM_KEY_ID (+);
BEGIN
OPEN cur_issue_version ;
FETCH cur_issue_version BULK COLLECT INTO pv_issue_version_col ;
CLOSE cur_issue_version ;
END ;
PROCEDURE get_all_issue_col_v1
( pv_issue_version_col OUT NOCOPY issue_version_col_t
, pv_row_count IN number
, pv_issuer_id IN VARCHAR2
AS
CURSOR cur_issue_version
IS
SELECT
issue_version_t (
SHARE_OUTST_T (so.shr_outst_amt )
, SECURITY_T ( s.vote_per_shr
, s.sec_cusip
, s.PRI_MKT_EXCH_CD
, s.IV_TYPE_CD
, s.SEC_TICKER_SYMB )
, ALTERNATE_ID_T (a.ALT_ID_TYPE)
, ISSUER_T (i.ISSR_ID )
, ISSUE_MAINT_VERSION_T (imv.im_key_id
, imv.im_ver_num
, imv.eff_tmstmp
, imv.exp_tmstmp
, imv.next_review_tmstmp
, imv.appr_status_ref_id
, imv.vote
, imv.add_usr_id
, imv.add_tmstmp
, imv.upd_usr_id
, imv.upd_tmstmp
, imv.lock_level_num
, NULL )
, ISSUE_SHARE_MAINT_T (ism.im_key_id
, ism.im_ver_num
, ism.shr_outst_amt
, ism.curr_outst_amt
, ism.add_usr_id
, ism.add_tmstmp
, ism.upd_usr_id
, ism.upd_tmstmp
, ism.lock_level_num
, NULL)
, ISSUE_MAINT_COMMENT_T(imc.im_key_id
, imc.im_ver_num
, imc.comment_txt
, imc.add_usr_id
, imc.add_tmstmp
, imc.upd_usr_id
, imc.upd_tmstmp
, imc.lock_level_num
, NULL )
FROM
share_outst so
, security s
, alternate_id a
, issuer i
, issue_maintenance_version imv
, issue_share_maintenance ism
, issue_maintenance_comment imc
WHERE
s.sec_key_id = so.SEC_KEY_ID
and s.SEC_KEY_ID = a.SEC_KEY_ID
and s.MSTR_ISSR_KEY_ID = i.ISSR_KEY_ID
and s.SEC_CUSIP = imv.SEC_CUSIP (+)
and s.SEC_CUSIP = ism.SEC_CUSIP (+)
and imv.IM_KEY_ID = imc.IM_KEY_ID (+);
BEGIN
OPEN cur_issue_version ;
FETCH cur_issue_version BULK COLLECT INTO pv_issue_version_col ;
CLOSE cur_issue_version ;
END ;
====================
When I execute this stored procedure thru rapid sql, I get error
Error: ORA-06550: line 1, column 21:
PLS-00306: wrong number or types of arguments in call to 'GET_ALL_ISSUE_VERSION_COL'
ORA-06550: line 1, column 21:
PL/SQL: Statement ignored, Batch 1 Line 1 Col 21
What is that I am missing?
Any help would be greatly appreciated.I've never tried Rapid SQL, but my guess is that you can't pass objects through it. I'd write a test case on the server and try it there. It looks like it should work but I didn't build a test case. If it works on the server but not in the tool, it's like the tool. OCI8 doesn't support passing instantiated objects.
-
Execute oracle stored procedure from C# always returns null
Hi,
I'm trying to execute a stored procedure on oracle 9i. I'm using .Net OracleClient provider.
Apparently, I can execute the stored procedure, but it always returns null as a result (actually all the sp's I have there returns null)! I can execute any text statement against the database successfully, and also I can execute the stored procedure using Toad.
This is not the first time for me to call an oracle stored procedure, but this really is giving me a hard time! Can anyone help please?
Below are the SP, and the code used from .Net to call it, if that can help.
Oracle SP:
CREATE OR REPLACE PROCEDURE APIECARE.CHECK_EXISTENCE(l_number IN NUMBER) AS
v_status VARCHAR2(5) := NULL;
BEGIN
BEGIN
SELECT CHECK_NO_EXISTENCE(to_char(l_number))
INTO v_status
FROM DUAL;
EXCEPTION WHEN OTHERS THEN
v_status := NULL;
END;
DBMS_OUTPUT.PUT_LINE(v_status);
END CHECK_CONTRNO_EXISTENCE;
C# Code:
string connStr = "Data Source=datasource;Persist Security Info=True;User ID=user;Password=pass;Unicode=True";
OracleConnection conn = new OracleConnection(connStr);
OracleParameter param1 = new OracleParameter();
param1.ParameterName = "v_status";
param1.OracleType = OracleType.VarChar;
param1.Size = 5;
param1.Direction = ParameterDirection.Input;
OracleParameter param2 = new OracleParameter();
param2.ParameterName = "l_number";
param2.OracleType = OracleType.Number;
param2.Direction = ParameterDirection.Input;
param2.Value = 006550249;
OracleParameter[] oraParams = new OracleParameter[] { param1, param2 };
OracleCommand cmd = new OracleCommand("CHECK_EXISTENCE", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddRange(oraParams);
conn.Open();
object result = cmd.ExecuteScalar();
conn.Close();Hi,
Does that actually execute? You're passing two parameters to a procedure that only takews 1 and get no error?
Your stored procedure doesnt return anything and has no output parameters, what are you expecting to be returned exactly?
If you're trying to access V_STATUS you'll need to declare that as either an output parameter of the procedure, or return value of the function, and also access it via accessing Param.Value, not as the result of ExecuteScalar.
See if this helps.
Cheers,
Greg
create or replace function myfunc(myinvar in varchar2, myoutvar out varchar2) return varchar2
is
retval varchar2(50);
begin
myoutvar := myinvar;
retval := 'the return value';
return retval;
end;
using System;
using System.Data;
using Oracle.DataAccess.Client;
public class odpfuncparams
public static void Main()
OracleConnection con = new OracleConnection("user id=scott;password=tiger;data source=orcl");
con.Open();
OracleCommand cmd = new OracleCommand("myfunc", con);
cmd.CommandType = CommandType.StoredProcedure;
OracleParameter retval = new OracleParameter("retval",OracleDbType.Varchar2,50);
retval.Direction = ParameterDirection.ReturnValue;
cmd.Parameters.Add(retval);
OracleParameter inval = new OracleParameter("inval",OracleDbType.Varchar2);
inval.Direction = ParameterDirection.Input;
inval.Value="hello world";
cmd.Parameters.Add(inval);
OracleParameter outval = new OracleParameter("outval",OracleDbType.Varchar2,50);
outval.Direction = ParameterDirection.Output;
cmd.Parameters.Add(outval);
cmd.ExecuteNonQuery();
Console.WriteLine("return value is {0}, out value is {1}",retval.Value,outval.Value);
con.Close();
} -
Stored Procedures for Simple SQL statements
Hi Guys,
We are using Oracle 10g database and Web logic for frontend.
The Product is previously developed in DotNet and SQL Server and now its going to develop into Java (Web Logic) and Oracle 10g database.
Since the project is developed in SQL Server, there are lot many procedures written for simple sql queries. Now I would like to gather your suggestions / pointers on using procedures for simple select statements or Inserts from Java.
I have gathered some list for using PL/SQL procedure for simple select queries like
Cons
If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)
Simple select statements are much faster than executing them from Procedure
Pros
Code changes for modifying select query in PL/SQL much easier than in Java
Your help in this regard is more valuable. Please post your points / thoughts here.
Thanks & Regards
Srinivas
Edited by: Srinivas_Reddy on Dec 1, 2009 4:52 PMSrinivas_Reddy wrote:
Cons
If we use procedures for select statements there are lot many Ref Cursors opened for Simple select statements (Open cursors at huge rate)No entirely correct. All SQLs that hit the SQL engine are stored as cursors.
On the client side, you have an interface that deals with this SQL cursor. It can be a Java class, a Delphi dataset, or a PL/SQL refcursor.
Yes, cursors are created/opened at a huge rate by the SQL engine. But is is capable of doing that. What you need to do to facilitate that is send it SQLs that uses bind variables. This enables the SQL engine to simply re-use the existing cursor for that SQL.
Simple select statements are much faster than executing them from ProcedureAlso not really correct. SQL performance is SQL performance. It has nothing to do with how you create the SQL on the client side and what client interface you use. The SQL engine does not care whether you use a PL/SQL ref cursor or a Java class as your client interface. That does not change the SQL engine's performance.
Yes, this can change the performance on the client side. But that is entirely in the hands of the developer and how the developer selected to use the available client interfaces to interface with the SQL cursor in the SQL engine.
Pros
Code changes for modifying select query in PL/SQL much easier than in JavaThis is not a pro merely for ref cursors, but using PL/SQL as the abstraction layer for the data model implemented, and having it provide a "business function" interface to clients, instead of having the clients dealing with the complexities of the data model and SQL.
I would seriously consider ref cursors in your environment. With PL/SQL servicing as the interface, there is a single place to tune SQL, and a single place to update SQL. It allows one to make data model changes without changing or even recompiling the client. It allows one to add new business logical and processing rules, again without having to touch the client. -
Execute a stored procedure on a database
Hi,
I want to execute a stored procedure on an oracle database. Therefore I use the open SQL step configured as follows:
- option "statement requires parameters" is checked
- on the advanced tab: Command Type = Stored Procedure
After this step I use the Data Operation step with operation = Execute. Now, how can I set values for the parameters?
Has anyone an example where I can see how the needed steps have to be configured?
Thanks in advance
Best regards
SteffenHi Steffen,
Your sequence should have the following steps:
1) Open Database
2) Open SQL Statement
3) Data Operation
4) Close SQL Statement
5) Close Database
I am using a very basic stored procedure that doesn't really do anything:
CREATE PROCEDURE MySP @myInput int AS SELECT * FROM myTable GO
For step 2, your SQL Statement field should be the name of the stored procedure. In my example, it would simply by "MySP". Make sure you have the "Statement has parameters" field is checked.
For step 3, select "Execute" as the Operation. Under the Column/Parameter field, you can insert all of your parameters. In my case, I just have one parameter. I can refer to it by index (1) or name ("myInput").
Hope this helps!
Allen P.
NI -
Error while executing the stored procedure through sender JDBC adapter
Hi All,
I am getting below error while executing the stored procedure through sender JDBC adapter.
Database-level error reported by JDBC driver while executing statement 'exec SapgetNextEntity 'SalesOrder''. The JDBC driver returned the following error message: 'com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.'. For details, contact your database server vendor.
what is the problem? any idea to anyone...
regards
Rameshhi Dharamveer,
I am not getting below statement for your reply
Try to use Refrence Cursor it will return u reference of resultset.
I mention SP like this
exec SapgetNextEntity 'SalesOrder'
SapgetNextEntity -
> SP Name
SalesOrder----
> Parameter I am passing...
regards
Ramesh -
Strange error while executing a stored procedure: Incorrect syntax near '@p0'
All, I am getting a strange error while executing a stored procedure: Incorrect syntax near '@p0' using JDBC CallableStatment.
Here is my code...
CallableStatement cStmt = con.prepareCall("{call SET CHAINED ON EXEC <dbName>.<schemaName>.<SPName> (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)}");
cStmt.setString(1, "2012005881");
cStmt.setString(2, "07");
cStmt.setString(3, "10");
cStmt.setString(4, "Case title");
cStmt.setString(5, "Open");
java.sql.Date dt1 = new java.sql.Date(2014,10,20);
cStmt.setDate(6, dt1);
cStmt.setString(7, "01");
cStmt.setString(8, "N");
cStmt.setString(9, "ADA Test");
cStmt.setString(10, "N");
cStmt.setString(11, "English");
cStmt.setString(12, "N");
cStmt.setString(13, "N");
cStmt.setString(14, "N");
cStmt.setString(15, "N");
cStmt.setString(16, "N");
cStmt.setString(17, "N");
cStmt.setString(18, "07");
cStmt.setString(19, "10");
cStmt.setString(20, "juache0");
java.sql.Date dt2 = new java.sql.Date(2014,10,20);
java.sql.Date dt3 = new java.sql.Date(2014,10,20);
cStmt.setDate(21, dt2);
cStmt.setDate(22, dt3);
cStmt.setString(23, "userid0");
cStmt.setString(24, "");
cStmt.setString(25, "");
cStmt.setString(26, "");
java.math.BigDecimal bg1 = new java.math.BigDecimal(10);
cStmt.setBigDecimal(27, bg1);
cStmt.setString(28, "userid");
cStmt.setString(29, "userid");
int hadResults = cStmt.executeUpdate();
Your help is greatly appreciated.
I am executing the above using Jconnect3.0 driver, inside WebSphere Application Server V8.0
Thanks
NagsNOTE: I don't work with JDBC/jConnect so (at this point) just some questions ...
1 - are you sending this to ASE, ASA, IQ, or some other RDBMS?
2 - what is the value of <schemaname>?
3 - do you have other prepareCall() instances that successfully call a stored proc? [would be interesting to see if there's a difference in the format of the calls]
A quick google search shows a couple ways to submit a stored proc execution to the RDBMS, with the format depending on the format expected by the target RDBMS.
I'm wondering if you really need/want the parentheses around the argument list, ie, what happens if you change
from
-- parentheses around args
EXEC <dbName>.<schemaName>.<SPName> ( ?,?,?,?,?,...,? )
to
-- no parentheses around args
EXEC <dbName>.<schemaName>.<SPName> ?,?,?,?,?,...,?
In ASE if I wrap the parameters in parentheses I get the same error you're getting:
================== w/ parentheses => error
1> sp_who (sa)
2> go
Msg 102, Level 15, State 1:
Server 'CC1_V1', Line 1:
Incorrect syntax near 'sa'. <<=== sa == @p0 ??
================== w/out parentheses => works
1> sp_who sa
2> go
fid spid status loginame origname ...
0 17 running sa sa ...
==================
Maybe you are looking for
-
I have never used a mac and would like to know how to delete web sites form my tool bar.
-
Material is there in the BOM still no reservation.
Hi , I have created planned order. According to planned order material is there in the BOM. Still no reservation happened. Can you please tell me what all the possible reasons for this? Regards, Amit
-
MGP Tuning: MGP Processing taking too long
Hi All, I have question here related to MGP Processing. MGP Processing is taking too long for us, close to 900 secs. Is there a way to tune and optimize this MGP Process. Right now we have only 3 users syncing and this kind of delay in Sync for users
-
Not able to print double sided or into the mailbox of our "Canon Image Press C1" anymore
Maybe someone can help me. Yesterday I noticed, that I am not able to print double sided or into the mailbox of our "Canon Image Press C1" anymore (InDesign Version 6.0.4). At the end of january I printed double sided the last time and it worked. Rig
-
ManageCustomerIn Webservice - Update Customer with additional attachments
I am attempting to use the webservices to maintain an account and update the account with attachments. Since users will be interacting with the UI and adding attachments, we only want to add new attachments to the list that is already there. When i a