Nested Stored procedure
Hi experts,
case :- A stored procedure calling 5 stored procedure in 3rd procedure a error handled in execption
is the 3rd procedure resume next?
the 4 & 5 procedure will execute or not?
Many thanks
Kalinga
Hi experts,
case :- A stored procedure calling 5 stored procedure
in 3rd procedure a error handled in execption
is the 3rd procedure resume next?
the 4 & 5 procedure will execute or not?
Many thanks
KalingaSo you have 1 procedure that calls 5 others.
In the 3rd procudure an exception happens, which you capture within that procedure and handle it.
Assuming the 3rd procedure exception handler is at the top level for that procedure, it will cease execution and drop back out and then the 4th and 5th procedures will continue to be executed.
If the exception handler in the 3rd procedure is in a nested execution block then the execution will continue from after that execution block in that 3rd procedure.
If the 3rd procedure doesn't actually handle the exception but raises the error then the exception handler of the calling procedure will capture the exception (if there is an exception handler there) and the 4th and 5th procedures will not be called.
The key thing to remember is that once an exception happens inside an execution block the execution point cannot return back within that same execution block automatically. It can only leave that execution block gracefully by handling the exception or it can raise the exception up a level to the calling execution block's exception handler.
Similar Messages
-
Consider a situation where a stored procedure taking a varbinary(max) (BLOB) input parameter
then calls a nested stored procedure and passes along that varbinary(max) as an input parameter to the nested stored procedure.
Is a copy of the BLOB provided to the nested stored procedure (passed by value) OR is the BLOB passed by reference.
My interest is in understanding the potential memory hit when handling large BLOBs in this environment.
For example, if the BLOB is 200MB, will SQL server need to allocate memory for a new copy each time it's passed to another stored procedure at the next nestlevel?
Looks like table type parameters are passed by reference, but I haven't been able to find any info on BLOBS in this context.The semantics for parameters in SQL Server is copy-in/copy-out. However, this does not mean that there cannot be optimizations. That is, there is no need to copy the BLOB, as long as the procedure does not change it. Whether they actually have such an optimization,
I don't know.
I composed the repro below, and it is sort of interesting. If I restart my instance (SQL 2014), the memory usage grows with about 40 M for each nesting call, which certainly indicates that the BLOB is copied over and over again. But if I then run it again,
the growth is not the same. This may be because, it uses buffers already available. (A BLOB has to be a handle like a table when it is over some size.) Then again, it means that it is squeezing something else out of the cache.
CREATE PROCEDURE K @h varchar(MAX) AS
SELECT SUM(pages_kb)*8192 AS K, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
SELECT @h = ''
go
CREATE PROCEDURE L @h varchar(MAX) AS
SELECT SUM(pages_kb)*8192 AS L1, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
EXEC K @h
SELECT SUM(pages_kb)*8192 AS L2, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
--SELECT @h = ''
go
CREATE PROCEDURE M @h varchar(MAX) AS
SELECT SUM(pages_kb)*8192 AS M1, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
EXEC L @h
SELECT SUM(pages_kb)*8192 AS M2, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
--SELECT @h = ''
go
CREATE PROCEDURE N @h varchar(MAX) AS
SELECT SUM(pages_kb)*8192 AS N1, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
EXEC M @h
SELECT SUM(pages_kb)*8192 AS N2, datalength(@h) as Dlen FROM sys.dm_os_memory_clerks
--SELECT @h = ''
go
DECLARE @h varchar(MAX) = replicate(cast('ABCD' AS varchar(MAX)), 1E7)
EXEC N @h
go
DROP PROCEDURE K, L, M, N
Erland Sommarskog, SQL Server MVP, [email protected] -
Problem in calling nested stored procedure
Hi,
I am using execute(), getMoreResults() and getResultSet() methods to call sybase stored proc. It is working fine when calling a simple stored proc. But it is giving following error when this stored proc calls another stored proc inside it.
<<
Error connecting: com.sybase.jdbc2.jdbc.SybSQLException: Implicit conversion from datatype 'INT' to 'CHAR' is not allowed. Use the CONVERT function to run this query
>>
It will be very helpful if somebody shares the experience of nested stored procs calls using JDBC.
-SubhenduVinay,
Thanks for replying...
Following is the excerpts from the parent procedure
create proc TEST_PARENT_sp
(@fundID char(5) = NULL)
as
begin
exec TEST_CHILD_sp @fundID
end
The code for CHILD proc is attached
create procedure TEST_CHILD_sp
(@fundID char(5) = NULL)
as
begin
insert #PV_funds_curr
(fundID,
curr_id,
curr_type,
tcurr_id,
in_xrate_id,
out_xrate_id,
display_seq)
select
pv.fund_id,
rl.curr_id,
rl.curr_type,
rl.curr_id,
null,
null,
pv.display_seq
from
#PV_funds pv,
RL_currencies rl,
#PV_currencies tmp_c
where
@fundID in (pv.fund_id, 'ALL') and
pv.fund_id = rl.fund_id and
tmp_c.curr_id in (rl.curr_id, 'ALL') and
tmp_c.curr_type in (rl.curr_type, 'ALL')
end
Regards,
Subhendu.
PS.- The Parent Stored proc works fine while calling from other applications,e.g., Rapid SQL, isql. -
Java and Sybase nested stored procedures.
Hi!
I have nested Sybase stored procedures, the main procedure calls a helper stored proc.
The main procedure returns 2 result sets before calling the helper store proc and helper store proc returns 1 resultset. After the helper store proc is called, the main store proc returns 2 more resultset. When I run it using SQL client tool the main procedure(and it's helper) execute well and returns rows.
I need to call this store proc in a java code and display all the resultset in screen. I am using Statement:execute(<exec sp>) to execute the store proc and then statement.getResultSet() to get each resultset. The loop is controlled by statement.getMoreResults() .
It displays the first 2 resultsets from main Store Proc. Then the control goes to helper store proc. It executes the helper store proc and displays the resultset from helper. But then it stops there and doesnot
come back to main store proc to execute the remaining resultset.
What I suspect is that, the statement object is getting overlaid when the call goes to helper proc.
Any idea as to how to code to handle multiple nested resultset ?
~ RNS.
My Sybase stored procedure code looks like -
=======================================================================
create procedure main_proc
@param1 int
as
select getdate()
select @@servername
declare @return_val int
exec proc2 @param1, @return_val out
select myCol1,
myCol2,
myCol3=@return_val
from mytable
select db_name()
===========================================================================
Sybase Code for proc2
create procedure proc2
@param1 int,
@param2 int out
as
begin
if something exists(select * from table where whereClause)
select @param2="TRUE"
else
select @param2="FALSE"
select getdate()
end
go
GRANT EXECUTE...
EXEC sp_procxmode 'dbo.proc2,'unchained'
go
====================================================================
Code snippet :-
do {
int iit=0;
rs=stmt.getResultSet();
if ( rs != null ) {
ResultSetMetaData rsd = rs.getMetaData();
int nocols = rsd.getColumnCount();
for (int i=1; i<=nocols; i++)
System.out.println(rsd.getColumnName(i)));
while (rs.next())
for (int i=1; i<=nocols; i++)
System.out.println(rs.getString(rsd.getColumnName(i));
} while (stmt.getMoreResults());I'm not 100% sure about this, but my guess is that this is caused by the TDS protocol (used by Sybase). TDS makes no difference between the stored procedure you are calling and the "inner" stored procedure, so the driver just returns update counts and result sets as they are generated, regardless of who generated them.
Another guess (as I don't know what driver you are using) is that execute() returns the first result (update count or ResultSet), as opposed to executeQuery(), which returns the first ResultSet (probably discarding the update count). You can make sure of this by calling getMoreResults(); you should get your ResultSet at some point.
Alin. -
Stored procedure call returns null result set when using temp table in sp!
Here's a really odd problem...
SQL Server stored procedure called sp_Test takes 1 input INT. Here is the code I call it with
cStmt = connection.prepareCall("{call sp_Test(?)}");
cStmt.setInt(1, 44);
cStmt.execute();
rs = cStmt.getResultSet();When the body of the stored proc is
CREATE PROCEDURE sp_Test(@i_NodeID INT)
AS
BEGIN
SELECT node_id FROM tbl_NavTree
END
GOthe query works and I get all node_id back in rs
BUT when the body of the stored proc is
CREATE PROCEDURE sp_Test(@i_NodeID INT)
AS
BEGIN
CREATE TABLE #Descendants(
descendant_id INT
SELECT node_id FROM tbl_NavTree
DROP TABLE #Descendants
END
GOThe rs comes back as NULL. Really really weird if you ask me. I also tried removing the DROP TABLE line just in case the SELECT had to be the last statement but still NULL.
Final note is that BOTH the above stored proc bodies work when executed within SQL Server query analyser.
Must be JDBC .. what can it be!??DROP TABLE #DescendantsMS SQL Server - right?
Then don't drop the table.
From the MS docs for "create table"
Local temporary tables are visible only in the current session;
A local temporary table created in a stored procedure is dropped automatically when the stored procedure completes. The table can be referenced by any nested stored procedures executed by the stored procedure that created the table. The table cannot be referenced by the process which called the stored procedure that created the table. -
Stored Procedure in Universe - Multi-result set
I have been trying to get more information on stored procedures as a source for universes. Business Objects designer 3.1 documentation says the following
Stored procedures with multi-result set
Example: A stored procedure that returns more than one result set. At design
time, several tables are created in the universe structure based on the same
stored procedure.
Does this mean?
1. These result sets are shown as multiple tables in designer?
2. if so, can these result sets be used as regular tables in designer to build joins and contexts.
I searched the forum for relevant threads before posting but could not find any. I tried posting this thread earlier - internet connection timed out. Please forgive me if this is a duplicate post.
ThanksDROP TABLE #DescendantsMS SQL Server - right?
Then don't drop the table.
From the MS docs for "create table"
Local temporary tables are visible only in the current session;
A local temporary table created in a stored procedure is dropped automatically when the stored procedure completes. The table can be referenced by any nested stored procedures executed by the stored procedure that created the table. The table cannot be referenced by the process which called the stored procedure that created the table. -
Java call stored procedure with nested table type parameter?
Hi experts!
I need to call stored procedure that contains nested table type parameter, but I don't know how to handle it.
The following is my pl/sql code:
create or replace package test_package as
type row_abc is record(
col1 varchar2(16),
col2 varchar2(16),
col3 varchar2(16 )
type matrix_abc is table of row_abc index by binary_integer;
PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
p_arg2 IN VARCHAR2,
p_arg3 IN VARCHAR2,
p_out OUT matrix_abc
END test_package;
create or replace package body test_package as
PROCEDURE test_matrix(p_arg1 IN VARCHAR2,
p_arg2 IN VARCHAR2,
p_arg3 IN VARCHAR2,
p_out OUT matrix_abc
IS
v_sn NUMBER(8):=0 ;
BEGIN
LOOP
EXIT WHEN v_sn>5 ;
v_sn := v_sn + 1;
p_out(v_sn).col1 := 'col1_'||to_char(v_sn)|| p_arg1 ;
p_out(v_sn).col2 := 'col2_'||to_char(v_sn)||p_arg2 ;
p_out(v_sn).col3 := 'col3_'||to_char(v_sn)||p_arg3 ;
END LOOP ;
END ;
END test_package ;
My java code is following, it doesn't work:
Class.forName ("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection
("jdbc:oracle:thin:@10.16.102.176:1540:dev", "scott", "tiger");
con.setAutoCommit(false);
CallableStatement ps = null;
String sql = " begin test_package.test_matrix( ?, ? , ? , ? ); end ; ";
ps = con.prepareCall(sql);
ps.setString(1,"p1");
ps.setString(2,"p2");
ps.setString(3,"p3");
ps.registerOutParameter(4,OracleTypes.CURSOR);
ps.execute();
ResultSet rset = (ResultSet) ps.getObject(1);
error message :
PLS-00306: wrong number or types of arguments in call to 'TEST_MATRIX'
ORA-06550: line 1, column 8:
PL/SQL: Statement ignored
Regards
LouisLouis,
If I'm not mistaken, record types are not allowed. However, you can use object types instead. However, they must be database types. In other words, something like:
create or replace type ROW_ABC as object (
col1 varchar2(16),
col2 varchar2(16),
col3 varchar2(16 )
create or replace type MATRIX_ABC as table of ROW_ABC
/Then you can use the "ARRAY" and "STRUCT" (SQL) types in your java code. If I remember correctly, I recently answered a similar question either in this forum, or at JavaRanch -- but I'm too lazy to look for it now. Do a search for the terms "ARRAY" and "STRUCT".
For your information, there are also code samples of how to do this on the OTN Web site.
Good Luck,
Avi. -
Cursor with nested query in stored procedure problem
Hello
I'm trying to declare the folowing (example) cursor in a stored procedure in Oracle 8i:
CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
The nested part "(SELECT d.DUMMY FROM dual)" is not alowed, while the same query runs outside the stored procedure. Can someone explain why this is not alowed and how to solve the problem whitout rewriting the query?
TomWhen i run the same code in SQL plus:
SQL> declare
2 CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
3 begin
4 null;
5 end;
6 /
CURSOR RECORDS IS SELECT d.DUMMY, (SELECT dd.DUMMY FROM dual dd) FROM dual d;
FOUT in regel 2:
.ORA-06550: line 2, column 36:
PLS-00103: Encountered the symbol "SELECT" when expecting one of the following:
( - + mod not null others <an identifier>
<a double-quoted delimited-identifier> <a bind variable> avg
count current exists max min prior sql stddev sum variance
execute forall time timestamp interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string>
ORA-06550: line 2, column 66:
PLS-00103: Encountered the symbol "FROM" when expecting one of the following:
; return returning and or
Different versions of Oracle? -
Stored procedure: nested cursor problem
Hey folks,
i am really having a hard time trying to figure out how nested cursors work.
What i want to do:
-> Do one select statement and process the yielded rows with one cursor
-> Do another select statement depending on the first cursor
The code is quite simple, the beginning of the stored procedure is:
create or replace
PROCEDURE extractEntireMD IS
CURSOR curTemplateUnitId IS
SELECT
tu.externalident,
tu.templateunitid
FROM
templateunit tu
WHERE
tu.templateunitid = 100007;
CURSOR curPartTypeId(templateUnitID IN varchar2) IS
SELECT
tpt.parttypeid
FROM
templateparttype tpt
WHERE
tpt.templateunitid = templateUnitID;
From what i have read, this seems to be right.
No i want to use this code like this:
BEGIN
FOR valInCurTemplateUnitId IN curTemplateUnitId LOOP
DBMS_OUTPUT.PUT_LINE('ExtIdent: ' || valInCurTemplateUnitId.externalident);
DBMS_OUTPUT.PUT_LINE('templateunitid: ' || valInCurTemplateUnitId.templateunitid);
FOR valIncurPartTypeId IN curPartTypeId(valInCurTemplateUnitId.templateunitid) LOOP
DBMS_OUTPUT.PUT_LINE('PartTypeId: ' || valIncurPartTypeId.parttypeid);
END LOOP;
END LOOP;
EXCEPTION
WHEN NO_DATA_FOUND THEN
DBMS_OUTPUT.PUT_LINE('No such data ');
END;
The problem:
I seem to be doing something wrong, because Oracle does not heed the argument which i give to the second cursor from the first cursor:
CURSOR curPartTypeId(templateUnitID IN varchar2) IS
which i call via:
FOR valIncurPartTypeId IN curPartTypeId(valInCurTemplateUnitId.templateunitid)
Instead, oracle prints out __all__ templateunitids.
If I modify the second cursor with a constant argument like this:
CURSOR curPartTypeId(templateUnitID IN varchar2) IS
SELECT DISTINCT
tpt.parttypeid
FROM
templateparttype tpt
WHERE
tpt.templateunitid = 100007;
The result is correct. So it seems like oracle simply disregards the parameter i am giving him for the second cursor.
What am i doing wrong?> i am really having a hard time trying to figure out how nested cursors work.
Good. I trust that this will result in the realisation that it is an idiotic thing to emulate the features of the SQL engine in PL/SQL. Only a fool thinks the he/she can outprogram and outsmart the SQL engine, and do things like nested loop joins better and faster in PL/SQL.
Use SQL for the purpose it was designed. Use PL/SQL for the purpose it was designed.
Joining of data? That is prime function and feature of SQL. Not PL/SQL. -
How to create Nested table in oracle stored procedure(Temp Table)
Hi
I am creating Nested table in stored procedure(Temp Table)
type t_v_tbl_rec is record(cumid number,col1 varchar(50),col2 varchar(50),col3 varchar(50),col4 varchar(50),col5 varchar(50),col6 varchar(50));
type t_v_tbl is table of t_v_tbl_rec index by binary_integer;
V_V_TBL t_v_tbl;
But i can't insert value in to this temp table
Plz help meWhat is problem?
SQL>declare
2 type t_v_tbl_rec is record( cumid number,
3 col1 varchar(50),
4 col2 varchar(50),
5 col3 varchar(50),
6 col4 varchar(50),
7 col5 varchar(50),
8 col6 varchar(50) );
9 type t_v_tbl is table of t_v_tbl_rec index by binary_integer;
10 v_v_tbl t_v_tbl;
11 begin
12 v_v_tbl(1).cumid := 1;
13 dbms_output.put_line(v_v_tbl(1).cumid);
14 end;
15 /
1
PL/SQL procedure successfully completed. -
Get error message from a nested/encrypted stored procedure
Hi,
I have an encrypted procedure, that is used inside my 'own' complex procedure as:
Begin try
Begin tran
Do a lot
insert into #tmp exec xp_encryptedSP
Do a lot more
commit tran
end try
begin catch
print ERROR_MESSAGE()
rollback tran
end catch
Some error occur on the insert into #tmp exec xp_encryptedSP row, and in this case it's correct that the error occur, but:
If I run only exec xp_encryptedSP in query analyzer, I can see the root cause error message,
but in my complex procedure all I get is:
Cannot use the ROLLBACK statement within an INSERT-EXEC statement.
I have tried to enclose the insert into #tmp exec xp_encryptedSP in an own try block, but all I get is the message above.
Please help
/Magnus
Magnus BurkNo, the error message has nothing to do with the fact that the procedure obfuscated. It is a limitation of INSERT-EXEC. A quite silly one, since a consequence of the error is that the transaction is rolled back...
There are better ways to share data between stored procedures, but most of them assumes that you can change the procedure you call, and obviously this is not possible since this is a vendor procedure.
So it looks like you are in for heavy artillery, that is the CLR. See here for an example:
http://www.sommarskog.se/share_data.html#CLR
I should warn you in advance that error handling when the CLR is involved is also a very difficult thing.
Erland Sommarskog, SQL Server MVP, [email protected] -
Nested Try/Catch in a stored procedure going to outer
I am using Service Broker to move data to a historical database and then delete it from the current table in a second stored procedure that gets the information passed to it; which I have working but what I am having trouble with is when there
is an error in the second stored procedure rather than going to the catch in the second Stored procedure it goes back up to my first one.
CREATE PROCEDURE [sp_PkgDelActivator_SB]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
DECLARE @RecvReqDlgHandle UNIQUEIDENTIFIER;
DECLARE @RecvReqMsg XML;
DECLARE @RecvReqMsgName sysname;
BEGIN TRY
WHILE (1=1)
BEGIN
BEGIN TRAN
--Get the top item on the queue.
WAITFOR
( RECEIVE TOP(1)
@RecvReqDlgHandle = conversation_handle,
@RecvReqMsg = message_body,
@RecvReqMsgName = message_type_name
FROM DeleteReceiveQueue
), TIMEOUT 5000;
IF (@@ROWCOUNT = 0)
BEGIN
ROLLBACK TRANSACTION;
BREAK;
END
ELSE
COMMIT TRAN
EXEC sp_PkgDeleteHeap_SB
@RecvReqDlgHandle = @RecvReqDlgHandle,
@RecvReqMsg = @RecvReqMsg
END
END TRY
BEGIN CATCH
DECLARE @ERR_NR INT = ERROR_NUMBER(),
@ERR_SVR_NR TINYINT = ERROR_SEVERITY(),
@ERR_STT_NR TINYINT = ERROR_STATE(),
@ERR_PRC_TE VARCHAR(50) = ERROR_PROCEDURE(),
@ERR_LN_NR INT = ERROR_LINE(),
@ERR_MSG_TE VARCHAR(1000) = ERROR_MESSAGE()
IF @@TRANCOUNT > 0
ROLLBACK TRAN
INSERT INTO DB_ERR_LOG(
ERR_NR,
ERR_SVR_NR,
ERR_STT_NR,
ERR_PRC_TE,
ERR_LN_NR,
ERR_MSG_TE,
LOG_DT)
SELECT
@ERR_NR,
@ERR_SVR_NR,
@ERR_STT_NR,
@ERR_PRC_TE,
@ERR_LN_NR,
@ERR_MSG_TE,
GETDATE()
END CATCH
END
CREATE PROCEDURE [sp_PkgDeleteHeap_SB]
@RecvReqDlgHandle UNIQUEIDENTIFIER,
@RecvReqMsg XML
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
BEGIN TRY
BEGIN TRANSACTION
DECLARE @dtArrival date = 'gotten from somewhere else'
IF @dtArrival BETWEEN '2014-07-01' AND '2014-09-30'
BEGIN
'Code to move and delete rows from a table'
END
ELSE IF @dtArrival BETWEEN '2015-01-01' AND '2015-03-31'
BEGIN
'Code to move and delete rows from a table'
END
ELSE IF @dtArrival BETWEEN '2015-04-01' AND '2015-06-30'
BEGIN
'Code to move and delete rows from a table'
END
END CONVERSATION @RecvReqDlgHandle WITH CLEANUP;
END
COMMIT TRAN
END TRY
BEGIN CATCH
ROLLBACK TRAN
DECLARE @ERR_NR INT = ERROR_NUMBER(),
@ERR_SVR_NR TINYINT = ERROR_SEVERITY(),
@ERR_STT_NR TINYINT = ERROR_STATE(),
@ERR_PRC_TE VARCHAR(50) = ERROR_PROCEDURE(),
@ERR_LN_NR INT = ERROR_LINE(),
@ERR_MSG_TE VARCHAR(1000) = ERROR_MESSAGE()
'Code to send the message back into the queue'
INSERT INTO DB_ERR_LOG(
ERR_NR,
ERR_SVR_NR,
ERR_STT_NR,
ERR_PRC_TE,
ERR_LN_NR,
ERR_MSG_TE,
LOG_DT)
SELECT
@ERR_NR,
@ERR_SVR_NR,
@ERR_STT_NR,
@ERR_PRC_TE,
@ERR_LN_NR,
@ERR_MSG_TE,
@END_TS
END CATCH
END
Thanks for any help.
Also if this is not the right area for this question I am sorry please tell me and I will try moving it to the right area.>>Please guide me how to create Stored Procedure and how to load datas into Flatfile table and from Flatfile Table to Parent and Child Table.
Can you try loading the data using SSIS package ? If that's not an option , you could try OPENROWSET
--from the linkUSE AdventureWorks2012;
GO
CREATE TABLE myTable(FileName nvarchar(60),
FileType nvarchar(60), Document varbinary(max));
GO
INSERT INTO myTable(FileName, FileType, Document)
SELECT 'Text1.txt' AS FileName,
'.txt' AS FileType,
* FROM OPENROWSET(BULK N'C:\Text1.txt', SINGLE_BLOB) AS Document;
GO
Satheesh
My Blog |
How to ask questions in technical forum -
How to write call specs for a java stored procedure that takes a nested obj
Example Class :
public class B {
int number;
String str;
public class A {
private B[] _childern;
public B[] getChildern(){
return _children
public static void saveAll(A a) throws SQLException {
B[] children = a.getChildern();
for(int i=0; i<children.length; i++){
saveChild(children);
public static void saveChild(B ch)throws SQLException {
// do something
What would be the call specification for the method A.saveAll(A)? Your help will be apprecited.
Thank you
AjmalIn other words, How to pass a Java Object from a Java stored procedure to a Java client ???
Hello,
I don't know to deal with a Vector object that has been generated from a stored procedure.
Should I create first in the JDBC client and pass it as argument to the procedure ?
Thanks in advance. Here is an extract ...
On the client side :
<<
Vector buffer = new Vector();
CallableStatement call =
con.prepareCall ("{call my_procedure_run (?, ?)}");
call.registerOutParameter(2, java.sql.Types.JAVA_OBJECT );
call.setString (1, "bla bla bla");
call.setObject (2, buffer);
call.execute ();
buffer = (Vector)call.getObject (2);
>On the Java stored procedure
<<
public class my_procedure
public static void Run(String input_value, Vector buffer)
// ??? Vector buffer = new Vector();
try
while ( true )
buffer.addElement(...) ;
catch(Exception ex) { } -
Empty strings when passing a Java object to a Stored Procedure
Hi,
I'm using the interface SQLData to pass Java objects to StoredProcedures. All the object's attributes 'arrive' to the Stored Procedure ok, except the strings, which are empty.
Here is my Oracle object:
TYPE OBJ_ASJFF_OBJ1 IS OBJECT (
ARG1 CHAR(3),
ARG2 NUMBER(4),
ARG3 CHAR(4),
ARG4 NUMBER(7),
ARG5 NUMBER(13,2),
ARG6 CHAR(1));
The nested table of that object:
TYPE TAB_ASJFF_OBJ1 AS TABLE OF OBJ_ASJFF_OBJ1;
The procedure declaration:
PROCEDURE Pup_Instaura_Processo ( x_crCert IN TAB_ASJFF_OBJ1,
x_cResult OUT CHAR(4)
My SQLData implementation:
public void writeSQL(SQLOutput stream) throws SQLException {
stream.writeString(getArg1());
stream.writeInt(getArg2().intValue());
stream.writeString(getArg3());
stream.writeLong(getArg4().longValue());
stream.writeBigDecimal(getArg5());
stream.writeString(getArg6());
Can anybody help me?
Thanks in advance
Rui Gonçalvesnot exactly what you wanted but ingredients can be found at
- JPublisher's docuemntation (especially "Type Mapping Support Through PL/SQL Conversion Functions")
- http://otn.oracle.com/sample_code/tech/java/jsp/Oracle9iJSPSamples.html (Best Hotels PL/SQL Sample )
- http://otn.oracle.com/tech/xml/xdk_sample/xdksample_093001i.html
hope this helps
Kuassi
I have a Java Stored procedure which takes an instance of a different java object as its parameter.
I need to do this from a pl/sql package - can anyone point me to a sample etc (looked on the website but don't see one) ?
Andrew -
Report with stored proc running multiple stored procedures with insert statement
Hi,
I wonder if this is possible in SSRS ... I use the 2012 version (Data Tools).
I have a report that triggers a stored procedure. See below.
Within this SP there are 2 insert statements getting data from 2 other SP's.
When I make a dataset referring to the main SP below, SSRS does not show me any fields at all.
Is this because it's a SP with insert statements and nested SP's?
At the end of the SP I make a select so it should see all the fields.
The parameters @month and @costcenter are multivalue params. I use a special function to convert the multivalues, selected in the report, into a string to pass it correctly to the query (comma separated).
USE [TestDB]
GO
/****** Object: StoredProcedure [dbo].[_Pink_SP_StandingsRegisterDataset] Script Date: 15-4-2014 13:31:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[_Pink_SP_StandingsRegisterDataset]
@year INT,
@month NVARCHAR(50),
@costcenter NVARCHAR(500),
@GLaccount NVARCHAR(9)
AS
BEGIN
/* Remove existing content*/
DELETE FROM _Pink_TB_StandingsRegister
/* Add records part 1 */
INSERT INTO _Pink_TB_StandingsRegister
EXEC _Pink_SP_StandingsRegister @year, @month, @costcenter, @GLaccount
/* Add records part 2 */
INSERT INTO _Pink_TB_StandingsRegister
Type,
Row,
Year,
Month,
YearDatetable,
MonthDatetable
EXEC _Pink_SP_StandingsRegisterDatetable @year
/* Select all records */
SELECT *
FROM _Pink_TB_StandingsRegister
END
GOHi bijntjede2e,
After testing a similar scenario in my own environment, it works well in Reporting Services. In my test, the stored procedure returns all the fields from _Pink_TB_StandingsRegister table in the dataset. Then I select some values from year, month, costcenter
and Glaccount parameters, it inserts some values in the _Pink_TB_StandingsRegister table. So we can use this stored procedure as the dataset in the report.
In order to solve the problem more efficiently, I need to clarify some information.
Are you pass multiple values parameter to one stored procedure correctly? We can refer to the following thread:
http://social.technet.microsoft.com/Forums/en-US/dbdfa101-cccc-4e9f-aa50-566dc5ebcc27/ssrs-2008-r2-report-dataset-call-a-stored-procedure?forum=sqlrep
What results are you get when executing the stored procedure in SQL Server Management Studio? Is it works well? We should double those stored procedures.
If there are any misunderstanding, please elaborate the issue for further investigation.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Maybe you are looking for
-
A 10 Steps Plan to Qualify Cisco Certifications
The networking industry over the last few years has made exceptional development so has increased the demand of networking professionals. Cisco Corporation is heading the networking industry by offering networking data management and all other highly
-
Reciving imges in a midlet sent by sevlet..
hiii........ i want to images sent by a servlet in a midlet thru this code.. try HttpConnection c = (HttpConnection) Connector.open(url); int i = c.getResponseCode(); if( i == HttpConnection.HTTP_OK ){ int len = (int)c.getLength(); System.out.println
-
I have forgotten my Apple ID security questions. I have reset my password but it is still asking me for the answers to my questions. What should I do?
-
XML load error - when moving table data after upgrade
Greetings: Background: Previously in our 2.2 instance, we would use the Data Load/Unload feature of APEX to move data in the form of XML from instance 1 to instance 2. This woks well because it moves images also (BLOB) What Changed: Recently we did t
-
Re-registering iPod for different user
Recently bought a new video iPod and wanted to give my older one to another family member using iTunes. When the iPod was synched with the new user's library iTunes effectively deleted all my old library and synched only the titles of the new users'