How to retrieve Table of Records output param from stored procedure ?
Hi,
I'm trying to retrieve data from a PL/SQL stored proc. It seems I can't modify this procedure (I'm not allowed to and I don't know PL/SQL :)).
My only documentation is the PL/SQL code and its comments. And that's the first I have to deal with output of a defined complex PL/SQL type
So the signature of the procedure is :
FUNCTION FUN_AFF_EVELEG_IHM (
pEntumTyp IN NUMBER,
pEntnum IN VARCHAR2,
pEveListSize IN OUT NUMBER,
pEveList IN OUT pkg_funaff_eveleg.TableRecordEVL,
pErrCode IN OUT VARCHAR2,
pMessage IN OUT VARCHAR2)
RETURN NUMBER;pkg_funaff_eveleg.TableRecordEVL type is defined as "TABLE of RecordEVL"
pkg_funaff_eveleg.RecordEVL type is defined as "RECORD" (struct of 12 different fields : NUMBER or VARCHAR2)
What is the correct syntax to call the stored procedure then ? I don't find how to manage the pEveList output param. Is it a Cursor ? An ARRAY ? And how to register it ?
My code so far :
public static void callFunaffEVL(Connection con, String rcs) {
// CallableStatement procCstmt=null;
OracleCallableStatement oraCstmt = null;
try {
// Identifiy the Stored procedure
// package synonyme : pkg_aff_EVELEG_IHM
// stored procedure name : FUN_AFF_EVELEG_IHM
String command = new StringBuilder("{? = call pkg_aff_EVELEG_IHM.FUN_AFF_EVELEG_IHM(?,?,?,?,?,?");
// 1 RETURN
// 2 pEntumTyp IN NUMBER
// 3 pEntnum IN VARCHAR2
// 4 pEveListSize IN OUT NUMBER,
// 5 pEveList IN OUT pkg_funaff_eveleg.TableauRecordEVL,
// 6 pErrCpde IN OUT VARCHAR2,
// 7 pMessage IN OUT VARCHAR2)
// Create a Callable Statement Object:
oraCstmt = (OracleCallableStatement) con.prepareCall(command);
// Assign IN and OUT parameters
oraCstmt.registerOutParameter(1, OracleTypes.NUMBER); // RET
oraCstmt.setInt(2, 0); // ENTNUMTYP
oraCstmt.setString(3, rcs); // ENTNUM
oraCstmt.registerOutParameter(4, OracleTypes.NUMBER); // pEveListSize
oraCstmt.registerOutParameter(5, OracleTypes.ARRAY); // pEveList
oraCstmt.registerOutParameter(6, OracleTypes.VARCHAR); // pErrCode
oraCstmt.registerOutParameter(7, OracleTypes.VARCHAR); // pMessage
// Execute the Procedure or Function Call:
oraCstmt.execute();
// Process the OUT Placeholders:
int ret = oraCstmt.getInt(1);
String errCode = oraCstmt.getString(6);
String message = oraCstmt.getString(7);
System.out.println("RCS : " + rcs);
System.out.println("ret : " + ret);
System.out.println("errCode : " + errCode );
System.out.println("message : " + message);
} catch (SQLException sqle) {
sqle.printStackTrace();
} finally {
// Close the CallableStatement Object:
try {
oraCstmt.close();
} catch (SQLException e) {
e.printStackTrace();
Return : java.sql.SQLException: Parameter type Conflict: sqlType=2003
Any help ? I found several examples that might refer to this case, but everything I tried end by a SQL exception of one type or another...
(and sorry for my poor english :))
Cy
As I said, "pkg_funaff_eveleg.TableRecordEVL" is TABLE of RecordEVL.
i.e : I can find 2 defined types under the package pkg_funaff_eveleg :
TYPE TableRecordEVL is TABLE of RecordEVL INDEX BY BINARY_INTEGER;
TYPE RecordEVL is RECORD (
EVLENTNUM_PK EVENEMENTS_LEGAUX.EVLENTNUM_PK%TYPE,
EVLENTNUMTYP_PK EVENEMENTS_LEGAUX.EVLENTNUMTYP_PK%TYPE,
EVLSEQ_PK EVENEMENTS_LEGAUX.EVLSEQ_PK%TYPE,
EVLTYPSRC EVENEMENTS_LEGAUX.EVLTYPSRC%TYPE,
EVLPK1 EVENEMENTS_LEGAUX.EVLPK1%TYPE,
EVLPK2 EVENEMENTS_LEGAUX.EVLPK2%TYPE,
EVLPK3 EVENEMENTS_LEGAUX.EVLPK3%TYPE,
EVLPK4 EVENEMENTS_LEGAUX.EVLPK4%TYPE,
EVLPK5 EVENEMENTS_LEGAUX.EVLPK5%TYPE,
EVLPK6 EVENEMENTS_LEGAUX.EVLPK6%TYPE,
EVLCODEVTSRC EVENEMENTS_LEGAUX.EVLCODEVTSRC%TYPE,
EVLLEGEVECOD EVENEMENTS_LEGAUX.EVLLEGEVECOD%TYPE,
EVLSEQREF_FK EVENEMENTS_LEGAUX.EVLSEQREF_FK%TYPE,
EVLCOMMENT EVENEMENTS_LEGAUX.EVLCOMMENT%TYPE,
EVLETATCOD EVENEMENTS_LEGAUX.EVLETATCOD%TYPE,
EVLHISDATPUB EVENEMENTS_LEGAUX.EVLHISDATPUB%TYPE,
EVLHISPUBPRE EVENEMENTS_LEGAUX.EVLHISPUBPRE%TYPE,
EVLHISDATEFF EVENEMENTS_LEGAUX.EVLHISDATEFF%TYPE,
EVLHISEFFPRE EVENEMENTS_LEGAUX.EVLHISEFFPRE%TYPE,
EVLHISPOIDATEFF EVENEMENTS_LEGAUX.EVLHISPOIDATEFF%TYPE,
EVLHISORICOD EVENEMENTS_LEGAUX.EVLHISORICOD%TYPE,
EVLHISSUPPORTCOD EVENEMENTS_LEGAUX.EVLHISSUPPORTCOD%TYPE,
EVLHISNUMSUPPORT EVENEMENTS_LEGAUX.EVLHISNUMSUPPORT%TYPE,
EVLHISNUMINF EVENEMENTS_LEGAUX.EVLHISNUMINF%TYPE,
ANNNUMBODPCL CBODACCPROD.CODANN2.ANNNUMBOD%TYPE
);If needed, I can translate each "EVENEMENTS_LEGAUX.EVLENTNUM_PK%TYPE", but they must be VARCHAR2 or NUMBER
Do I answer your question ?
Similar Messages
-
Is it possible to pass TABLE as the output parameter in stored procedure
Hey Experts,
Is it possible to pass TABLE as the output parameter in stored procedure.
eg
create procedure spGetData
@tableName as TABLE(intValue INT NOT NUL)
asYou can use OPENQUERY or OPENROWSET, as mentioned above, to make stored procedure results table like. There are
some limitations with these methods:
http://technet.microsoft.com/en-us/library/ms188427.aspx
In OPENQUERY this-sql-server-instance can be used instead of a linked server name. It requires setting data accces server option:
exec sp_serveroption @server = 'PRODSVR\SQL2012'
,@optname = 'DATA ACCESS'
,@optvalue = 'TRUE'
LINK: http://www.sqlusa.com/bestpractices/select-into/
Kalman Toth Database & OLAP Architect
SELECT Video Tutorials 4 Hours
New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012 -
How to output value from stored procedure
Hi folks, I need to output the OrderFK from a stored procedure not really sure how to achieve this any help or tips much appreciated.
Sql code below
USE [TyreSanner]
GO
/****** Object: StoredProcedure [dbo].[AddCustomerDetails] Script Date: 11/12/2014 20:56:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[AddCustomerDetails]
/***********************Declare variables ***********************/
/******tblCustomer******/
@Forename nvarchar(50),
@Surname nvarchar(50),
@HouseNo nvarchar(50),
@CustAddress nvarchar(50),
@Town nvarchar(50),
@Postcode nvarchar(50),
@ContactNo nvarchar(50),
@EmailAddress nvarchar(50),
/******tblLink_OrderProduct******/
@ProductQuantity int,
@TotalProductSaleCost decimal,
@ProductFK int,
@FittingDate date,
@FittingTime Time
As
DECLARE @CustomerFK int;
DECLARE @OrderFK int;
Begin TRANSACTION
SET NOCOUNT ON
INSERT INTO [TyreSanner].[dbo].[Customer](Forename, Surname, HouseNo, CustAddress, Town, Postcode, ContactNo, EmailAddress)
VALUES (@Forename,@Surname,@HouseNo,@CustAddress,@Town,@Postcode,@ContactNo,@EmailAddress)
Set @CustomerFK = SCOPE_IDENTITY()
INSERT INTO [TyreSanner].[dbo].[Order] (CustomerFK)
VALUES (@CustomerFK)
SET @OrderFK = SCOPE_IDENTITY()
INSERT INTO [TyreSanner].[dbo].[Link_OrderProduct](OrderFK, ProductFK, ProductQuantity, TotalProductSaleCost, FittingDate, FittingTime)
VALUES
(@OrderFK, @ProductFK, @ProductQuantity, @TotalProductSaleCost, @FittingDate, @FittingTime)
COMMIT TRANSACTIONHi brucey54,
There’re several ways to capture the value from a Stored Procedure. In you scenario, I would suggest 2 options, by an output parameter or by a table variable.
By an output Parameter, you need to make a little bit modification on your code as below:
USE [TyreSanner]
GO
ALTER PROCEDURE [dbo].[AddCustomerDetails]
@Forename nvarchar(50),
@FittingDate date,
@FittingTime Time,
@OrderFK int output
As
DECLARE @CustomerFK int;
--DECLARE @OrderFK int;
Run the following code, Then @OrderFKvalue holds the value you’d like.
DECLARE @OrderFKvalue int;
EXEC AddCustomerDetails(your parameters,@OrderFKvalue output)
Anyway if you don’t like to add one more parameter, you can get the value by a table variable as well. Please append “SELECT @OrderFK;” to your Procedure as below:
USE [TyreSanner]
GO
ALTER PROCEDURE [dbo].[AddCustomerDetails]
SET @OrderFK = SCOPE_IDENTITY()
INSERT INTO [TyreSanner].[dbo].[Link_OrderProduct](OrderFK, ProductFK, ProductQuantity, TotalProductSaleCost, FittingDate, FittingTime)
VALUES
(@OrderFK, @ProductFK, @ProductQuantity, @TotalProductSaleCost, @FittingDate, @FittingTime);
SELECT @OrderFK;
Then you can call the Stored Procedure as below:
DECLARE @T TABLE (OrderFK INT);
INSERT @T EXEC AddCustomerDetails(your parameters) ;
SELECT OrderFK FROM @T;
There’re more options to achieve your requirement, please see the below link:
How to Share Data between Stored Procedures
If you have any question, feel free to let me know.
Best Regards,
Eric Zhang -
Returning Oracle Output Parameters from Stored Procedures
Hi,
Please forgive my ignorance of Oracle and PL/SQL. I'm trying to get a value out of a stored proc which I've written. The proc takes a username input parameter and returns a user guid through an output parameter. I'm able to print the output parameter to the DBMS Output but can't figure out how to return the thing in a record when calling the proc through a normal sql prompt!
My call is like so:
DECLARE
nGUID NVARCHAR2(255);
BEGIN
GETUSER(nGUID, 'WHY-DEV-QSYS-Tim Watson');
DBMS_OUTPUT.PUT_LINE (nGUID);
Would like to return the value here; what's the syntax?
END;
The signature of the proc is
CREATE OR REPLACE PROCEDURE GETUSER
USERGUID OUT NVARCHAR2,
UNAME IN NVARCHAR2
IS
Can anyone assist?
Thanks in advance!
TimThe easiest way, in my opinion, is to not write a procedure, but a function for this porpose. You would not have to declare an out parameter, but a return value:
CREATE OR REPLACE FUNCTION GETUSER
UNAME IN NVARCHAR2
return nvarchar2
IS
From SQL prompt, you can then do
SQL> select getuser(<input_string>) from dual;
and get the returnvalue.
Best regards,
Gerd -
How to get RECORD data in output parameter of stored procedure
I would like to return some data through RECORD structure from stored procedure.
I have defined the RECORD as below:
type ShipmentStatus is record(
Booked integer,
OnWater integer,
OnRoad integer,
InAir integer,
OnRail integer,
InWarehouse integer,
Idle integer);
the stored procedure is defined as
create or replace procedure SP_MC_GET_SHIPMENT_STATUS
iCustId in nvarchar2,
oResult out ShipmentStatus
I can get result in Sql*plus or PL/SQL developer, but I failed in get the result in Toplink.
How can I get the output result, and convert it to an ENTITY by Toplink?
Could you give me some advices on how to do mapping, how to call the stored procedure etc.., or code snip?
Your answer is deeply appreciated. :)I'm not sure it is possible to get the PL/SQL record type through JDBC. Please try to access this procedure through JDBC to see if it is possible.
You may need to convert the record type, to an object-type, i.e. wrap the procedure in another procedure that converts the record type. You could also just wrap the procedure in another that expands the record values into individual output parameters. -
How to retrieve the duplicates records.
Hi friends,
My next issue, how to retrieve the duplicate records in web intelligence.I checked the option Retrieve duplicate records in web intelligence as well.But it is not helping me.
Hope you guys are help to solve this issue.
Thanks lot,
Regards,
-B-hi Blaji,,
ive tried this here and it worked perfectly with me
even so, you dont need to make the QTY as a dimension, you can leave it as a measure also, and it will work good with you.
click the block on the WebI, the Block itself.
and find its properties, under "Display", you will find
"Avoid Duplicate row Aggregations"
in the query it self you should flag "Retrieve Duplicated Rows"
i think this will work fine with you
good luck
Amr -
How do I merge data from table1 on server 1 to final table on server 2 with a stored procedure to execute every so
many hours.How big is the table on server B? Is that possible to bring the all data into a server A and merge the data locally?
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
How do I merge data from table1 on server 1 to final table on server 2 with a stored procedure to execute every so many hours.
Hello,
If you had configure server2 as
linked server on the server1, you can run the following statement inside stored proceduce to copy table data. And then create a job to the run stored proceduce every 4 hours.
Insert Into Server2.Database2.dbo.Table2
(Cols)
Select Cols From Server1.Database1.dbo.Table1
Or you can use the SQL Server Import and Export Wizard to export the data from server1 to server2, save the SSIS package created by the wizard on the SQL Server, create a job to run the SSIS package.
Reference:http://technet.microsoft.com/en-us/library/ms141209.aspx
Regards,
Fanny Liu
Fanny Liu
TechNet Community Support -
How to retrieve start and end date values from sharepoint 2013
Hi,
How to retrieve start and end date values from new event form of calendar in SharePoint foundation2013
Thanks
Gowri BalaguruHi Srini
Yes i need to have parallel flow for both and in the cube where my reporting will be on monthly basis i need to read these 2 master data and get the required attributes ( considering last/first day of that month as per the requirement).......but i am just wondering this is common scenario....while there are so many threads written for populating 0employee from 0person......don't they have such requirement.....
Thanks
Tripple k -
How in ColdFusion with in variables get a Oracle stored procedure to return values?
How in ColdFusion with in variables get a Oracle stored procedure to return values?
We have tried several things, we can get a stored procedure to return a result set if we are not passing in variables but we cannot get them when we are passing in variables.
We know how to do it calling MS SQL.
Thanks for any help,
Nathan Sr
P.S. we have heard this may not be possible with the current Oracle Driver is there a different Oracle driver?I can only barely understand what you're asking here (not from a technical perspective, but from understanding your written English), but I suspect you're wanting to know how to pass back values other than recordsets from Oracle?
You should be able to pass them back via a type=out proc param, shouldn't you?
If you could reword your post so it's a bit more coherent, and possibly post some code, that might help.
Adam -
How to execute Operating System commands from Stored procedure.
Any help on how to execute Operating System commands from stored procedures will be appreciated.
Nanditha.Search the forums for 'External Procedure' and you will find example code that has been posted before.
-
How to retrieve future hire records in HCM Extract?
Please let me know how to retrieve future hire employee records from HCM Extract. Is there any DB item available for the same.
HCM Extract related questions are likely better answered on the Human Capital Management (HCM) (MOSC) forum.
Jani Rautiainen
Fusion Applications Developer Relations
https://blogs.oracle.com/fadevrel/ -
How to delete the all records in Ztable from report program
Hi Guys,
Good Day!
How to delete all records in Ztable from report program(Means I want to clean Ztable records from report program) . Please send me the code.
Thanks & Regards,
ReddyUse this.
DELETE { {FROM target [WHERE sql_cond]}
| {target FROM source} }.
*But before deleting the rows please check if this Ztable is being used in any other programs or used by others.
Check "where-used-list"
in se11 give the table name
utilities- where-used list.
I hope this helps.
thanks. -
How to fetch 2 set of records in MII from SQL procedure
Hi Experts,
I am invoking a SQL procedure from MII which return 2 set of records. But at MII I am able to get only first set of records. Is there any configuration required at MII side or SQL side to get both set of records in MII?
Here is the SQL Query Structure
Create procedure Sample_Proc
@Param1 Varchar(10),
@Param2 varchar(10),
@Param3 Varchar(20) OUT,
SET INCOUNT ON;
AS
Begin
*//Selection statements//*
END
SP Executing in MII
Declare @Param1,
@Param2,
@Param3,
Exec Sample_Proc
@Param1='name',
@Param2='Id',
@Param3=@Param3 OUTPUT,
Select @Param3
Our SP is returning values (Say Recordset1)based on the input parameters 1 and 2 , along with Parameter3 value(Say Recordset2) in MS SQL server but in MII its returning only the values(Recordset1) ... how to fetch recordset2 values in MII
I hope MII can return 2 set of records (rowsets) after executing the procedure.
MII version -> 12.2.3 Build(182)
Thanks & Regards,
Rajasekhar KantepalliHi Swaroop,
With MII 14.0 SP5 Patch 11, in a transaction, I get following XML output for a query that executes an SP(returning multiple resultSets) :
And, results in this format can surely be used for further processing in an MII transaction.
Thanks Rajasekhar, got to know about this because of your query.
regards,
Manisha -
How to use Oracle refcursor dataset output parameter from SP
Can I request for help on how to use Oracle Output parameter from a stored procedure as a source. I need the output tobe stored in a flat file
Thanks
Abhijit
Message was edited by:
Abhijit77yes I would like to use it for ODI.. I would like the ouput of the refcursor to be fed to a text file using ODI. How to handle the records returned by the refcursor and map with txt file.
Maybe you are looking for
-
I have 1MB wireless link from my ISP. I am using Cisco VOIP phones in my company. Over the months my VOIP quality is not good(on/off connectivity),though my internet is somehow working fine. When I talked to my ISP , they told me to use Cisco switch
-
Euro symbol is showing as ? instead of actual symbol
Hi, Euro symbol is coming fine when run the report locally from template builder but showing ? when run from oracle apps. Any solution? Please help Thanks, Mahesh
-
Picture in iphoto is different than when ready to print
to make more sense... in iphoto, the pic looks great. Then I choose "print". The pic shows up with the top of subject's head trimmed off. Shouldn't it look just like it does before choosing to print? How do I fix this? I have tried to reduce my image
-
Cisco WLC PSK Scheduled for Autogeneration
Hi All, Is there a way to schedule Auto Generation of PSK for Guest WLAN in WLC or PI for every week/month? We want to use WPA+WPA2 layer2 security with PSK on our Guest WLAN with just a splash screen acknowledging our policy without user/name passw
-
Hi there, I checked the forum, and find many different possible answers...but got a bit lost... My point is: I updated to Safari 5, and since then the application is not even able to start. I'm running on an iMac 20" with Mac OS X 10.5.8. All I get i