OUT parameter functionality
I thought that you are not supposed to be able to assign the value of an out parameter to a variable (Feuerstein, 5th ed) and yet I was just
able to do this without any compilation error messages. Is Feuerstein wrong or am I missing something? Has the functionality changed?
PROCEDURE Parse_HC
(p_timestamp_string IN VARCHAR2,
p_timestamp_date OUT DATE)
AS
v_date DATE;
BEGIN
p_timestamp_date := TO_DATE(p_timestamp_string, 'YYMMDDHH24MI');
v_date := p_timestamp_date;
END Parse_HC;
Here is my banner:
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 – Production
"CORE 11.1.0.7.0 Production"
TNS for Linux: Version 11.1.0.7.0 – Production
NLSRTL Version 11.1.0.7.0 - Production
>
He said, on p583 of "Oracle PL/SQL Programming":
"You cannot assign an OUT parameter's value to another variable or even use it in a reassignment to itself."
I think his reasoning is that OUT parameters are write-only; thus, since they can't be read, one can't assign them to a variable.
But, based on the result of my code, that's not true. But perhaps I misunderstand his point.
>
Well this shows that (vanilla 11.2.0.1.0) you can assign the OUT multiple times and assign it to your var multiple times.
CREATE OR REPLACE PROCEDURE Parse_HC
(p_timestamp_string IN VARCHAR2,
p_timestamp_date OUT DATE)
AS
v_date DATE;
BEGIN
dbms_output.put_line('v_date initial:' || v_date);
p_timestamp_date := TO_DATE(p_timestamp_string, 'YYMMDDHH24MI');
v_date := p_timestamp_date;
dbms_output.put_line('v_date after:' || v_date);
p_timestamp_date := sysdate + 2;
v_date := p_timestamp_date;
dbms_output.put_line('v_date after 2nd:' || v_date);
END Parse_HC;
declare
mydate date;
begin
parse_hc('1303251425', mydate);
dbms_output.put_line(mydate);
end;
v_date initial:
v_date after:25-MAR-13
v_date after 2nd:27-MAR-13
27-MAR-13
Similar Messages
-
Can we use OUT or IN OUT parameter mode in function?
Can we use OUT or IN OUT parameter mode in function & if YES then what's limitations?
hi,
Yes we can have OUT and IN OUT parameters for a function.
As per my knowledge there are no limitations , but as per the convention we will use OUT ,IN OUT Parameter modes for only procedures .
Thanks,
P Prakash -
Pass a record type vaiable in out parameter of a function in a package
Hi All,
1.I have created a ecod inside a package.
2.Then created a function which has a out parameter of the above record.
3.Now package body i'm creating a dynamic cursor .
4.My equirement is to fetch this dynamic cursor's value into the out parameter of the function.
I have created the below code for 1,2 and 3 but not getting how to achive the point 4.
create package pkg
type t_rec is recod (id number,id_name varchar2(10));
type t_data is table of t_rec index by binary_integer;
act_data t_data;
funcion return_data is (dept in number,region in number,o_rec out t_data) return boolean;
end pkg;
create package body pkg
funcion return_data is (dept in number,region in number,o_rec out t_data) return boolean is
p_cur sys_refcursor;
l_text varchar2(100);
begin
-- As per my requirement i have built a dynamic l_text which contains where clause by taking dept and region values.In actual i have nearly 10 in paramaters with >which i'm building a dynamic where clause in l_text. So i'm using a ref cursor.
open p_cur for 'select id,id_name from tab1'||l_text';
fetch p_cur bulk collect into act_data;
exception ....
end pkg;Now as per the code snippet i could fetch all the rows returned by p_cur into act_data.
But how i will pass it though out parameter in the function which i will use somewhere in front end to show data.
Please help me in this.
Thanks in advance.bp wrote:
i need to create the where clause one the basis of the values of IN parameters.Sometimes i need to take count of the data on the basis of the IN parameters and if one of the conditions return value i will build where clause with those parameters.Please google and read up on the importance of creating shareable SQL - which needs to be done using bind variables.
The ref cursor interface in PL/SQL only support a static/fixed number of bind variables. So if you want to create cursors with variable number of bind values, you need to use conditional processing. E.g.
SQL> create or replace procedure EmpFilter( c OUT sys_refcursor, nameFilter varchar2, jobFilter varchar2 ) is
2 sqlSelect varchar2(32767);
3 begin
4 --// we pretend to built a dynamic SQL statement - so the table
5 --// name and so on is "unknown"
6 sqlSelect := 'select * from emp ';
7 case
8 when nameFilter is null and jobFilter is null then
9 open c for sqlSelect;
10
11 when nameFilter is null and jobFilter is not null then
12 sqlSelect := sqlSelect||'where job like :filter';
13 open c for sqlSelect using jobFilter;
14
15 when nameFilter is not null and jobFilter is null then
16 sqlSelect := sqlSelect||'where ename like :filter';
17 open c for sqlSelect using nameFilter;
18
19 when nameFilter is not null and jobFilter is not null then
20 sqlSelect := sqlSelect||'where ename like :filter1 and job like :filter2';
21 open c for sqlSelect using nameFilter, jobFilter;
22
23 end case;
24
25 DBMS_OUTPUT.put_line( 'Dynamic SQL: '||sqlSelect );
26 end;
27 /
Procedure created.
SQL>
SQL>
SQL> var c refcursor
SQL> begin
2 EmpFilter( :c, 'A%', null );
3 end;
4 /
Dynamic SQL: select * from emp where ename like :filter
PL/SQL procedure successfully completed.
SQL> print c
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7499 ALLEN SALESMAN 7698 1981/02/20 00:00:00 1600 300 30
7876 ADAMS CLERK 7788 1987/05/23 00:00:00 1100 20
SQL>
SQL> begin
2 EmpFilter( :c, null, 'ANALYST' );
3 end;
4 /
Dynamic SQL: select * from emp where job like :filter
PL/SQL procedure successfully completed.
SQL> print c
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7788 SCOTT ANALYST 7566 1987/04/19 00:00:00 3000 20
7902 FORD ANALYST 7566 1981/12/03 00:00:00 3000 20
SQL>And this approach is for external clients - where a Visual Basic or Java client program calls the database, executes the stored procedure, and receives a cursor handle in turn. And the client then fetches the output of this cursor and process it.
There is no need to return a record type of any sorts. The client wants the cursor handle as that is the optimal and best interface for the client to receive database data.
If the caller is not an external client, but another PL/SQL procedure, then this approach does not make much sense.
It is important that you understand basic Oracle concepts and fundamentals. What a cursor is. What the best way is to process Oracle data. How to best use the basic features of Oracle. Without that basic understanding, you as good as a low hour Cessna pilot getting into an Airbus A400M - where the Cessna pilot would not even be able to start a single engine, never mind get the plane in the air.
Likewise, without a basic understanding of Oracle cursors and fundamentals, you will be unable to code even a single line of sensible code. Not because you are a bad programmer. Even the best programmer in the world will be unable to write decent code, if the programmer has no idea how the environment works, what the concepts and fundamentals are. But it is fair to expect that a good programmer will no write such code, understand that there is a lack of knowledge, and address that accordingly. -
Stored function with OUT parameter
Hi there,
anyone knows wether a stored function may have an OUT parameter other than a returning value and/or IN parameter.
I think not but I've a doubt about it.
Thanks
Paolo Paolucci
Oracle ConsultingMi h capitato sovente di utilizzare funzioni del tipo:
Function PROVA
( param1 IN datatype,
param2 OUT datatype DEFAULT default_value,
param3 IN OUT datatype DEFAULT default_value)
RETURN datatype IS.......
Spero di aver interpretato bene la domanda, ciao
null -
How can I Create function with an out Parameter
how all
how can I Create function with an out Parameter
I try to create it it sucess but how can I CALL it , it give me error
please I want A simple example
thanks3rd post on same question by same user :
Re: how can I Create function with an out Parameter
how can I Create function with an out Parameter -
Calling a Function returing(Out parameter) Nested Table Rows in Java
Hi,
I am trying to call a Function which returns Nested Table rows (as Out Parameter) in Java .
When I am trying to use
pstmt.registerOutParameter(3, OracleTypes.OTHER);
to capture the Out parameter in Java code , I get the follwoing error :
java.sql.SQLException: Invalid column type
I have even tried using OracleTypes.JAVA_OBJECT ,but I get the same error.
If I use OracleTypes.JAVA_STRUCT I get
java.sql.SQLException: Parameter Type Conflict: sqlType=2008
error.
Please help .
Am I doing the right thing ?
Thanks in advance.
NinadNinad,
Search this forum's archives for STRUCT and ARRAY and peruse the "Collections" examples on this Web page:
http://www.oracle.com/technology/sample_code/tech/java/sqlj_jdbc/files/jdbc20/jdbc20.html
Good Luck,
Avi. -
Call stored procedure with OUT parameter
Hello,
I have created a short-lived process. Within this process I am using the "FOUNDATION > JDBC > Call Stored Procedure" operation to call an Oracle procedure. This procedure has 3 parameters, 2 IN and 1 OUT parameter.
The procedure is being executed correctly. Both IN parameters receive the correct values but I am unable to get the OUT parameter's value in my process.
Rewriting the procedure as a function gives me an ORA-01460 since one of the parameters contains XML (>32K) so this is not option...
Has someone been able to call a stored procedure with an OUT parameter?
Regards,
NicoObject is Foundation, Execute Script
This is for a query, you can change to a stored procedure call. Pull the value back in the Java code then put into the process variable.
import javax.naming.InitialContext;
import javax.sql.DataSource;
import java.sql.*;
PreparedStatement stmt = null;
Connection conn = null;
ResultSet rs = null;
try {
InitialContext ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("java:IDP_DS");
conn = ds.getConnection();
stmt = conn.prepareStatement("select FUBAR from TB_PT_FUBAR where PROCESS_INSTANCE_ID=?");
stmt.setLong(1, patExecContext.getProcessDataLongValue("/process_data/@inputID"));
rs = stmt.executeQuery();
rs.next();
patExecContext.setProcessDataStringValue("/process_data/outData", rs.getString(1));
} finally {
try {
rs.close();
} catch (Exception rse) {}
try {
stmt.close();
} catch (Exception sse) {}
try {
conn.close();
} catch (Exception cse) {} -
Invoking Stored Procedure with OUT Parameter
I am calling a stored procedure that has a "out" parameter of PL/SQL type (table of varchar2) through toplink API. My procedure executes, performs the updates successfully, but I can not obtain the value of the out parameter. Is the approach followed below incorrect? I could not figure out by looking into examples provided in the documentation:
http://download.oracle.com/docs/cd/B25221_04/web.1013/b25386/building_and_using_application_services009.htm#BCFEFAHC
Java function is given below:
public List removeFromAutoupdSched( List srNumbers, String userName)
if (srNumbers == null || srNumbers.size() == 0)
return null;
List result = null;
try
//Example Stored procedure call with an output parameter
DatabaseLogin login = m_dbSess.getLogin();
Connection conn = (Connection) (java.sql.Connection)login.connectToDatasource(null);
oracle.sql.ArrayDescriptor arrDesc = new oracle.sql.ArrayDescriptor("AUTOUPD_SRLIST_T", conn);
oracle.sql.ARRAY srARR = new oracle.sql.ARRAY(arrDesc, conn, srNumbers.toArray());
StoredProcedureCall procCall = new StoredProcedureCall();
procCall.setProcedureName("SEW_AUTOUPD.PURGE_AUTOUPD_SCHEDULE");
procCall.addNamedArgumentValue("excludeSRlist", srARR);
procCall.addNamedArgumentValue("exclude_by", userName);
procCall.addNamedOutputArgument(
"excludeSR_srlist_status",
"excludeSR_srlist_status",
OracleTypes.ARRAY,
"AUTOUPD_SRLIST_ERRS_T"
ValueReadQuery vq = new ValueReadQuery();
vq.setCall(procCall);
oracle.sql.ARRAY srResultARR = (oracle.sql.ARRAY)m_dbSess.executeQuery(vq);
if (srResultARR != null)
String[] msgs = (String[])srResultARR.getArray();
if (msgs.length > 0)
result = Arrays.asList(msgs);
Iterator iter = result.iterator();
while (iter.hasNext())
System.out.println("msg = " + iter.next());
return result;
catch (Exception exc)
throw new RuntimeException(exc);
PL/SQL Type
create or replace TYPE autoupd_srlist_errs_t IS TABLE OF VARCHAR2(150);
Sample procedure called by toplink:
PROCEDURE purge_autoupd_schedule(
excludeSRlist autoupd_srlist_t,
exclude_by VARCHAR2,
excludeSR_srlist_status OUT NOCOPY autoupd_srlist_errs_t)
IS
pkg sew_log.pkg_name%TYPE default upper('sew_autoupd');
prc sew_log.prc_name%TYPE default upper('purge_autoupd_schedule(excludeSRlist, exclude_by)');
srno NUMBER;
-- cnt NUMBER := 0;
exclude_status VARCHAR2(150);
err_prefix VARCHAR2(50) := 'Unable to exclude from autoupdate, ';
BEGIN
FOR i IN excludeSRlist.FIRST..excludeSRlist.LAST
LOOP
BEGIN
srno := excludeSRlist(i);
-- Update actn_taken column in autoupd_schedule before doing delete.
UPDATE autoupd_schedule SET actn_taken='Removed by engineer', UPD_TIME=systimestamp
WHERE sr_no = srno and engr_itsid = exclude_by;
-- Add SR to exclusion list.
INSERT INTO autoupd_exclude(sr_no, exclude_by, exclude_time) VALUES (srno, exclude_by, systimestamp);
exclude_status := 'Item ' || i || ' - SR ' || srno || ' - ' || 'Excluded from autoupdate.';
excludeSR_srlist_status(i) := exclude_status;
EXCEPTION
WHEN others THEN
-- Add SR to excludeSR_fail if previous steps occurred okay.
-- cnt := cnt +1;
exclude_status := 'Item ' || i || ' - SR ' || srno || ' - ' || err_prefix || substr(sqlerrm,12);
excludeSR_srlist_status(i) := exclude_status;
END;
END LOOP;
EXCEPTION
WHEN others THEN
sew_logger.log(
code => substr(sqlerrm,1,9),
msg => substr(sqlerrm,12),
pkg => pkg,
prc => prc
END;
Any help is appreciated.What happens if you run the stored procedure through pure jdbc (without TopLink)?
I tried a simple example that worked for me:
//defined type in the db
CREATE TYPE "TEST"."VAR_LIST" AS TABLE OF VARCHAR2(150)
//defined stored procedure in the db
CREATE OR REPLACE PROCEDURE "TEST"."VAR_LIST_IN_OUT" (
VARS_IN VAR_LIST,
VARS_OUT OUT NOCOPY VAR_LIST
as
begin
VARS_OUT := VAR_LIST();
FOR i IN VARS_IN.FIRST..VARS_IN.LAST LOOP
VARS_OUT.EXTEND;
VARS_OUT(i) := CONCAT(VARS_IN(i), '_BLAH');
END LOOP;
end;
// Java code
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("VAR_LIST_IN_OUT");
Connection conn = (Connection) ((oracle.toplink.internal.sessions.AbstractSession)getSession()).getAccessor().getConnection();
oracle.sql.ArrayDescriptor arrDesc = new oracle.sql.ArrayDescriptor("VAR_LIST", conn);
oracle.sql.ARRAY srARR = new oracle.sql.ARRAY(arrDesc, conn, new String[]{"A1", "A2", "A3"});
call.addNamedArgumentValue("VARS_IN", srARR);
call.addNamedOutputArgument("VARS_OUT", "VARS_OUT", Types.ARRAY, "VAR_LIST");
ValueReadQuery query = new ValueReadQuery();
query.setCall(call);
Object result = getSession().executeQuery(query);
Object[] array = (Object[])((java.sql.Array)result).getArray();
for(int i=0; i<array.length; i++) {
System.out.println(array);
// System.out:
[TopLink Finest]: 2008.04.25 15:37:16.687--DatabaseSessionImpl(3491657)--Thread(Thread[main,5,main])--Execute query ValueReadQuery()
[TopLink Fine]: 2008.04.25 15:37:16.703--DatabaseSessionImpl(3491657)--Connection(29118152)--Thread(Thread[main,5,main])--BEGIN VAR_LIST_IN_OUT(VARS_IN=>?, VARS_OUT=>?); END;
bind => [oracle.sql.ARRAY@323274, => VARS_OUT] (There is no English translation for this message.)
A1_BLAH
A2_BLAH
A3_BLAH
My stored procedure didn't work (on Oracle 9 db) without output collection initialization: VARS_OUT := VAR_LIST(); and extending: VARS_OUT.EXTEND. -
Oracle Instant Client and OUT Parameter of custom type in Stored Procedures
Hi @ all!
I try to set up a simple client application, that calls a stored procedure via Instant Client from C#.
The stored procedure and assiciated types looks like this:
TYPE MYVALUE AS OBJECT
Id INTEGER,
value FLOAT
TYPE MYVALUELIST AS TABLE OF MYVALUE;
PROCEDURE ReadValues( ID IN INTEGER,
RESULTSET OUT MYVALUELIST)
IS
...I created an Oracle Command executing this SP and added OracleParameters for ID and (where I got stuck) the RESULTSET.
Is it possible to pass a parameter with a custom type from C# in some way?
I already tried it as a function with SELECT * FROM TABLE(ReadValues(1));
With my parameter RESULTSET as the RETURN type. But since I use DML within the procedure, this does not work inside of a query...
Any suggestions?
Thanks in advance!Hi Greg!
Sorry, I misunderstood the forum topic then. =(
Anyway, in the example you provided in the link, this is nearly exactly my situation. But there the Oracle.DataAccess.Client is used, where the OracleDBType can be called to initialize an object of type person. I use the instant client libraries called by using System.Data.OracleClient. There is only the OracleType enum, that does not contain an object or something similar.
So I do it right now after trying a bit with a ref cursor parameter and an OracleDataAdapter - the ref cursor is passed back from Oracle as a DataReader, so die DataAdapter is able to use it for a .Fill():
OracleCommand cmd = new OracleCommand();
cmd.Parameters.Add("RESULTSET", OracleType.Cursor).Direction = ParameterDirection.Output;
OracleDataAdapter odr = new OracleDataAdapter(cmd);
DataTable result = new DataTable();
odr.Fill(result);Within my stored procedure I just added the following OUT parameter:
PROCEDURE ReadValues( ID IN INTEGER,
RESULTSET OUT sys_refcursor)
IS
currentlist MYVALUELIST;
... [Adding elements to that list] ...
OPEN resultset for select * from TABLE(currentlist);It works now, but I don't like that solution that much since I'm always afraid that there are lots of opened cursors idyling around. Do I have to close this one explicitly after filling my table by the DataAdapter?
Regards -
How to use the out parameter of a transformation
Hi All,
I have a requirement where I need to move all the transformations from process flows to map.SO for each transformation I need to have 1 map which calls this transformation.I have 1 transformation which has both input and output parameter.If I use this transformation in mapping then how to use the out parameter of thsi transformation.This out parameter needs to beused in other mappings.Can soemone please help me.
Thansk in advanceHi,
I'm not quite sure what you are trying to do.
What works: Connect the outgroup of a pre- or post-mapping process operator to the mapping output parameter operator..
What does not work: Connect the outgroup of an operator that can return more than one row (e.g. table operator, filter, joiner ,...) to the mapping output parameter operator. The mapping output parameter just returns "one row", like a pl/sql function call.
You cannot pass a "data stream" from one mapping to another. Maybe the pluggable mappings is what you are looking for.
Regards,
Carsten. -
Calling an Oracle stored procedure and retrieving result from OUT parameter
Hello,
I have a stored procedure that returns a string in an OUT parameter after receiving 6 IN parameters. I have tested the procedure in PL/SQL and it's producing the right output there. The problem is when I call the stored procedure from my Java method. I then get an error message telling me that I have the wrong number or types of arguments in my procedure call. I have checked that the method receives and sends the correct data in the correct order and I'm not sure what else the error message can relate to...?
The exception is called on my second try statement but I haven't been able to find out what I have done wrong there. Does anyone have any suggestions? Thanks.
the error message
java.sql.SQLException: ORA-06550: line 1, column 13: PLS-00306: wrong number or types of arguments in call to 'P_SET_GIVEN_ANSWER' ORA-06550: line 1, column 7: PL/SQL: Statement ignored
the procedure
CREATE OR REPLACE PROCEDURE p_set_given_answer(
strfeedback OUT VARCHAR2,
intpi_id IN INTEGER,
intquestion_id IN INTEGER,
intgivenanswer IN INTEGER,
strgivenprefix IN VARCHAR2,
strgivenunit IN VARCHAR2,
strgu_id IN VARCHAR2) AS
-- some declarations
BEGIN
-- some processing and then returns the string below indicating the outcome
strfeedback = 'result';
END
the java method (the class is called dbUtil and the database connection is created in the method called getDbConnection() )
public void setGivenAnswer(int intPi_id, int intQuestion_id, int intGivenAnswer, String strGu_id, String strGivenPrefix, String strGivenUnit) {
java.sql.Connection con = null;
String query = "{call ? := p_set_given_answer(?,?,?,?,?,?)}";
try {
con = dbUtil.getDbConnection();
} catch(Exception e) {
dbConnectionExceptionMessage = "error 1:"+e.toString();
try{
CallableStatement stmt = con.prepareCall(query);
// register the type of the out param - an Oracle specific type
stmt.registerOutParameter(1, OracleTypes.VARCHAR);
// set the in params
stmt.setInt(2, intPi_id);
stmt.setInt(3, intQuestion_id);
stmt.setInt(4, intGivenAnswer);
stmt.setString(5, strGivenPrefix);
stmt.setString(6, strGivenUnit);
stmt.setString(7, strGu_id);
// execute the stored procedure
stmt.execute();
// retrieve the results
strFeedback = stmt.getString(1);
} catch (java.sql.SQLException e) {
dbConnectionExceptionMessage = "error 2:"+e.toString();
try {
con.close();
} catch (java.sql.SQLException e) {
dbConnectionExceptionMessage = "error 3:"+e.toString();
----------------------------------------Looks like you are declaring a procedure, but you are calling it like a function. A procedure has no return value, it has only parameters: "{call p_set_given_answer(?,?,?,?,?,?,?)}"
-
Procedure with table type out parameter
Hi,
I need to create a procedure which gives back a content of a table as an out parameter.
i have tried something like below code
it might not be correct since i am writing from home and cannot access any oracle db right now
create or replace procedure test (
table_out test_table%rowtype
) as
type table_out test_table%rowtype
begin
select * into table_out
from test_table
where country = 'HUN';
end;
compile doesnt gives error, but when running it i get error
declare
table_out test_table%rowtype
begin
test( table_out );
dbms_output.put_line( table_out );
end;
but it fails, could you help how to solve the above problem and call the proc correctly?
thanks in advanceWell you said you want the content of a table but your example says you just want a record. So for a record:
CREATE OR REPLACE PROCEDURE sp_test (EMP_REC OUT EMP%ROWTYPE) IS
BEGIN
select * into emp_rec from emp where empno = 7369;
END;The anonymous block to run it might be:
declare
tab_out emp%rowtype;
begin
sp_test(tab_out);
dbms_output.put_line(tab_out.ename);
end;As damorgan said the dbms_output can't be used with the record type. Notice I used it for the ENAME value of the record.
If you really want the entire table then do it the way damorgan suggests. A pipeline function can give you the table but not as an OUT parameter. -
Registering a bool out parameter in callable statement
Hi all..
Can we register a bool type as a out parameter.in oraclecallablestatement.....
Class definition says only char varchar long raw longraw can be registered as out parameters..
if we cant.. what how can we capture a bool o/p from a function....please helpuser21786,
We discussed this issue just a few days ago. Boolean is not a supported native type in oraclecallablestatement. Check the thread for workarounds.
--Shiv -
Returning result set from procedure out parameter, display with anon block
I'm trying to do something pretty simple (I think it should be simple at least). I want to use a pl/sql procedure to return a result set in an OUT parameter. If I run this code by itself (in the given anonymous block at the end, without trying to display any results), toad says that the PL/SQL procedure successfully completed.
How can I display the results from this procedure? I am assuming that the result set should be stored in the O_RETURN_REDEEM_DTL, but how can I get anything out of it?
I have this package with the following procedure:
/* FUNCTION - REDEEM_DTL_READ */
PROCEDURE REDEEM_DTL_READ(
ZL_DIVN_NBR_IN IN REDEEM_DTL.ZL_DIVN_NBR%TYPE,
GREG_DATE_IN IN REDEEM_DTL.GREG_DATE%TYPE,
ZL_STORE_NBR_IN IN REDEEM_DTL.ZL_STORE_NBR%TYPE,
REGISTER_NBR_IN IN REDEEM_DTL.REGISTER_NBR%TYPE,
TRANS_NBR_IN IN REDEEM_DTL.TRANS_NBR%TYPE,
O_RETURN_REDEEM_DTL OUT REDEEM_DTL_TYPE,
o_rtrn_cd OUT NUMBER,
o_err_cd OUT NUMBER,
o_err_msg OUT VARCHAR2
IS
BEGIN
o_rtrn_cd := 0;
o_err_msg := ' ';
o_err_cd := 0;
--OPEN REDEEM_DTL_READ_CUR(ZL_DIVN_NBR_IN, GREG_DATE_IN, ZL_STORE_NBR_IN, REGISTER_NBR_IN, TRANS_NBR_IN);
OPEN O_RETURN_REDEEM_DTL FOR SELECT * FROM REDEEM_DTL;
-- LOOP
-- FETCH REDEEM_DTL_READ_CUR INTO O_RETURN_REDEEM_DTL;
-- EXIT WHEN REDEEM_DTL_READ_CUR%NOTFOUND;
-- END LOOP;
-- CLOSE REDEEM_DTL_READ_CUR;
EXCEPTION
WHEN OTHERS
THEN
o_rtrn_cd := 7;
o_err_msg := SUBSTR (SQLERRM, 1, 100);
o_err_cd := SQLCODE;
END REDEEM_DTL_READ;and call it in an anonymous block with:
DECLARE
ZL_DIVN_NBR_IN NUMBER;
GREG_DATE_IN DATE;
ZL_STORE_NBR_IN NUMBER;
REGISTER_NBR_IN NUMBER;
TRANS_NBR_IN NUMBER;
O_RETURN_REDEEM_DTL PSAPP.CY_SALESPOSTING.REDEEM_DTL_TYPE;
O_RETURN_REDEEM_DTL_OUT PSAPP.CY_SALESPOSTING.REDEEM_DTL_READ_CUR%rowtype;
O_RTRN_CD NUMBER;
O_ERR_CD NUMBER;
O_ERR_MSG VARCHAR2(200);
BEGIN
ZL_DIVN_NBR_IN := 71;
GREG_DATE_IN := TO_DATE('07/21/2008', 'MM/DD/YYYY');
ZL_STORE_NBR_IN := 39;
REGISTER_NBR_IN := 1;
TRANS_NBR_IN := 129;
-- O_RETURN_REDEEM_DTL := NULL; Modify the code to initialize this parameter
O_RTRN_CD := NULL;
O_ERR_CD := NULL;
O_ERR_MSG := NULL;
PSAPP.CY_SALESPOSTING.REDEEM_DTL_READ ( ZL_DIVN_NBR_IN, GREG_DATE_IN, ZL_STORE_NBR_IN,
REGISTER_NBR_IN, TRANS_NBR_IN, O_RETURN_REDEEM_DTL, O_RTRN_CD, O_ERR_CD, O_ERR_MSG );
FOR item IN O_RETURN_REDEEM_DTL
LOOP
DBMS_OUTPUT.PUT_LINE('ZL_DIVN_NBR = ' || item.ZL_DIVN_NBR);
END LOOP;
END; And end up with an error:
ORA-06550: line 25, column 15:
PLS-00221: 'O_RETURN_REDEEM_DTL' is not a procedure or is undefined
ORA-06550: line 25, column 3:
PL/SQL: Statement ignoredMessage was edited by:
user607908Aha, I knew I forgot something!
I actually had it defined as a REF CURSOR in PSAPP.CY_SALESPOSTING package spec:
TYPE REDEEM_DTL_TYPE IS REF CURSOR;since I wasn't sure what to make it.
Cursor used in procedure:
CURSOR REDEEM_DTL_READ_CUR (
zl_divn_nbr_in IN NUMBER,
greg_date_in IN DATE,
zl_store_nbr_in IN NUMBER,
register_nbr_in IN NUMBER,
trans_nbr_in IN NUMBER)
IS
SELECT ZL_DIVN_NBR, GREG_DATE, ZL_STORE_NBR, REGISTER_NBR, TRANS_NBR, PAYMENT_TYP_NBR
FROM REDEEM_DTL
WHERE ZL_DIVN_NBR = zl_divn_nbr_in AND GREG_DATE = greg_date_in AND
ZL_STORE_NBR = zl_store_nbr_in AND REGISTER_NBR = register_nbr_in AND
TRANS_NBR = trans_nbr_in;Updated code:
/* PROCEDURE - REDEEM_DTL_READ */
PROCEDURE REDEEM_DTL_READ(
ZL_DIVN_NBR_IN IN REDEEM_DTL.ZL_DIVN_NBR%TYPE,
GREG_DATE_IN IN REDEEM_DTL.GREG_DATE%TYPE,
ZL_STORE_NBR_IN IN REDEEM_DTL.ZL_STORE_NBR%TYPE,
REGISTER_NBR_IN IN REDEEM_DTL.REGISTER_NBR%TYPE,
TRANS_NBR_IN IN REDEEM_DTL.TRANS_NBR%TYPE,
O_RETURN_REDEEM_DTL OUT REDEEM_DTL_TYPE,
o_rtrn_cd OUT NUMBER,
o_err_cd OUT NUMBER,
o_err_msg OUT VARCHAR2
IS
BEGIN
o_rtrn_cd := 0;
o_err_msg := ' ';
o_err_cd := 0;
OPEN REDEEM_DTL_READ_CUR(ZL_DIVN_NBR_IN, GREG_DATE_IN, ZL_STORE_NBR_IN,
REGISTER_NBR_IN, TRANS_NBR_IN);
--OPEN O_RETURN_REDEEM_DTL FOR SELECT * FROM REDEEM_DTL;
LOOP
FETCH REDEEM_DTL_READ_CUR INTO O_RETURN_REDEEM_DTL;
EXIT WHEN REDEEM_DTL_READ_CUR%NOTFOUND;
DBMS_OUTPUT.PUT_LINE('ZL_DIVN_NBR = ' || O_RETURN_REDEEM_DTL.ZL_DIVN_NBR);
END LOOP;
CLOSE REDEEM_DTL_READ_CUR;
-- LOOP
-- FETCH REDEEM_DTL_READ_CUR INTO O_RETURN_REDEEM_DTL;
-- EXIT WHEN REDEEM_DTL_READ_CUR%NOTFOUND;
-- END LOOP;
-- CLOSE REDEEM_DTL_READ_CUR;
EXCEPTION
WHEN OTHERS
THEN
o_rtrn_cd := 7;
o_err_msg := SUBSTR (SQLERRM, 1, 100);
o_err_cd := SQLCODE;
END REDEEM_DTL_READ;the updated anon block:
DECLARE
ZL_DIVN_NBR_IN NUMBER;
GREG_DATE_IN DATE;
ZL_STORE_NBR_IN NUMBER;
REGISTER_NBR_IN NUMBER;
TRANS_NBR_IN NUMBER;
O_RETURN_REDEEM_DTL PSAPP.CY_SALESPOSTING.REDEEM_DTL_TYPE;
O_RTRN_CD NUMBER;
O_ERR_CD NUMBER;
O_ERR_MSG VARCHAR2(200);
BEGIN
ZL_DIVN_NBR_IN := 71;
GREG_DATE_IN := TO_DATE('07/21/2008', 'MM/DD/YYYY');
ZL_STORE_NBR_IN := 39;
REGISTER_NBR_IN := 1;
TRANS_NBR_IN := 129;
-- O_RETURN_REDEEM_DTL := NULL; Modify the code to initialize this parameter
O_RTRN_CD := NULL;
O_ERR_CD := NULL;
O_ERR_MSG := NULL;
PSAPP.CY_SALESPOSTING.REDEEM_DTL_READ ( ZL_DIVN_NBR_IN, GREG_DATE_IN, ZL_STORE_NBR_IN,
REGISTER_NBR_IN, TRANS_NBR_IN, O_RETURN_REDEEM_DTL, O_RTRN_CD, O_ERR_CD, O_ERR_MSG );
FOR item IN 1..O_RETURN_REDEEM_DTL.COUNT
LOOP
DBMS_OUTPUT.PUT_LINE('ZL_DIVN_NBR = ' || O_RETURN_REDEEM_DTL(item).ZL_DIVN_NBR);
END LOOP;
END;and the new error:
ORA-06550: line 25, column 38:
PLS-00487: Invalid reference to variable 'O_RETURN_REDEEM_DTL'
ORA-06550: line 25, column 3:
PL/SQL: Statement ignoredAlso, it would be nice if the forums would put a box around code so that it would be easy to
distinguish between what is supposed to be code and what should be regular text...
Message was edited by:
user607908 -
Using the result of an OUT Parameter
Hi,
A little help?, I want to use the OUT parameter in another procedure, I can do it with a function but its bugging me what I'm doing wrong in the procedure.
I code compiles i.e.
PROCEDURE LOG_OUT(calc_id OUT NOCOPY VARCHAR2) AS
BEGIN
SELECT MAX(calculation_ID)
INTO calc_id
FROM AXMW_FA_TRX_DETAIL_BASE;
DBMS_OUTPUT.PUT_LINE('LOG Value Returned IS : '||calc_id ) ;
END;
But when I call this from another procedure as
v_log_name VARCHAR2(400);
v_log_name := Fnd_File.LOG_OUT;
The error is
PLS-00306: wrong number or types of arguments in call to 'LOG_OUT'
Is it something with bind variables
Thanks
QuertyTry
v_log_name := 'Fnd_File.LOG_OUT';Hey, what r u doing with above code?
You are assigning string value to a variable?
The compilation won't give any error.
And OP thinks it's solution!!!!!!!!!!!
LOL
Maybe you are looking for
-
How to use exporting prameter IT_FILTER in FM 'REUSE_ALV_GRID_DISPLAY'
Hi ALL, Can u plz tell me what are the fields which i must pass for using IT_FILTER in FM 'REUSE_ALV_GRID_DISPLAY'. I am passing DATA:WT_TAB TYPE SLIS_T_FILTER_ALV , ws_fieldcat1 TYPE SLIS_FILTER_ALV. ws_fieldcat1-fieldname = 'SHIP_TO'. ws_fieldcat1-
-
Hello Experts, I am runing the transaction code CO60 to display the PI sheet,but it is resulting in a short-dump as a result of time out. This is happening with only one sheet. can we increase the time line to execute this particular trasaction ? I f
-
I have my monitor setup with several thresholds. And I am getting gwiapop3BadPassword gwiapop3UnknownUsers notifications. I would like to followup and see further details about these MIB captures but I can't find anything relating to them in the log
-
Same as Title.....
-
Windows XP operating system