Returning in out variable in proc
I am performing an insert using bulk collect.
In the below procedure v_week_no(i) is an IN OUT parameter, so i have to pass v_week_no(i) as input but i do not know how can i get the same v_week_no(i) as OUT parameter.
I have to get the same parameter as OUT and use that value in the next insert query.
How can i do this??
PKG_WEIGHT_TRACKER.P_SAVE_WEIGH_IN_RECORD
( v_member_id_1(i),
v_week_no(i),
v_mc_date(i),
v_l_no(i),
v_height_1(i),
v_today_weight_kg(i),
v_flag,
v_pn_no(i),
v_wt_loss_plan,
v_meeting_user_map_id_seq(i),
v_site_id
----- Get the v_week_no(i) as out value from proc and use in the below insert
INSERT INTO member_milestone
( member_milestone_id ,
user_id ,
week_no ,
milestone_id ,
reached_date ,
site_id ,
created_date ,
created_by ,
last_upd_date ,
last_upd_by
SELECT member_milestone_id_seq.nextval,
v_member_id_1(i),
v_week_no(i),
v_pa_no(i),
v_mc_date(i),
v_site_id,
v_mc_date(i) ,
v_created_by ,
v_sysDATE ,
V_CREATED_BY
FROM DUAL
Here is the thing,
v_week_no(i) is a collection passing to the procedure, the parameter to this procedure is defined as out, so i have to get the same column as out variable and use that value in the next subsequent inserts.
just calling this procedure will not give the same variable as output and use it in the next subsequent inserts
PROCEDURE P_SAVE_WEIGH_IN_RECORD (
p_USER_ID IN WEIGH_IN_RECORD.USER_ID%TYPE,
p_WEEK_NUMBER IN OUT WEIGH_IN_RECORD.WEEK_NO%TYPE,
p_WEIGH_IN_DATE IN OUT WEIGH_IN_RECORD.WEIGH_IN_DATE%TYPE,
p_LOCATION_ID IN OUT WEIGH_IN_RECORD.LOCATION_ID%TYPE,
p_HEIGHT IN OUT WEIGH_IN_RECORD.HEIGHT%TYPE,
p_WEIGHT IN OUT WEIGH_IN_RECORD.WEIGHT%TYPE,
p_NO_WEIGH_IN IN WEIGH_IN_RECORD.NO_WEIGH_IN_FLAG%TYPE,
p_WEIGH_IN_NOTE_ID IN OUT WEIGH_IN_RECORD.WEIGH_IN_NOTE_ID%TYPE,
p_WEIGHT_LOSS_PLAN_TYPE IN WEIGH_IN_RECORD.WEIGHT_LOSS_PLAN_TYPE_ID%TYPE,
p_MEETING_USER_MAP_ID IN WEIGH_IN_RECORD.MEETING_USER_MAP_ID%TYPE,
p_SITE_ID IN SITE.SITE_ID%TYPE
IS
m_WEIGHT NUMBER(10,4) := p_WEIGHT;
m_HEIGHT NUMBER(10,4) := p_HEIGHT;
BEGIN
Similar Messages
-
Executing a Stored Procedure with OUT Variables
When you execute a stored proc withi OUT variables, do you have to add in the "Declare" section and "Begin/End" sections? Or can you just use "EXECUTE <stored proc>"??
When you execute a stored proc withi OUT variables, do you have to add in the "Declare" section and "Begin/End" sections?
Or can you just use "EXECUTE <stored proc>"?? You mean this?:
michaels> create or replace procedure p (o out varchar2)
as
begin
o := 'Some out variable';
end p;
Procedure created.
michaels> var o varchar2(50)
michaels> exec p(:o)
PL/SQL procedure successfully completed.
michaels> print o
o
Some out variable -
APEX - accepting OUT variable values from PL/SQL Stored Procedure
I have created a page (Form) which is accepting values text fields.
In the Page Processing section under Processing, I am passing the values to a PL/SQL Stored Procedure, which acts like an API. The procedure contains code to validate the entered data and finally insert the data into the base tables. The procedure also contains OUT variables in the parameter that would return status of processing and any error messages.
Now, my question is, how can I make the page accept these OUT variables from the procedure. What I wish to do is, to capture these messages/processing status from the procedure in the page. For example, if there is a error in the data and the procedure is sending this message in the OUT variable, I need this to be displayed on the page as an error message.
Is this possible in APEX?
Regards,
Santhosh JoseHi VC,
I just tried putting the string directly instead of the variable. Its still not giving me the expected results.
HOWEVER, I think the reason was because of the EXCEPTION block in my code. I have an EXCEPTION block to handle exceptions. I commented the WHEN OTHERS section and now the error message is coming on the page.
So what I have done now is as follows: At the point at which the error is expected, I am raising a handled exception. And within the exception handling, I am giving RAISE_APPLICATION_ERROR.
WHEN ex_main_error*
THEN*
p_status := 2;*
p_msg := 'ERROR Stage: '||lc_err_stage||' ERROR Message: '||lc_err_msg;*
RAISE_APPLICATION_ERROR (-20001, p_msg);*
This is working now! Which is very good news. Thanks once again for your help!
Regards,
Santhosh Jose -
Printing OUT variables from a Stored Procedure
Hi all,
I'm running an SQL command that calls a Stored Procedure and passes in some value. I've pasted in the important parts of it below. What I am trying to do is access the OUT variables that have been assigned to the DECLARED variables. I come from a SQL Server background and there we can do "SELECT @variable" which will print it to screen. I'm trying to do something similar here.
I need to access the contents of the three variables declared at the top of the script.
Thanks in advance.
DECLARE
l_error_value NUMBER;
l_error_product VARCHAR2 (10);
l_CE_DOC_ID number;
BEGIN
PEM.create_enquiry
( ce_cat => 'COMP'
, ce_class => 'FRML'
, error_value => l_ERROR_VALUE
,error_product => l_ERROR_PRODUCT
, ce_doc_id => l_ce_doc_id
END;Ah yes I see. Sorry I misunderstood what you were suggesting. I'm currently working on a test script that uses an approach similar to the one you mentioned, but I'm having trouble resolving foreign key relationships with test data.
I've no access to the tables or anything so it's proving to be a time consuming task!!
Is it required that all fields are given a value, even if they have a "DEFAULT" defined for them within the procedure. At the moment I'm using a rather cumbersome approach to this:
i.e.
With cmmAddRequest
.ActiveConnection = strConnect
.CommandType = adCmdText
.CommandText = strSQL
.Parameters(0).Direction = adParamInput
.Parameters(1).Direction = adParamInput
.Parameters(2).Direction = adParamInput
.Parameters(3).Direction = adParamOutput
.Parameters(4).Direction = adParamOutput
.Parameters(5).Direction = adParamOutput
.Parameters(0).Value = "COMP"
.Parameters(1).Value = "FRML"
.Parameters(2).Value = "1"
.Execute
WScript.Echo(.Parameters(5).Value)
End With -
Use of Return and Notify_url variables offered by PayPal
I have been integrating PayPal into my application (ASP NET MVC) where I made some analysis about PayPal (went through their documentation about the integration). Created a PayPal sandbox account and can transfer the amount.What I want to know is about the `return` and `notify_url` variables. I have enabled `auto return` in my account and also enabled `PDT`. My form variable is like this:<input type="hidden" name="notify_url" value="http://localhost:xxx/xx/Notify">
<input type="hidden" name="return" value="http://localhost:xx/xx/Return">As I have surfed in net, what they state about `Return` and `notify_url` is:> The "return" URL to which PayPal redirects buyers’ browser after they complete their payments. For example, specify a URL on your site that displays a “Thank you for your payment” page. Default is nothing is specified – PayPal redirects the browser to a PayPal webpage. Note, you must have "Auto Return" enabled in your Account Profile settings in order for this variable to work.
>PayPal returns data back to your site via what they call IPN. Its really just a callback to a URL you specify. You can set this URL via the variable `notify_url` you can send to PayPal.From the above quotes what I understand is that PayPal will post `IPN` variables to `notify action` once the payment done before auto redirecting to the page I set (I mean customer may go the application page or they may close the session).But only return action alone hitting not the `Notify_url`.Correct me if I misunderstood the concept and let me know if it was still Unclear.Yes, it's not present in the code I have posted but I have tried this as well.
It didn't work, as expected, because soap/axis is on top of http and not https and because my proxy uses http as well (or at least that's what I have learned so far).
In fact, I have tried all combinations between http.\*, https.\*, and Authenticator without success.
I think the problem is more soap/axis related. The solution for axis2 seems somewhat 'trivial' (and well explained over the web) while it's not for axis1.
Regards
Rob
Edited by: RobR on Nov 29, 2007 4:37 AM
Edited by: RobR on Nov 29, 2007 9:56 AM -
How to use OUT variables in my stored procedure
I'm wondering if I can get some help using OUT variables in my stored procedure. Here's my code...
CREATE OR REPLACE PROCEDURE testProj.testProcedure (
v_segment_id IN VARCHAR2,
v_student_id OUT VARCHAR2,
v_current_code OUT NUMBER,
v_new_code OUT NUMBER
) AS
BEGIN
SELECT
s.student_id,
s.quad_code_id,
nc.quad_code_id
INTO
v_student_id,
v_current_quad_code,
v_new_quad_code
FROM testProj.students s
INNER JOIN testProj.new_codes nc ON s.student_id = nc.student_id
WHERE s.segment_id = v_segment_id ;
END testProcedure ;
EXECUTE testProj.testProcedure ('44') ;
When I execute that stored procedure with the above execute statement, I get this error:
Error report:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'testProcedure'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
+06550. 00000 - "line %s, column %s:\n%s"+
*Cause: Usually a PL/SQL compilation error.+
*Action:+Using Refcursor is one way you can do that ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
PL/SQL Release 10.2.0.3.0 - Production
CORE 10.2.0.3.0 Production
TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
NLSRTL Version 10.2.0.3.0 - Production
Elapsed: 00:00:00.21
satyaki>
satyaki>
satyaki>create or replace procedure r_arg(
2 choice in number,
3 b in out sys_refcursor
4 )
5 is
6 str varchar2(500);
7 begin
8 str := 'select * from emp';
9 open b for str;
10 exception
11 when others then
12 dbms_output.put_line(sqlerrm);
13 end;
14 /
Procedure created.
Elapsed: 00:00:01.84
satyaki>
satyaki>
satyaki>declare
2 rec_x emp%rowtype;
3 w sys_refcursor;
4 begin
5 dbms_output.enable(1000000);
6 r_arg(1,w);
7 loop
8 fetch w into rec_x;
9 exit when w%notfound;
10 dbms_output.put_line('Employee No: '||rec_x.empno||' - '||
11 'Name: '||rec_x.ename||' - '||
12 'Job: '||rec_x.job||' - '||
13 'Manager: '||rec_x.mgr||' - '||
14 'Joining Date: '||rec_x.hiredate||' - '||
15 'Salary: '||rec_x.sal||' - '||
16 'Commission: '||rec_x.comm||' - '||
17 'Department No: '||rec_x.deptno);
18 end loop;
19 close w;
20 exception
21 when others then
22 dbms_output.put_line(sqlerrm);
23 end;
24 /
Employee No: 9999 - Name: SATYAKI - Job: SLS - Manager: 7698 - Joining Date: 02-NOV-08 - Salary: 55000 - Commission: 3455 - Department No: 10
Employee No: 7777 - Name: SOURAV - Job: SLS - Manager: - Joining Date: 14-SEP-08 - Salary: 45000 - Commission: 3400 - Department No: 10
Employee No: 7521 - Name: WARD - Job: SALESMAN - Manager: 7698 - Joining Date: 22-FEB-81 - Salary: 1250 - Commission: 500 - Department No: 30
Employee No: 7566 - Name: JONES - Job: MANAGER - Manager: 7839 - Joining Date: 02-APR-81 - Salary: 2975 - Commission: - Department No: 20
Employee No: 7654 - Name: MARTIN - Job: SALESMAN - Manager: 7698 - Joining Date: 28-SEP-81 - Salary: 1250 - Commission: 1400 - Department No: 30
Employee No: 7698 - Name: BLAKE - Job: MANAGER - Manager: 7839 - Joining Date: 01-MAY-81 - Salary: 2850 - Commission: - Department No: 30
Employee No: 7782 - Name: CLARK - Job: MANAGER - Manager: 7839 - Joining Date: 09-JUN-81 - Salary: 4450 - Commission: - Department No: 10
Employee No: 7788 - Name: SCOTT - Job: ANALYST - Manager: 7566 - Joining Date: 19-APR-87 - Salary: 3000 - Commission: - Department No: 20
Employee No: 7839 - Name: KING - Job: PRESIDENT - Manager: - Joining Date: 17-NOV-81 - Salary: 7000 - Commission: - Department No: 10
Employee No: 7844 - Name: TURNER - Job: SALESMAN - Manager: 7698 - Joining Date: 08-SEP-81 - Salary: 1500 - Commission: 0 - Department No: 30
Employee No: 7876 - Name: ADAMS - Job: CLERK - Manager: 7788 - Joining Date: 23-MAY-87 - Salary: 1100 - Commission: - Department No: 20
Employee No: 7900 - Name: JAMES - Job: CLERK - Manager: 7698 - Joining Date: 03-DEC-81 - Salary: 950 - Commission: - Department No: 30
Employee No: 7902 - Name: FORD - Job: ANALYST - Manager: 7566 - Joining Date: 03-DEC-81 - Salary: 3000 - Commission: - Department No: 20
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.48
satyaki>
satyaki>Regards.
Satyaki De. -
How can I execute a Procedure with OUT variable is %ROWTYPE on SQL Prompt
Hi,
I have a procedure with OUT variable is %ROWTYPE
How can I execute the following procedure on SQL prompt.
(without creating anonymous block)
CREATE OR REPLACE PROCEDURE zz_sp_EMP(VEMPNO IN EMP.EMPNO%TYPE,
V_REC IN OUT EMP%ROWTYPE)
AS
BEGIN
SELECT * INTO V_REC FROM EMP WHERE EMPNO = VEMPNO;
END;
Thanks & Regards,
Nareshas previous posters said: it's not possible to do this without declaring a variable in the anonymous block.
With anonymous block it would look like this (had to change it a bit, since i'm using hr-schema on oracle XE):
declare
l_rec EMPLOYEES%ROWTYPE;
begin
zz_sp_EMP(VEMPNO => 100, V_REC => l_rec);
DBMS_OUTPUT.PUT_LINE ( 'first_name = ' || l_rec.first_name );
DBMS_OUTPUT.PUT_LINE ( 'last_name = ' || l_rec.last_name );
end;
first_name = Steven
last_name = King -
Free of goods returns with out main item
Hi.. All
Free goods returns with out Main item
created sale order with Shoes 5 Pair qnty
and free of goods are pair Soxs are 3
Now one pair Damaged now i want to send returns only For Free of goods Here no main item""""No seller is creating billing with free of goods with main items
now i am going to create Return order main item is coming as well as Free of goods items also coming to RO
Now i want to return only free of goods only one pair
i cant delete main item Right""""
Have you tested this? what was the problem in deleting the item??
Have you activated the complete reference in your VTAA controls??
Phanikumar -
JSP Custom Tags Fragments// OUT Variables
How are associations established between tag file fragment attributes and [OUT] variables? Is this established in a "tld" by associating an EL variable with an attribute element? I've been reading the tutorial, though I can't seem to resolve this. Thanks.
I'm not sure what you mean by out variables.
-
Out variable bnot working during Exception
Hi
I am having some problem with the Out varibale.
Out variables are not working of there is an Exception inside the called Procedure.
My Test Procedure
==============
CREATE OR REPLACE PROCEDURE TEST( ERR_MSG IN OUT VARCHAR2)
AS
BEGIN
ERR_MSG := 'Why I am not getting this Error Message';
RAISE_APPLICATION_ERROR(-20000,'Exception occured');
END;
My Calling PL SQL Block
===================
declare
Err_Msg varchar2(100);
begin
Err_Msg := 'I am OK Now';
test(Err_Msg);
exception when others then
dbms_output.put_line('Err_Msg=' || Err_Msg);
end;
Result
==================================
Err_Msg=I am OK Now
My question why I am not getting the error message set in the Out Parameter inside the procedue.
I am going for this approch since I can get more information for the cause of failure in different out variables during Exception.
Thanks in Advance
BalajiCorrect.
The NOCOPY will however work as it passes a pointer - thus the assignment statement changes the original variable. When the exception occurs nothing gets propogated up the call stack, except for the exception itself. But as the assignment already changed the source var using a pointer reference that caller will see the change.
However, I have a serious problem with anyone using this method in production code to propogate any data up the call stack when an exception occurs. IT IS WRONG. Period.
Besides, the PL/SQL manual clearly states that the NOCOPY statement is treated as a hint by the PL/SQL RTS. Thus you are not guaranteed to have a value by reference when using it. -
Some Out-Variables are not filled when one is missing (Oracle-Client 10)
Hello everybody,
we have a problem in our applications, written in C++ using OCI.
All works fine with Oracle Client 8 and 9, the problem occurs when using Client 10.
A simple example:
select 1, 2, 3, 4, 5 from dual;
I have 4 out-variables, the 3rd one is missing:
OCIDefineByPos(..., 1, &out1, ...);
OCIDefineByPos(..., 2, &out2, ...);
OCIDefineByPos(..., 4, &out4, ...);
OCIDefineByPos(..., 5, &out5, ...);
When executing with Oracle Client 8 and 9, the result is:
out1 = 1
out2 = 2
out4 = 4
out5 = 5
Executing the same with Oracle Client 10, the result is:
out1 = 1
out2 = 2
out4 = 0
out5 = 0
When there is a selected column without a variable for it, all following out-variables are not filled. Can someone repeat and / or explain this? I read the Oracle Docs for the OCI 10, but nowhere is a hint about differences or changes in this behaviour. I know that when selecting a column I should spend an out-variable for it, but nobody is perfect.
Here are some details:
Oracle Client 10.2.0.1.0
Client OS Windows XP SP1
Oracle Database 10g Release 10.2.0.1.0
Application developed with Visual Studio C++ 7.1
Thanks for any help.
Torsten
Here's the code, I changed the simple OCI-example from the Oracle homepage:
void ocitest()
static text username = (text ) "xxx";
static text password = (text ) "yyy";
static OCIEnv *envhp;
static OCIError *errhp;
static sword status;
sword out1, out2, out3, out4, out5;
sb2 ind1, ind2, ind3, ind4, ind5; /* indicator */
static text maxemp = (text ) "SELECT 1, 2, 3, 4, 5 FROM dual ";
OCISession authp = (OCISession ) 0;
OCIServer *srvhp;
OCISvcCtx *svchp;
OCIStmt stmthp, stmthp1;
OCIDefine defnp1 = (OCIDefine ) 0;
OCIDefine defnp2 = (OCIDefine ) 0;
OCIDefine defnp3 = (OCIDefine ) 0;
OCIDefine defnp4 = (OCIDefine ) 0;
OCIDefine defnp5 = (OCIDefine ) 0;
(void) OCIInitialize((ub4) OCI_DEFAULT, (dvoid *)0,
(dvoid * (*)(dvoid *, size_t)) 0,
(dvoid * (*)(dvoid *, dvoid *, size_t))0,
(void (*)(dvoid *, dvoid *)) 0 );
(void) OCIEnvInit( (OCIEnv **) &envhp, OCI_DEFAULT, (size_t) 0,
(dvoid **) 0 );
(void) OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &errhp, OCI_HTYPE_ERROR,
(size_t) 0, (dvoid **) 0);
/* server contexts */
(void) OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &srvhp, OCI_HTYPE_SERVER,
(size_t) 0, (dvoid **) 0);
(void) OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &svchp, OCI_HTYPE_SVCCTX,
(size_t) 0, (dvoid **) 0);
(void) OCIServerAttach( srvhp, errhp, (text *)"", strlen(""), 0);
/* set attribute server context in the service context */
(void) OCIAttrSet( (dvoid *) svchp, OCI_HTYPE_SVCCTX, (dvoid *)srvhp,
(ub4) 0, OCI_ATTR_SERVER, (OCIError *) errhp);
(void) OCIHandleAlloc((dvoid *) envhp, (dvoid **)&authp,
(ub4) OCI_HTYPE_SESSION, (size_t) 0, (dvoid **) 0);
(void) OCIAttrSet((dvoid *) authp, (ub4) OCI_HTYPE_SESSION,
(dvoid *) username, (ub4) strlen((char *)username),
(ub4) OCI_ATTR_USERNAME, errhp);
(void) OCIAttrSet((dvoid *) authp, (ub4) OCI_HTYPE_SESSION,
(dvoid *) password, (ub4) strlen((char *)password),
(ub4) OCI_ATTR_PASSWORD, errhp);
checkerr(errhp, OCISessionBegin ( svchp, errhp, authp, OCI_CRED_RDBMS,
(ub4) OCI_DEFAULT));
(void) OCIAttrSet((dvoid *) svchp, (ub4) OCI_HTYPE_SVCCTX,
(dvoid *) authp, (ub4) 0,
(ub4) OCI_ATTR_SESSION, errhp);
checkerr(errhp, OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &stmthp,
OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0));
checkerr(errhp, OCIHandleAlloc( (dvoid *) envhp, (dvoid **) &stmthp1,
OCI_HTYPE_STMT, (size_t) 0, (dvoid **) 0));
checkerr(errhp, OCIStmtPrepare(stmthp, errhp, maxemp,
(ub4) strlen((char *) maxemp),
(ub4) OCI_NTV_SYNTAX, (ub4) OCI_DEFAULT));
checkerr(errhp, OCIDefineByPos(stmthp, &defnp1, errhp, 1, (dvoid *) &out1,
(sword) sizeof(sword), SQLT_INT, (dvoid *) &ind1, (ub2 *)0,
(ub2 *)0, OCI_DEFAULT));
checkerr(errhp, OCIDefineByPos(stmthp, &defnp2, errhp, 2, (dvoid *) &out2,
(sword) sizeof(sword), SQLT_INT, (dvoid *) &ind2, (ub2 *)0,
(ub2 *)0, OCI_DEFAULT));
/* checkerr(errhp, OCIDefineByPos(stmthp, &defnp3, errhp, 3, (dvoid *) &out3,
(sword) sizeof(sword), SQLT_INT, (dvoid *) &ind3, (ub2 *)0,
(ub2 *)0, OCI_DEFAULT));*/
checkerr(errhp, OCIDefineByPos(stmthp, &defnp4, errhp, 4, (dvoid *) &out4,
(sword) sizeof(sword), SQLT_INT, (dvoid *) &ind4, (ub2 *)0,
(ub2 *)0, OCI_DEFAULT));
checkerr(errhp, OCIDefineByPos(stmthp, &defnp5, errhp, 5, (dvoid *) &out5,
(sword) sizeof(sword), SQLT_INT, (dvoid *) &ind5, (ub2 *)0,
(ub2 *)0, OCI_DEFAULT));
/* execute and fetch */
if (status = OCIStmtExecute(svchp, stmthp, errhp, (ub4) 1, (ub4) 0,
(CONST OCISnapshot *) NULL, (OCISnapshot *) NULL, OCI_DEFAULT))
if (status == OCI_NO_DATA)
else
checkerr(errhp, status);
void checkerr(OCIError *errhp, sword status)
text errbuf[512];
sb4 errcode = 0;
switch (status)
case OCI_SUCCESS:
break;
case OCI_SUCCESS_WITH_INFO:
(void) printf("Error - OCI_SUCCESS_WITH_INFO\n");
break;
case OCI_NEED_DATA:
(void) printf("Error - OCI_NEED_DATA\n");
break;
case OCI_NO_DATA:
(void) printf("Error - OCI_NODATA\n");
break;
case OCI_ERROR:
(void) OCIErrorGet((dvoid *)errhp, (ub4) 1, (text *) NULL, &errcode,
errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR);
(void) printf("Error - %.*s\n", 512, errbuf);
break;
case OCI_INVALID_HANDLE:
(void) printf("Error - OCI_INVALID_HANDLE\n");
break;
case OCI_STILL_EXECUTING:
(void) printf("Error - OCI_STILL_EXECUTE\n");
break;
case OCI_CONTINUE:
(void) printf("Error - OCI_CONTINUE\n");
break;
default:
break;
}Use int/long instead sword .
-
Out Variable of PL/SQL into UNIX environment
Hallo,
I'd like to pass an out variable from a PL/SQL package to an UNIX environment!
Is this possible?
Thanks,Hello Shankar,
Thank you for your instant reply.
Thanks to you, I can write the sample code that works fine.
I understand that calling setMaxParamSize() before calling setString() is very important.
Below is the final sample code that works fine.
std::string sql4 = "BEGIN test4_proc(:1); END;";
std::string result;
Statement* stmt4 = conn->createStatement(sql4);
stmt4->setMaxParamSize(1, 12); // Important!! Call before setXXX()
stmt4->setString(1, "Hello");
stmt4->executeUpdate();
result = stmt4->getString(1);
std::cout << "result : <" << result << ">" << std::endl;
Thank you. -
REF CURSOR not returned to "Output Variables"
I have a poorly performing procedure that returns a Ref Cursor. I can retrieve the Ref Cursor via Crystal Reports, so I know that it is working. However, the data is not showing up in the "Output Variables" section on SQL Developer version 3.1.07.42.
I have other procs that run much faster and the data shows up just fine for them.
I'm wondering if the fact that the query runs in about 4 minutes is causing the results to be lost?
Oracle 11.2.0.3.0 64 bit on AIX version 6.
Sql Developer 3.1.07.42.
Thanks.Can't reproduce. Test case:
<code>
create or replace
package pivot
as
type rc is ref cursor;
procedure tst4( c1 in out rc, c2 out rc, i out integer, c4 out rc );
end;
create or replace
package body pivot
as
procedure tst4( c1 in out rc, c2 out rc, i out integer, c4 out rc ) is
stmt1 long;
stmt2 long;
stmt3 long;
stmt4 long;
begin
stmt1 := 'select 11 one, 12 two, ''a'' from dual union select 21 one, 22 two, ''b'' from dual';
open c1 for stmt1;
stmt2 := 'select 2 from dual';
select count(1) into stmt4 from dual -- simulated delay
connect by level < 40000000;
open c2 for stmt2;
i:=42;
stmt4 := 'select level from dual connect by level < 7';
open c4 for stmt4;
end;
end; -
How to use stored procedure with many return results and variable with perl
Hi everybody,
i´m writtting now a Perl programm, wich use a oracle stored procedure with more than 1 result and 1 variable(I have to return 2 variable fpr each result). I don´t now how I can get it.I already search the web but I didn´t find.
My example:
PROCEDURE get_projects_and_sub_projects (
v_project_id IN INTEGER,
v_project_c_id OUT INTEGER,
v_project_id_find OUT VARCHAR2
IS
BEGIN
SELECT c_id, proj_id
INTO
v_project_c_id,
v_project_id_find
FROM t_projet
WHERE t_projet .ksa_pro_art_kbz = 'KU'
AND t_projet.proj_id LIKE v_project_id || '%';
EXCEPTION
WHEN NO_DATA_FOUND
THEN
v_project_c_id := NULL;
v_project_id_find := NULL;
WHEN OTHERS
THEN
kmessages.error (NULL,
'get_projects_and_sub_projects',
'Project-Name: ' || v_project_id,
'Errornumber: '
|| SQLCODE
|| ' Error: '
|| SQLERRM,
TRUE,
TRUE
raise_application_error (-20001,
'Error '
|| SQLCODE
|| ' get_projects_and_sub_projects: '
|| SQLERRM,
TRUE
END get_projects_and_sub_projects;
in Perl Program:
sub get_projects_unterprojects_name($$){
my ($db_handle, $proj_name_id) = @_; #$db_handle ist the DB Connection return value
my $db_proj_c_id;
my $db_proj_name;
eval{ my $csr = $db_handle->prepare(q{
BEGIN
pro_doc_ber.get_projects_and_sub_projects(:proj_name_id, :db_proj_c_id, :db_proj_name);
END;
# parameter value
$csr->bind_param(":proj_name_id", $proj_name_id);
# return values
$csr->bind_param_inout(":db_proj_c_id", \$db_proj_c_id, 11);
$csr->bind_param_inout(":db_proj_name", \$db_proj_name, 20);
$csr->execute(); };
But this didn´t work. Could somebody give me some idea?
Thank you
FelxSome additional info would probably be helpful.
What is your programming enviironment? Java?
In any case I suspect that you will need to use the OCI to deal with specific Oracle types such as user defined object types -- thats not standard ANSI SQL.
In Java I believe you need to use OPAQUE, there are some examples out there. I'm mostly a PL/SQL developer with some Java expereince so others here are more qualifed to answer your question more directly. -
I need to know the syntax to print out bind variable to
xterm. ( :import.out := outdir ).
I believe forms doesn't have the dbms package but
does have the text_io. I would like to know the
syntax for both as I want to monitor a variable's contents
from unix script through forms and through a stored procedure.> I want to use the select statement instead of anonymous block.
Like I wrote above, functions with out parameters is poor programming practice. Oracle won't let you use a function with an out parameter in a select statement. You MUST use PL/SQL. See this example:
SQL> Create or replace function ABC(i in number, o out number)
2 return number is
3 Begin
4 o := 2 * i;
5 Return 3 * i;
6 End;
7 /
SQL> variable o1 number
SQL> select ABC( 5, :o1 ) from dual;
select ABC( 5, :o1 ) from dual
ERROR at line 1:
ORA-06572: Function ABC has out arguments
SQL> variable r1 number
SQL> Begin
2 :r1 := ABC( 5, :o1 );
3 End;
4 /
SQL> print :r1
R1
15
SQL> Print :o1
O1
10
SQL> drop function ABC;
SQL>
Maybe you are looking for
-
When I send a text my phone is sending a copy of my text back to me. How do I turn the off
My iPhone 4S started sending copies of the text messages I send other people to them ; but it also sends a copy back to me. How do I fix this? I turned off receipts and it still does it.
-
Hi All, Imagine I have a team of 20+ developers all writing PL/SQL extracting data for our internal customers who in turn use this to answer key Business questions (sound familiar?). The common data requests are packaged up and presented in a 'self s
-
What is standard PO smartforms program
please send me reply Reguards, Raji
-
UCCX Best Practice - UCM Agent Line Configuration documentation
With UCCX, I have always abided by some rules when it came to configuration of the agent's line in CUCM. At least to be a TAC supported solution anyway. For Example: 1. Agent Extension can not be shared 2. Agent Exension not part of any CUCM hunt g
-
Can't get rid of automatic request for server connect.
When loggin in the computer tries to connect to an other computer in the house (the last time the computer was connected to this server (other comp.), it could not disconnect, and since then it tries to connect again by login). How do I get rid of th