Userdefined Type combined with AssociativeArray as Output Parameter
Hello,
Does anybody get a workin solution for this combination of Techs?
"Userdefined Type combined with AssociativeArray as Output Parameter".
I don't get in my solution.
I can also post my example, if this is helpfull.
cheers
Holger
Hi Holger,
PL/SQL Associative Arrays of UDTs is not supported by ODP.NET. There is a bug/enhancement request for this issue which will be addressed in a future release.
Please take a look at Mark's post in the following thread:
Re: timestamps with associative arrays
As a workaround, can you use VARRAY or Nested Table of UDTs?
-Naveen
Similar Messages
-
How to call a stored procedure with only one output parameter using toplink
Can anybody help me to get out of this exception. I have tried through several ways, but could not find the solution.
I have a following stored proc : -
CREATE OR REPLACE PROCEDURE spt_remove_duplicates_pr (outbuffer OUT VARCHAR2)
IS
buff VARCHAR2(32000) := ' ';
BEGIN
buff := ' Hi From Stored Proc' ;
outbuffer : = buff;
END;
When I am executing it using following code :-
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("spt_remove_duplicates_pr");
call.addNamedOutputArgument("a","a",String.class);
ValueReadQuery query = new ValueReadQuery();
query.setCall(call);
String buff1 = (String) session.executeQuery(query);
I am getting the exception as : -
LOCAL EXCEPTION STACK:
EXCEPTION [TOPLINK-4002] (TopLink - 9.0.3.4 (Build 432)): oracle.toplink.exceptions.DatabaseException
EXCEPTION DESCRIPTION: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'SPT_REMOVE_DUPLICATES_PR'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
INTERNAL EXCEPTION: java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'SPT_REMOVE_DUPLICATES_PR'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
ERROR CODE: 6550
at oracle.toplink.exceptions.DatabaseException.sqlException(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabasePlatform.executeStoredProcedureCall(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelectCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelect(Unknown Source)
at oracle.toplink.queryframework.DirectReadQuery.executeNonCursor(Unknown Source)
at oracle.toplink.queryframework.DataReadQuery.execute(Unknown Source)
at oracle.toplink.queryframework.ValueReadQuery.execute(Unknown Source)
at oracle.toplink.queryframework.DatabaseQuery.execute(Unknown Source)
at oracle.toplink.queryframework.ReadQuery.execute(Unknown Source)
at oracle.toplink.publicinterface.Session.internalExecuteQuery(Unknown Source)
at oracle.toplink.threetier.ServerSession.internalExecuteQuery(Unknown Source)
at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
at com.marshmc.eta.reuse.persistent.PersistentService$DuplicateRemovalThread.run(Unknown Source)
INTERNAL EXCEPTION STACK:
java.sql.SQLException: ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'SPT_REMOVE_DUPLICATES_PR'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1983)
at oracle.jdbc.ttc7.TTC7Protocol.parseExecuteFetch(TTC7Protocol.java:1141)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2149)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2032)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2894)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeDirectNoSelect(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabasePlatform.executeStoredProcedureCall(Unknown Source)
at oracle.toplink.internal.databaseaccess.DatabaseAccessor.executeCall(Unknown Source)
at oracle.toplink.threetier.ServerSession.executeCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelectCall(Unknown Source)
at oracle.toplink.internal.queryframework.CallQueryMechanism.executeSelect(Unknown Source)
at oracle.toplink.queryframework.DirectReadQuery.executeNonCursor(Unknown Source)
at oracle.toplink.queryframework.DataReadQuery.execute(Unknown Source)
at oracle.toplink.queryframework.ValueReadQuery.execute(Unknown Source)
at oracle.toplink.queryframework.DatabaseQuery.execute(Unknown Source)
at oracle.toplink.queryframework.ReadQuery.execute(Unknown Source)
at oracle.toplink.publicinterface.Session.internalExecuteQuery(Unknown Source)
at oracle.toplink.threetier.ServerSession.internalExecuteQuery(Unknown Source)
at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
at oracle.toplink.publicinterface.Session.executeQuery(Unknown Source)
at com.marshmc.eta.reuse.persistent.PersistentService$DuplicateRemovalThread.run(Unknown Source)I got the partial solution. The code is working now, however I am not getting the return value from stored proc.
The changed code is as :-
StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("spt_remove_duplicates_pr");
call.addNamedOutputArgument("outbuffer","outbuffer",StringBuffer.class);
ValueReadQuery query = new ValueReadQuery();
query.setCall(call);
StringBuffer buff1 = (StringBuffer) session.executeQuery(query);
System.err.println("Done ! Output is : " + buff1);
The result is :-
Done ! Output is : null
How can I get the output ? -
How to Execute a SP with onlly one OUTPUT parameter.
I have SP as:-
CREATE OR REPLACE PROCEDURE spt_remove_duplicates_pr (outbuffer OUT VARCHAR2)
IS
buff VARCHAR2(32000) := ' ';
BEGIN
buff := ' Hi From Stored Proc' ;
outbuffer : = buff;
END;
How can I execute it and get the output result ?
I have tried as
declare
buff VARCHAR2(32000) := '';
begin
select (exec spt_remove_duplicates_pr(buff)) into buff from dual;
DBMS_OUTPUT.put_line (buff);
end;
END;
but getting errors as : -
ORA-06550 line string, column string:string
Cause: A PL/SQL compilation error has occurred. The numbers given for line and column are the location in the PL/SQL block where the error occurred.
Please help.Probably I was being hasty in my assumptions. If you really need a procedure, use it like the following.
SQL> l
1 CREATE OR REPLACE PROCEDURE spt_remove_duplicates_pr (outbuffer OUT V
2 IS
3 buff VARCHAR2(32000) := ' ';
4 BEGIN
5 buff := ' Hi From Stored Proc' ;
6 outbuffer : = buff;
7
8* END;
SQL> /
Warning: Procedure created with compilation errors.
SQL> show errors
Errors for PROCEDURE SPT_REMOVE_DUPLICATES_PR:
LINE/COL ERROR
6/11 PLS-00103: Encountered the symbol ":" when expecting one of the
following:
:= . ( @ % ;
SQL> 6 outbuffer := buff;;
SQL> /
Procedure created.
SQL> declare
2 b varchar2(128);
3 begin
4 spt_remove_duplicates_pr(b);
5 dbms_output.put_line(b);
6 end;
7 /
PL/SQL procedure successfully completed.
SQL> set serveroutput on size 1000000
SQL> /
Hi From Stored Proc
PL/SQL procedure successfully completed.
SQL>
Just a side note, you got an error in line 6 of your procedure. In assignment operator :=
there must not be any symbols (including spaces) between : and =
Vlad Sadilovskiy
Oracle Database Tools
http://www.fourthelephant.com -
Connecting the Sequence Operator to the Mapping Output Parameter?
my OWB Client: 10.2.0.2.8
my OWB Repository: 10.2.0.2.0
I need to obtain a sequence number (from the Sequence Operator), then output it
using the Mapping Output Parameter, if possible.
I have tried two things:
1. Connect Sequence Operator nextval variable to the Mapping Output Parameter.
This generates error:
"Table,View Or Sequence reference 'xx_SEQ.NEXTVAL' not allowed in this
context"
2. Join the Sequence Operator nextval variable with a source table, then
connect a port from the dataflow to Mapping Output Parameter.
This generates error:
"Mapping Input Parameter and Mapping Output Parameter are intended to be
executed before and after the data flow of the mapping and cannot accept
inputs from any part of the data flow."
From what I have seen so far, it appears it may not be possible to use the
Sequence Operator along with the Mapping Output Parameter. If Im wrong, please
let me know of an example of how the Sequence Operator and Mapping Output
Parameter can be connected.
ThanksUser -
Look at adding a Post-Mapping Process to your mapping, there you have a choice of built in functions or custom ones that could return a sequence value for you. You may have to create the sequence outside of OWB ...
TXB -
Custom action with XML type input and output parameter.
Hi,
I want to develop custom action with xml type input and/or output parameter.
Is there sample code for java side. How is the definition of input and/or output parameter and set/get methods?
does it need special .jar file to develop custom action like this?
Thanks.Cemil - yes, you can use XML data types. Use the class
com.sap.lhcommon.xml.XMLDataType
for your parameter type. Here is a snippet from a custom action we use to log XML (instead of just returning the #text node like the default logger does):
public class XMLLogger extends ActionReflectionBase
private String source;
private String eventType;
private String textMessage;
private XMLDataType xmlMessage;
public XMLLogger()
log = new Logger("UserLog");
source = DEFAULT_SOURCE;
eventType = TYPE_INFO;
textMessage = "";
xmlMessage = new XMLDataType();
public XMLDataType getXmlMessage()
return xmlMessage;
public void setXmlMessage(XMLDataType xmlMessage)
this.xmlMessage = xmlMessage;
public void Invoke(Transaction transaction, ILog ilog)
StringBuffer sb = new StringBuffer();
sb.append('[');
sb.append(source);
sb.append("] ");
sb.append(textMessage);
sb.append(XMLUtils.convertXmlToString(xmlMessage));
XMLUtils is a helper class we wrote - it's just a bunch of standard Java XML boilerplate code. The important part you need to know is XMLDataType.getDocument() will return an org.w3c.dom.Document.
I hope that was enough information to help.
-tim -
Associative Array with more than one field - retrieving as output parameter
Hello,
I'm developing an C# Application that is showing a datagrid with results from a PL/SQL procedure inside a Package.
The .net project is in .net 4 and the DB is an oracle 10g.
I have read the odp.net sample about the associative array. I could successfully pass as an input parameter a string[] and dealing with it inside my PL/SQL procedure.
Now it become more complex to me because I would like to return an associative array defined like this :
TYPE r_FinalExtract IS RECORD
RecordmyTable myTable%ROWTYPE,
Tel1 varchar2(25),
Tel1Libelle varchar2(50),
Tel2 varchar2(25),
Tel2Libelle varchar2(50),
Tel3 varchar2(25),
Tel3Libelle varchar2(50),
Tel4 varchar2(25),
Tel4Libelle varchar2(50),
Tel5 varchar2(25),
Tel5Libelle varchar2(50),
Email1 varchar2(50),
Email1Libelle varchar2(50),
Email2 varchar2(50),
Email2Libelle varchar2(50)
TYPE t_FinalExtract IS TABLE OF r_FinalExtract INDEX BY BINARY_INTEGER;
You can guess my PL/SQL stored procedure is filling this collection.
The spec of my procedure :
PROCEDURE P_SELECTDATA( ptab_ListRef IN t_AssocArrayVarchar2, ptab_Result OUT t_FinalExtract );
Unfortunately, in my .net project, I don't know how to deal with that.
I tryed to add p_Result as an output parameter but you have to define the OracleCollectionType for that parameter and the array type is not the good one because my t_FinalExtract is not a simple array...
I searched over the internet and the only one thread I could find is someone who was doing like me... and finally reply to his own thread 3 months later and said that he had to create CSV lines and return a table of varchar2...
This is what I will do because I'm loosing time for finding the way to do it with my associative array, but if someone has the solution I would be glad to read it.
Thanks in advance.For PL/SQL records, I would recommend using User-Defined Types (UDTs), rather than associative arrays.
You can read more on how to use ODP.NET UDTs here:
http://docs.oracle.com/cd/E20434_01/doc/win.112/e23174/featUDTs.htm#CJAGCAID
Strictly speaking, ODP.NET doesn't support PL/SQL Records per se. Instead, ODP.NET supports building any generic UDT in the Oracle DB, which covers the effective functionality of a Record.
If you want to walk through the process of taking a sample DB UDT, generating a .NET custom class, then passing an instance between DB and application, here's a tutorial that shows you how to do that:
http://www.oracle.com/webfolder/technetwork/tutorials/obe/db/dotnet/userdefinedtypes/userDefinedTypes.htm -
How to call a Stored Procedure with a REF CURSOR output parameter
I am looking forward an example that call a stored function/procedure with a REF CURSOR output parameter and get the result.
In other words, I have a stored function/procedure that execute a SELECT statement using the OCI library and then it could get the values of each column and each row.
I put a code snippet, it have only the main thing to call a simple stored procedure and print the name of each column of the cursor, but I couldn´t to print out the values in the table that call the stored procedure.
I understand that the next step, it is to call a OCIStmtFetch.
How to associate the cursor with the OCIStmtFetch?
If you need more information, only tell me.
I am using ANSI C with HP-UX Operative System (C for HP-UX) and Oracle 10g.
Regards.
Antonio Garcia
/* callOracleSP */
#include <stdio.h>
#include <string.h>
#include <oci.h>
#include <stdlib.h>
char* pConnectChar ="server";
char* pUsernameChar = "user";
char* pPasswordChar = "passwd";
char* sqlCharArray1 = "BEGIN SP_GETCITIES(:s, :c); END;";
int retval;
ub4 parmcnt=0;
ub4 pos2=0;
text *pcoln[20];
ub4 namelen[20];
char state_key[5];
OCIStmt* pOciStatement;
OCIStmt* pOciStatCursor;
OCIError* pOciError;
OCIEnv* pOciEnviron;
OCIServer* pOciServer;
OCISession* pOciSession;
OCISvcCtx* pOciServiceContext;
OCIBind* pOciBind[500];
OCIParam* pOciParam;
int main()
retval = OCIEnvCreate(&pOciEnviron, OCI_DEFAULT, NULL, NULL, NULL, NULL,0,NULL);
retval = OCIEnvInit(&pOciEnviron, OCI_DEFAULT, 0, NULL);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatement, OCI_HTYPE_STMT, 0, NULL);
retval = OCILogon(pOciEnviron,pOciError,&pOciServiceContext,(unsigned char *)pUsernameChar,
strlen(pUsernameChar), (unsigned char *)pPasswordChar, strlen(pPasswordChar),
(unsigned char *)pConnectChar,strlen(pConnectChar));
printf("OCILogon retval=%d\n",retval);
retval = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray1,strlen(sqlCharArray1),
OCI_NTV_SYNTAX, OCI_DEFAULT);
printf("StmtPrepare retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatCursor, OCI_HTYPE_STMT, 0, NULL);
retval = OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4) 1, (void *)&state_key,
(sb4) sizeof(state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
retval = OCIBindByPos(pOciStatement,&pOciBind[1], pOciError, (ub4) 2, (void *)&pOciStatCursor,
(sb4) 0, SQLT_RSET, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
strcpy(state_key,"CA");
retval = OCIStmtExecute(pOciServiceContext, pOciStatement, pOciError, (ub4)1, (ub4) 0,
(OCISnapshot *)NULL, (OCISnapshot *)NULL, (ub4) OCI_DEFAULT);
printf("StmtExecute retval=%d\n",retval);
/* How to get the values of the cursor? */
/* Get number of parameters of the Cursor */
OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &parmcnt,(ub4 *) 0,
(ub4)OCI_ATTR_PARAM_COUNT, pOciError);
printf("\nNumber of parameters of the cursor = %d\n",parmcnt);
for (int pos = 1; pos <= (int)parmcnt; pos++)
OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &pos2,(ub4 *) 0,
(ub4)OCI_ATTR_CURRENT_POSITION, pOciError);
retval = OCIParamGet((void *)pOciStatCursor, (ub4)OCI_HTYPE_STMT, pOciError, (void **)&pOciParam,
(ub4) pos );
OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &pcoln[pos-1],(ub4 *) &namelen[pos-1],
(ub4) OCI_ATTR_NAME,(OCIError *)pOciError );
for (int i = 1; i <=(int)parmcnt; i++)
printf("Column %i\tNAME = %.*s\n",i,namelen[i-1],pcoln[i-1]);
return 0;
This is the script that create the table, insert records and create the stored procedure
CREATE TABLE CITIES (
STATE_CODE VARCHAR2(2) NULL,
CITY_CODE NUMBER(15,5) NULL,
CITY_NAME VARCHAR2(30) NULL
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('CA', 30, 'SAN DIEGO')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('CA', 40, 'SACRAMENTO')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('FL', 10, 'MIAMI')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('FL', 20, 'ORLANDO')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('NY', 10, 'NEW YORK')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('NY', 20, 'ALBANY')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('CA', 10, 'LOS ANGELES')
INSERT INTO CITIES(STATE_CODE, CITY_CODE, CITY_NAME)
VALUES('CA', 20, 'SAN FRANCISCO')
CREATE OR REPLACE PACKAGE globalPkg AUTHID CURRENT_USER AS
/* The following are T/SQL specific global variables. */
TYPE RCT1 IS REF CURSOR;/*new weak cursor definition*/
END globalPkg;
CREATE OR REPLACE PROCEDURE SP_ADDCITY(
P_STATE_CODE IN VARCHAR,
P_CITY_CODE IN NUMBER,
P_CITY_NAME IN VARCHAR2,
P_RETURN IN OUT NUMBER)
AS
StoO_error INTEGER;
StoO_selcnt INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
BEGIN
StoO_rowcnt := 0;
StoO_error := 0;
StoO_selcnt := 0;
P_RETURN := 0;
INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
VALUES (P_STATE_CODE, P_CITY_CODE, P_CITY_NAME);
StoO_rowcnt := SQL%ROWCOUNT;
EXCEPTION
WHEN TOO_MANY_ROWS THEN
StoO_rowcnt := 2;
WHEN OTHERS THEN
StoO_rowcnt := 0;
StoO_selcnt := 0;
StoO_error := SQLCODE;
StoO_errmsg := SQLERRM;
IF StoO_error != 0 THEN
BEGIN
P_RETURN := 1;
RETURN;
END;
END IF;
END;
CREATE OR REPLACE PROCEDURE SP_GETCITIES(
STATE_KEY IN VARCHAR,
RC1 IN OUT globalPkg.RCT1)
AS
StoO_error INTEGER;
StoO_selcnt INTEGER;
StoO_rowcnt INTEGER;
StoO_errmsg VARCHAR2(255);
BEGIN
StoO_rowcnt := 0;
StoO_error := 0;
StoO_selcnt := 0;
OPEN RC1 FOR
SELECT STATE_CODE, CITY_CODE, CITY_NAME
FROM CITIES
WHERE STATE_CODE = STATE_KEY
ORDER BY CITY_CODE;
StoO_rowcnt := SQL%ROWCOUNT;
EXCEPTION
WHEN OTHERS THEN
StoO_rowcnt := 0;
StoO_error := SQLCODE;
StoO_errmsg := SQLERRM;
END;
/Hi Mark,
Thanks for your recommendations.
I change the code with OCIDefineByPos, one for each parameter from cursor and then use the OCIStmtFetch.
I don´t receive a error when call OCIDefineByPos, but when I call OCIStmtFetch receive a -1 error number.
What is wrong with the code?
The script is the same.
I need your help!
Best Regards!
Antonio Garcia (Mexico)
This the new code:
#include <stdio.h>
#include <string.h>
#include <oci.h>
#include <stdlib.h>
char* pConnectChar ="ORAC617";
char* pUsernameChar = "C617_005_DBO_01";
char* pPasswordChar = "Tempora1";
char* sqlCharArray1 = "BEGIN SP_GETCITIES(:s, :c); END;";
int retval;
ub4 parmcnt=0;
ub4 pos2=0;
sb2 *c_indp;
text *pcoln[20], *name,*name2;
ub4 namelen[20],len;
ub2 type,size;
char state_key[5];
OCIDefine *pdef;
OCIBind *p_bnd;
ub1 **c_buf;
OCIStmt* pOciStatement; /* Statement handle */
OCIStmt* pOciStatCursor; /* Statement handle */
OCIError* pOciError; /* Error handle */
OCIEnv* pOciEnviron; /* Environment handle */
OCIServer* pOciServer; /* Server handle */
OCISession* pOciSession; /* Session handle */
OCISvcCtx* pOciServiceContext; /* Service Context handle */
OCIBind* pOciBind[500]; /* Bind handle */
OCIParam* pOciParam; /* Param handle */
int OCI_Fetch(OCIStmt *p_select,OCIError *p_err, int *piOcc)
int iOcc, rc;
rc=OCIStmtFetch(p_select,p_err,1,OCI_FETCH_NEXT,OCI_DEFAULT);
printf("rc fetch %i",rc);
if(rc==0&&piOcc!=NULL){
printf("entro al if");
iOcc=*piOcc;
*piOcc=iOcc+1;
return rc;
int main()
int pos,i=0,rc;
retval = OCIEnvCreate(&pOciEnviron, OCI_DEFAULT, NULL, NULL, NULL, NULL,0,NULL);
printf("EnvCreate retval=%d\n", retval);
retval = OCIEnvInit(&pOciEnviron, OCI_DEFAULT, 0, NULL);
printf("EnvInit retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciError, OCI_HTYPE_ERROR, 0, NULL);
printf("HandleAlloc OCI_HTYPE_ERROR retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciServiceContext, OCI_HTYPE_SVCCTX, 0, NULL);
printf("HandleAlloc OCI_HTYPE_SVCCTX retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatement, OCI_HTYPE_STMT, 0, NULL);
printf("HandleAlloc OCI_HTYPE_STMT retval=%d\n",retval);
retval = OCILogon(pOciEnviron,pOciError,&pOciServiceContext,(unsigned char *)pUsernameChar,
strlen(pUsernameChar), (unsigned char *)pPasswordChar, strlen(pPasswordChar),
(unsigned char *)pConnectChar,strlen(pConnectChar));
printf("OCILogon retval=%d\n",retval);
retval = OCIStmtPrepare(pOciStatement, pOciError, (unsigned char *)sqlCharArray1,strlen(sqlCharArray1),
OCI_NTV_SYNTAX, OCI_DEFAULT);
printf("StmtPrepare retval=%d\n",retval);
retval = OCIHandleAlloc(pOciEnviron, (void **)&pOciStatCursor, OCI_HTYPE_STMT, 0, NULL);
printf("HandleAlloc OCI_HTYPE_STMT retval=%d\n",retval);
retval = OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4) 1, (void *)&state_key,
(sb4) sizeof(state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
retval = OCIBindByPos(pOciStatement,&pOciBind[1], pOciError, (ub4) 2, (void *)&pOciStatCursor,
(sb4) 0, SQLT_RSET, (void *) 0, (ub2 *) 0, (ub2 *)0,(ub4)0, (ub4 *)0, (ub4) OCI_DEFAULT);
printf("BindByPos OCI_HTYPE_STMT retval=%d\n",retval);
strcpy(state_key,"CA");
retval = OCIStmtExecute(pOciServiceContext, pOciStatement, pOciError, (ub4)1, (ub4) 0,
(OCISnapshot *)NULL, (OCISnapshot *)NULL, (ub4) OCI_DEFAULT);
printf("StmtExecute retval=%d\n",retval);
c_buf=(ub1 **)calloc(sizeof(ub1 *),3);
c_indp=(sb2 *)calloc(sizeof(sb2 *),3);
// Get number of parameters of the Cursor
OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &parmcnt,(ub4 *) 0,
(ub4)OCI_ATTR_PARAM_COUNT, pOciError);
printf("\nNumber of parameters of the cursor = %d\n",parmcnt);
for (pos = 1; pos <= (int)parmcnt; pos++)
OCIAttrGet((void *) pOciStatCursor, (ub4)OCI_HTYPE_STMT, (void*) &pos2,(ub4 *) 0,
(ub4)OCI_ATTR_CURRENT_POSITION, pOciError);
retval = OCIParamGet((void *)pOciStatCursor, (ub4)OCI_HTYPE_STMT, pOciError, (void **)&pOciParam,(ub4) pos );
// Get the column name
OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &name,(ub4 *) &len, (ub4) OCI_ATTR_NAME,(OCIError *)pOciError );
// Get the column datatype
OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &type,(ub4 *)0,(ub4)OCI_ATTR_DATA_TYPE,(OCIError *)pOciError);
// Get the column size
OCIAttrGet((void*) pOciParam, (ub4) OCI_DTYPE_PARAM,(void*) &size,(ub4 *)0,(ub4)OCI_ATTR_DATA_SIZE,(OCIError *)pOciError);
printf("Column %i\tNAME = %.*s \ttype %d \tsize %d\n",pos,len,name,type,size);
// OCIDefine ByPos, one for each parameter
// c_buf store the STATE_CODE, CITY_CODE and CITY_NAME columns from the cursor
rc=OCIDefineByPos(pOciStatCursor,&pdef,(OCIError *)pOciError,pos,c_buf[pos-1],size+1,(ub2)type,(dvoid *)c_indp[pos-1],(ub2 *)0,(ub2 *)0,OCI_DEFAULT);
printf("OCIDefineByPos retval=%d\n,rc);
// call OCIStmtFetch. In the next line, I receive the error
rc=OCIStmtFetch(pOciStatCursor,pOciError,1,OCI_FETCH_NEXT,OCI_DEFAULT);
printf("rc fetch %i",rc);
return 0;
{code} -
Problem with Output parameter in HR function
Hi,
I have a function "Z" done with tx PE04, the country it's venezuela, and i define the IT table as entry and output parameter.
When i run the payroll, ithe changes that i did by abap code in order to change one concept of the IT table doesn't appears in the log. I do this in others versions of sap and works... I working with SAP ECC 6.0.
Thanks,
Albio.-Hi,
This function it's not of the transaction se37, it was created using the transaction pe04, there are two types of parameters entry and output for the payrolls' log.
I have created several functions with pe04, and never this happened.
Thanks in advance.
Albio.- -
Calling Stored Procedure with Boolean Output Parameter
Hi all,
I'm running into an issue (or is it a BUG) when calling a Database Stored Procedure that has an output parameter of the boolean type.
procedure proc(p_text in varchar2, p_result out boolean)
is
.....I use the following 'standard' code (developer guide 36-19 36-20) to invoke this procedure from my application module.
try {
// 1. Define the PL/SQL block for the statement to invoke
String stmt = "begin proc(?,?); end;";
// 2. Create the CallableStatement for the PL/SQL block
st = getDBTransaction().createCallableStatement(stmt, 0);
// 3. Register the positions and types of the OUT parameters
st.registerOutParameter(2, Types.BOOLEAN);
// 4. Set the bind values of the IN parameters
st.setObject(1, "Some text");
// 5. Execute the statement
st.executeUpdate();
..............................As soon as 'st.registerOutParameter(2, Types.BOOLEAN);' is invoked I run into a SQLexception. "Invalid ColumnType: 16". Obviously 16 refers to Types.BOOLEAN.
[edit by Luc]
SOLUTION / WORKAROUND
To answer my own question.
It looks like BOOLEAN output parameters are not supported. I just Read "Appendix D Troubleshooting" of the Oracle® Database JDBC Developer's Guide and Reference 10g Release 2 (10.2).
I found that JDBC drivers do not support the passing of BOOLEAN parameters to PL/SQL stored procedures. If a PL/SQL procedure contains BOOLEAN values, you can work around the restriction by wrapping the PL/SQL procedure with a second PL/SQL procedure that accepts the argument as an INT and passes it to the first stored procedure. When the second procedure is called, the server performs the conversion from INT to BOOLEAN.
I'm not very happy with this but I guess I've no choice.
Regards Luc
Edited by: lucbors on Nov 30, 2010 10:37 AMfyi
Related to the solution/workaround posted by Luc.
see "Do Oracle's JDBC drivers support PL/SQL tables/result sets/records/booleans? "
at http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#34_05
regards
Jan Vervecken -
Calling an oracle stored procedure with output parameter
Hi,
I am trying to execute a procedure with 2 input and 1 output parameters by using SQLQuery. I tried each mode (Command, FixedQuery & FixedQueryWithOutput) with following statements.
call cm_test_prod([Param.1],[Param.2],[Param.3])
Error:"missing expression "
call cm_test_prod([Param.1],[Param.2],?)
Error:"wrong number or types of arguments in call to 'CM_TEST_PROD'"
call cm_test_prod([Param.1],[Param.2],:var)
Error:"wrong number or types of arguments in call to 'CM_TEST_PROD' "
or
Error: "not all variables bound"
If I use without output parameter, in Command mode, It works fine.
call cm_test_prod([Param.1],[Param.2])
or
call cm_test_prod('[Param.1]','[Param.2]')
works without error.
SAP XMII: Version 12.0.5 Build(126)
Oracle 10G
Any help would be greatly appreciated.
Thanks,
Tunur.
Edited by: Namik Tunur on Dec 14, 2010 3:34 PM
Edited by: Namik Tunur on Dec 14, 2010 3:36 PMHi,
@Marcelo,
I used your package just by replacing 'varchar2' instead of 'varchar(100)''. I got the error message 'ORA-00900: invalid SQL statement'. I didn't understand how we handle output parameter with this:
Query = Call MYPKG.MyProcedure(1,'Test FixedQueryWithOutput',?)
What is Query in here? If we have two output parameters, how would we get the outputs?
My procedure is:
CREATE OR REPLACE
PROCEDURE XXXXX.CM_TEST_PROD_OUTPUT(v1 in number,v2 in number, v3 out number) IS
BEGIN
update test_table set no2 = (v1+v2);
commit;
v3 := v1+v2;
END;
declare
a number;
BEGIN
cm_test_prod_output(1,6,a);
END;
if I use this
call cm_test_prod_output([Param.1],[Param.2],?)
with FixedQueryWithOutput mode,
I get the following error:
ORA-06553: PLS-306: wrong number or types of arguments in call to 'CM_TEST_PROD_OUTPUT'
@Mike,
I already tried both with quotes and without quotes, also I tried both with number output and with string output.
As I mentioned before, if I use number inputs without output in Command mode,
call cm_test_prod(http://Param.1,http://Param.2)
or
call cm_test_prod('http://Param.1','http://Param.2')
works succesfully.
Regards,
Tunur -
Function Modue with Dynamic Table as output parameter
Hi experts,
i have function (below) which reads "dynamically" data from table which is specify as input parameter, the data are "saved" in <ft>.
How can i return <ft> as output parameter of function module (table) ?
function
import parameter - > IC_TABLE
source code
data : lt_OPTIONS type standard table of RFC_DB_OPT,
lt_fields type standard table of rfc_db_fld,
lt_data type standard table of tab512,
la_rfcdata type tab512,
la_rfcfields type rfc_db_fld,
lr_dref type ref to data.
field-symbols: <ft> type table.
field-symbols: <structure> type any.
field-symbols: <field_to> type any.
field-symbols: <field_from> type any.
CALL FUNCTION 'RFC_READ_TABLE'
EXPORTING
query_table = IC_TABLE
DELIMITER = ' '
NO_DATA = ' '
ROWSKIPS = 0
ROWCOUNT = 0
tables
OPTIONS = lt_OPTIONS
fields = lt_fields
data = lt_data
EXCEPTIONS
TABLE_NOT_AVAILABLE = 1
TABLE_WITHOUT_DATA = 2
OPTION_NOT_VALID = 3
FIELD_NOT_VALID = 4
NOT_AUTHORIZED = 5
DATA_BUFFER_EXCEEDED = 6
OTHERS = 7.
create data lr_dref type table of (ic_table).
assign lr_dref->* to <ft>.
Fill data from OLTP table into ct_table.
assign local copy of initial line of <ft> to <structure>.
loop at lt_data into la_rfcdata.
loop at lt_fields into la_rfcfields.
assign component sy-tabix of structure <structure> to <field_to>.
if sy-subrc is initial.
assign la_rfcdata+la_rfcfields-offset(la_rfcfields-length)
to <field_from>.
<field_to> = <field_from>.
endif.
endloop.
append <structure> to <ft>.
endloop.
Thanks in advance
MartinHi Martin,
parameters with generic types are not allowed. So TYPE ANY TABLE etc. will not work. As Alex alreads said, you could return a reference to your table.
Your parameter should be typed like:
re_table type ref to data.
At the end of your function module get a reference of your table into your parameter:
get reference of <ft> into re_table
After the call of your function module you can now handle and work with your table as wished:
* Declaration
data: re_table type ref to data.
field-symbols: <my_table> type standard table.
* Assign reference to fieldsymbol
assign re_table->* to <my_table>
if sy-subrc NE 0.
" Error: Could not assign reference
endif.
Best regards,
Fabian -
Help with Input/Output Parameter Size using OLE DB Provider
I am using the OLE DB Provider for 9i in an Active Server Page to call a stored procedure in a 9i database. I pass have an input/output parameter (adVarChar with adSize=30) in which I pass a two digit number in, and expect to get a character value greater than 2 characters in return. However, when I execute the stored procedure call, it appears the value being returned in the parameter is being truncated to the size of the value I passed in (2 characters). Is there a way I can insure the parameter will return the entire length of the result regardless of the length of the input value?
cmd.Parameters.Add("retstatus", OracleDbType.Varchar2, 200, ParameterDirection.InputOutput); It seems to me that you're trying to use an OracleParameter constructor with parameter name, parameter type, parameter SIZE, and parameter direction. But OracleParameter class does not have any such constructor. Therefore, your test tries to use another constructor incorrectly.
OracleParameter has two constructors with four parameter ...
public OracleParameter(string parameterName, OracleDbType type, object obj, ParameterDirection direction)
public OracleParameter(string parameterName, OracleDbType type, int size, string srcColumn)
... and none of these matches your constructor. One way to solve this problem is to use appropriate constructor or OracleParameter properties. -
Getting error while Calling Oracle Stored Procedure with output Parameter
HI All,
From long days i am working on this but i unable to solve it.
Even i have studied so many forums in SAP but i didn't find the solution.
I am calling Oracle Store procedure with 3 inputs and 1 output without cursor.
Store Procedure:-
CREATE OR REPLACE PROCEDURE PDS.send_rm
IS
proc_name VARCHAR2(64) := 'send_rm';
destination_system VARCHAR2(32) := 'RAWMAT';
xml_message VARCHAR2(4000);
status_code INTEGER;
status_message VARCHAR2(128);
debug_message VARCHAR2(128);
p_ret INTEGER;
BEGIN
DBMS_OUTPUT.PUT_LINE( proc_name || ' started' );
xml_message := '<RAW_MATERIAL>'||
'<BAR_CODE>10000764601</BAR_CODE>'||
'<MATERIAL>1101448</MATERIAL>'||
'<VENDOR_CODE/>'||
'<PRODUCTION_DATE>0000-00-00</PRODUCTION_DATE>'||
'<EXPIRE_DATE>0000-00-00</EXPIRE_DATE>'||
'<BATCH/>'||
'<PO_NUM/>'||
'<MATERIAL_DESCRIPTION>POWER SUPPLY</MATERIAL_DESCRIPTION>'||
'<SPEC_NAME/>'||
'<STOCK_CODE>BSW-JH</STOCK_CODE>'||
'<INSPECTION_LOT>00</INSPECTION_LOT>'||
'<USAGE_DECISION_CODE/>'||
'<MATERIAL_GROUP>031</MATERIAL_GROUP>'||
'</RAW_MATERIAL>';
dbms_output.put_line('XML '||xml_message);
-- vp_interface.load_rawmat@cnprpt1_pds(SYSDATE, destination_system,
-- xml_message, p_ret);
vp_interface.load_rawmat(SYSDATE, destination_system,
xml_message, p_ret);
dbms_output.put_line('Return Code '||p_ret);
COMMIT;
EXCEPTION
WHEN OTHERS THEN
status_code := SQLCODE;
status_message := SUBSTR(SQLERRM, 1, 64);
-- Extract_Error_Logger(proc_name, 'LOCAL', SYSDATE, -999,
-- status_message, 0, debug_message);
ROLLBACK;
END send_rm;
And while i am calling this Store procedure in MII, I am facing error.
I have tried different ways but didnt solved
In SQL Query, i kept mode as: FixedQueryOutput
Can anyone tell me or send code for calling above store procedure
And onemore thing, While creating store procedure in Oracle for MII. Do we need to Create output parameter as cursor or normal.
Thanks,
Kind Regards,
Praveen Reddy MHi Praveen
Our wrapper was created because we could not modify the procedure we call (it was not returning a cursor).
CREATE OR REPLACE PROCEDURE CHECK_PUT_IN_USE
(STRCMPNAME in varchar2,
STRSCANLABEL in varchar2,
RCT1 out SYS_REFCURSOR
AS
charDispo Char(1);
charStatus Char(1);
intCatNo Integer;
charCatDispo Char(1);
strCatQual VarChar2(2);
strCatDesc VarChar2(30);
strMsg VarChar2(128);
BEGIN
qa.check_put_in_use@AR(STRCMPNAME,
STRSCANLABEL,
charDispo,
charStatus,
intCatNo,
charCatDispo,
strCatQual,
strCatDesc,
strMsg);
OPEN RCT1
FOR Select charDispo,charStatus,charDispo,charStatus,intCatNo,charCatDispo,strCatQual,strCatDesc,strMsg from Dual;
END;
Hope this helps
Regards
Amrik
then with a FixedQueryWithOutput
call mixar.qasap.wrapper_update_put_in_use('[Param.1]','[Param.2]',[Param.3],?)
Hope this helps. -
Hash tables in combination with data references to the line type.
I'm having an issue with hash tables - in combination with reference variables.
Consider the following: (Which is part of a class) - it attempts to see if a particular id exists in a table; if not add it; if yes change it.
types: BEGIN OF TY_MEASUREMENT,
perfid TYPE zgz_perf_metric_id,
rtime TYPE zgz_perf_runtime,
execount TYPE zgz_perf_execount,
last_start TYPE timestampl,
END OF TY_MEASUREMENT.
METHOD START.
DATA: ls_measurement TYPE REF TO ty_measurement.
READ TABLE gt_measurements WITH TABLE KEY perfid = i_perfid reference into ls_measurement.
if sy-subrc <> 0.
"Didn't find it.
create data ls_measurement.
ls_measurement->perfid = i_perfid.
insert ls_measurement->* into gt_measurements.
endif.
GET TIME STAMP FIELD ls_measurements-last_start.
ls_measurement->execount = ls_measurement->execount + 1.
ENDMETHOD.
I get compile errors on the insert statement - either "You cannot use explicit index operations on tables with types HASHED TABLE" or "ANY TABLE". It is possible that.
If I don't dereference the type then I get the error LS_MEASUREMENT cannot be converted to the line type of GT_MEASUREMENTS.
I'm not looking to solve this with a combination of references and work ares - want a reference solution.
Thanks!
_Ryan
Moderator message - Moved to the correct forum
Edited by: Rob Burbank on Apr 22, 2010 4:43 PMI think it might work when you change it for
insert ls_measurement->* into TABLE gt_measurements.
For hashed table a new line here will be inserted according to given table key.
Regards
Marcin -
Output Type determination with BAPI call
Hello SAP experts,
Thank you in advance for any guidance or ideas you may have.
We are modifying an outbound delivery document with the following functions:
bapi_outb_delivery_change and ws_delivery_update
and we need to cause an outbound type to be determined(executed)
This process works when we post goods issue manually but does not work when we post goods issue via an ABAP program using the above mentioned functions
Sincerely,
JimHi,
For Output determination the condition technique has to be followed.
1) Maintain Output condition table -V/57
2)maintain Access sequence
3)Maintain Output condition type-V-30
4)Maintain Output determination procedure
5)Maintain condition records in VV11
Besides you should also assign the Output types to Partner function
Assign Output det.pro to sales document header & sales document type (eg: OR)-V/43
Assign Output det.pro to Item category-V/69
The condition types for Output in your case is BA00(standard).
Have you done all these ?
I hope this would be helpful for you.
Saplinx
Maybe you are looking for
-
How to delete the SC in the SRM by backend?
Hi Experts. We've faced a huge trouble. We're using the BBP_EXTREQ_TRANSFER program to transfer PR from r/3 backend to SRM. Its works fine. However when we need unrelease all items from the RC in the backend the data aren't not send to SRM. The SC st
-
Import시 character set 문제, OORA-01435, IMP-00008 에러에 의해 중단되었습니다. 조언을 부탁합니다.
안녕하세요, 아래와 같이 import를 하려고 하는데 에러가 나면서 중단되었습니다. C:\temp>imp userid=system/1234 file=c:\temp\usr_lms2-TS_LMS_DEV_D1.dmp FULL=y 에러메시지는 아래와 같습니다. 참고로, export 했던 어떤 database에는 usr_lms2 계정이 있었고, import하려는 이 database에는 그 계정이 없어서 usr_lms2 계정을 생성하고 import를 실행
-
Dues to the size of my default mailbox database I created two new mail box databases and moved (using EMC) the existing user mailboxes from the default mailbox into the two new ones (half in each new database). That left me with the Discovery Search
-
How to view hierarchy in reports
how to view hierarchy in reports
-
Time machine local snapshot restoring hangs
Interested in others experiances with restoring form a local snapshot. Mine fail. They cause finder to stall at "preparing to copy". I have tested by clearing the local snapshot and then letting my Macbook pro create a new one. Then tried to restore