Problems calling a stored procedure with DG4IFMX
Hi guys,.I try to call stored procedures of database Informix, which is connected by an Oracle for Informix database gateway.
I ran select, update, delete correctly but when I try to execute a stored procedure, that nothing is happening.
for example:
When I run
call branko"@link_informix (1) «»
It returns that it is performed successfully, without error, but as you can see below no entry is entered in the branko_test table
to informix:
drop the branko procedure;
Create procedure "informix".branko (integer _vlez)
returning a Boolean;
If _vlez = 1 then
insert into branko_test values ('uspesen test', '1');
on the other
insert into branko_test values ('test 2 ', 2' uspesen);
end if;
end of procedure;
the procedure runs ok when called to informix.
Thanks for any help
P.S I even tried running:
declare
Whole RET;
Start
RET: = DBMS_HS_PASSTHROUGH. EXECUTE_IMMEDIATE@link_informix (' branko procedure (2)');
end;
but the same thing happens, no entry in the branko_test table.
Find the root cause:
When you are using dbaccess to call the original procedure it displays on the screen (expression)
=> remove the return value as it is not managed
-> looks like not supported return Boolean value. Changes to the procedure of
drop the branko procedure;
Create procedure "informix".branko (integer _vlez)
If _vlez = 1 then
insert into branko_test values ('uspesen test', '1');
on the other
insert into branko_test values ('test 2 ', 2' uspesen);
end if;
end of procedure;
allows me to execute the procedure using passthrough
DECLARE
result VARCHAR2 (50);
BEGIN
result: = DBMS_HS_PASSTHROUGH. EXECUTE_IMMEDIATE@dg4ifmx (' run the informix.branko procedure (1)');
END;
/
Edited by: kgronau may 6, 2011 07:31
Tags: Database
Similar Questions
-
Problem call Oracle10g stored procedure (bug?)
Hello everyone, I'm trying to call a stored procedure Oracle on Oracle 10 g XE of Java.
I can successfully run the query to Java, so I can't tell what driver, connection,... are very good.
I have the following error when I try to call a stored procedure or a function.
I think it's a bug OraClient10.Dll file, so, in general, a bug that depends on my code. So I install the latest version of the JDK/JRE, and I download new folder OraClient10.Dll but the result was the same.
Please help me!
Thank you
Manti
#
# A fatal error has been detected by Java runtime environment:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc = 0x61d37460, pid = 3872, tid = 1224
#
# Version JRE: 6.0_16 - b01
# Java VM: Java hotspot Client VM (14: 2 - b01 mixed mode windows - x 86)
# Problematic frame:
# C [OraClient10.Dll + 0 x 117460]
#
# A file error with more information report is saved as:
[...]
#
# If you want to submit a bug report, please visit:
[...]
# The accident happened outside the Virtual Machine Java to native code.
# See problematic frame for where report them the bug.
#Why not just connect via thin mode of the driver, not the mode of the OIC?
You will get all the features and no risk of native code bug. -
How to call a stored procedure with a REF CURSOR output parameter
I'm looking forward to example calling a function/stored procedure with a REF CURSOR output parameter and get the result.
In other words, I have a stored function/procedure that runs a SELECT statement using the OCI library and then he could get the values of each row and each column.
I put a code snippet, it have only the main thing to call a simple stored procedure and to print the name of each column of the cursor, but I couldn t to print out values in the table that calls the stored procedure.
I understand that the next step is to call an OCIStmtFetch.
How to associate the slider with the OCIStmtFetch?
If you need more information, just tell me.
I use ANSI C with HP - UX (HP - UX C) operating system and Oracle 10 g.
Kind regards.
Antonio Garcia
/ * callOracleSP * /.
#include < stdio.h >
#include < string.h >
#include < oci.h >
#include < stdlib.h > to
char * pConnectChar = "Server";
char * pUsernameChar = "user";
char * pPasswordChar = "passwd";
char * sqlCharArray1 = "BEGIN SP_GETCITIES (:,: 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 ("retval=%d\n",retval OCILogon);
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 = 1 OCIBindByPos(pOciStatement,&pOciBind[0], pOciError, (ub4), (void *) & state_key,)
((sb4) sizeof (state_key), SQLT_STR, (void *) 0, (ub2 *) 0, (ub2 *) 0, (ub4) 0, (ub4 *) 0, OCI_DEFAULT (ub4));
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, OCI_DEFAULT (ub4));
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, OCI_DEFAULT (ub4));
printf ("StmtExecute retval=%d\n",retval);
/ * How to get the values of the cursor? */
/ * Number of parameters of the cursor * /.
OCIAttrGet ((void *) pOciStatCursor, OCI_HTYPE_STMT (ub4), (void *) & parmcnt,(ub4 *) 0,)
(ub4) (OCI_ATTR_PARAM_COUNT, pOciError);
printf ("\nNumber of the slider settings = %d\n",parmcnt);
for (int pos = 1; pos < = (int) parmcnt; pos ++)
{
OCIAttrGet ((void *) pOciStatCursor, OCI_HTYPE_STMT (ub4), (void *) & pos2,(ub4 *) 0,)
(ub4) (OCI_ATTR_CURRENT_POSITION, pOciError);
retval = OCIParamGet ((void *) pOciStatCursor, OCI_HTYPE_STMT (ub4), pOciError, (void *) & pOciParam,)
POS (ub4));
OCIAttrGet pOciParam, (ub4) ((void*) 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 ("%i\tNAME = % column. ("* 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 ('NEW YORK', 10, 'NEW YORK')
/
INSERT INTO CITIES (STATE_CODE, CITY_CODE, CITY_NAME)
VALUES ('NEW YORK', 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 is specific global variables T/SQL. */
TYPE RCT1 IS REF CURSOR; / * new cursor low definition * /.
END globalPkg;
/
CREATE OR REPLACE PROCEDURE SP_ADDCITY)
P_STATE_CODE IN VARCHAR,
P_CITY_CODE NUMBER,
P_CITY_NAME IN VARCHAR2,
P_RETURN IN NUMBERS)
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: = number of LINES SQL %;
EXCEPTION
WHEN TOO_MANY_ROWS THEN
StoO_rowcnt: = 2;
WHILE 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 FOR RC1
SELECT STATE_CODE, CITY_CODE, FRANCISCO
CITIES
WHERE STATE_CODE = STATE_KEY
ORDER BY CITY_CODE;
StoO_rowcnt: = number of LINES SQL %;
EXCEPTION
WHILE OTHERS THEN
StoO_rowcnt: = 0;
StoO_error: = SQLCODE;
StoO_errmsg: = SQLERRM;
END;
/Hi Antonio,.
I see this:
c_buf=(ub1 **)calloc(sizeof(ub1 *),3); ... 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);
That I don't understand. You allocate space for 3 pointers ub1 but I don't see where these pointers are then initialized to point to where the data is to be stored.
I do not read correctly?
Sorry for posting code long, but here is an example of code that I have. It is much more 'code' for your code, but maybe that will be enough...
NOTE: This is just the code example and not rigorous. For example, I don't check the memory, allocations etc in this code!
Kind regards
Mark
#ifdef WIN32 #define _CRT_SECURE_NO_DEPRECATE 1 #endif #include
#include #include #include void checkerr(sword status, OCIError *errhp); int main(int argc, char *argv[]) { OCIEnv *envhp = NULL; /* OCI Environment handle */ OCIError *errhp = NULL; /* OCI Error handle */ OCISvcCtx *svchp = NULL; /* OCI Service Context handle */ OCIServer *srvhp = NULL; /* OCI Server handle */ OCISession *usrhp = NULL; /* OCI User Session handle */ OCIStmt *stmtp = NULL; /* OCI Statement handle */ OCIStmt *cursr = NULL; /* OCI Statement handle */ OCIParam *prmp1 = NULL; /* OCI Parameter handle */ OCIParam *prmp2 = NULL; /* OCI Parameter handle */ OCIParam *prmp3 = NULL; /* OCI Parameter handle */ OCIDefine *defp1 = NULL; /* OCI Define handle */ OCIDefine *defp2 = NULL; /* OCI Define handle */ OCIDefine *defp3 = NULL; /* OCI Define handle */ OCIBind *bndp1 = NULL; /* OCI Bind handle */ OCIBind *bndp2 = NULL; /* OCI Bind handle */ OCIBind *bndp3 = NULL; /* OCI Bind handle */ /* used to hold column width */ ub2 col_width; /* used to set the prefetch count */ ub4 prefetch_count = 32; /* will hold output from database */ oratext *pEmpId = NULL; oratext *pFirstName = NULL; oratext *pLastName = NULL; /* the anonymous block to execute */ /* this opens a ref cursor */ oratext *sqlstmt = "begin " \ " open :1 for " \ " select to_char(employee_id), " \ " first_name, " \ " last_name " \ " from hr.employees " \ " order by last_name, " \ " first_name; " \ "end;"; /* used to hold the results of each OCI call */ sword result = 0; /* Initialize and create a default environment */ result = OCIEnvCreate(&envhp, OCI_DEFAULT, (dvoid *) 0, 0, 0, 0, (size_t) 0, (dvoid **) 0); /* allocate an error handle */ result = OCIHandleAlloc((dvoid *) envhp, (dvoid **) &errhp, OCI_HTYPE_ERROR, 0, (dvoid **) 0); /* allocate a service context handle */ result = OCIHandleAlloc((dvoid *) envhp, (dvoid **) &svchp, OCI_HTYPE_SVCCTX, 0, (dvoid **) 0); /* allocate a server handle */ result = OCIHandleAlloc((dvoid *) envhp, (dvoid **) &srvhp, OCI_HTYPE_SERVER, 0, (dvoid **) 0); /* allocate a user session handle */ result = OCIHandleAlloc((dvoid *) envhp, (dvoid **) &usrhp, OCI_HTYPE_SESSION, 0, (dvoid **) 0); /* create a server context using the "ORADEMO" database */ result = OCIServerAttach(srvhp, errhp, "ORADEMO", (ub4) strlen("ORADEMO"), OCI_DEFAULT); /* set the server attribute in the service context handle */ result = OCIAttrSet((dvoid *) svchp, OCI_HTYPE_SVCCTX, (dvoid *) srvhp, (ub4) 0, OCI_ATTR_SERVER, errhp); /* open the session with the database */ /* using external authentication */ result = OCISessionBegin(svchp, errhp, usrhp, OCI_CRED_EXT, OCI_DEFAULT); /* set the user session attribute in the service context handle */ result = OCIAttrSet((dvoid *) svchp, OCI_HTYPE_SVCCTX, (dvoid *) usrhp, (ub4) 0, OCI_ATTR_SESSION, errhp); /* allocate the statement handle */ result = OCIHandleAlloc((dvoid *) envhp, (dvoid **) &stmtp, OCI_HTYPE_STMT, 0, (dvoid **) 0); /* prepare the statement for execution */ result = OCIStmtPrepare(stmtp, errhp, sqlstmt, (ub4) strlen((char *) sqlstmt), OCI_NTV_SYNTAX, OCI_DEFAULT); /* allocate the handle for the ref cursor */ result = OCIHandleAlloc((dvoid *) envhp, (void **) &cursr, OCI_HTYPE_STMT, 0, NULL); /* bind the ref cursor parameter */ result = OCIBindByPos(stmtp, &bndp1, errhp, 1, &cursr, 0, SQLT_RSET, NULL, 0, NULL, 0, 0, OCI_DEFAULT); /* execute the statement */ result = OCIStmtExecute(svchp, stmtp, errhp, 1, 0, NULL, NULL, OCI_DEFAULT); /* get parameter descriptor for first column */ result = OCIParamGet((dvoid *) cursr, OCI_HTYPE_STMT, errhp, (dvoid **) &prmp1, (ub4) 1); /* get parameter descriptor for second column */ result = OCIParamGet((dvoid *) cursr, OCI_HTYPE_STMT, errhp, (dvoid **) &prmp2, (ub4) 2); /* get parameter descriptor for third column */ result = OCIParamGet((dvoid *) cursr, OCI_HTYPE_STMT, errhp, (dvoid **) &prmp3, (ub4) 3); /* get the first column width in characters */ result = OCIAttrGet((dvoid*) prmp1, (ub4) OCI_DTYPE_PARAM, (dvoid*) &col_width, (ub4 *) 0, (ub4) OCI_ATTR_DATA_SIZE, errhp); /* allocate memory to hold the result */ pEmpId = (oratext *) malloc(sizeof(oratext) * (col_width + 1)); /* define the first column in the results */ result = OCIDefineByPos(cursr, &defp1, errhp, 1, (dvoid *) pEmpId, (sword) col_width + 1, SQLT_STR, (dvoid *) NULL, (ub2 *) 0, (ub2 *) 0, OCI_DEFAULT); /* get the second column width in characters */ result = OCIAttrGet((dvoid*) prmp2, (ub4) OCI_DTYPE_PARAM, (dvoid*) &col_width, (ub4 *) 0, (ub4) OCI_ATTR_DATA_SIZE, errhp); /* allocate memory to hold the result */ pFirstName = (oratext *) malloc(sizeof(oratext) * (col_width + 1)); /* define the second column in the results */ result = OCIDefineByPos(cursr, &defp2, errhp, 2, (dvoid *) pFirstName, (sword) col_width + 1, SQLT_STR, (dvoid *) NULL, (ub2 *) 0, (ub2 *) 0, OCI_DEFAULT); /* get the third column width in characters */ result = OCIAttrGet((dvoid*) prmp3, (ub4) OCI_DTYPE_PARAM, (dvoid*) &col_width, (ub4 *) 0, (ub4) OCI_ATTR_DATA_SIZE, errhp); /* allocate memory to hold the result */ pLastName = (oratext *) malloc(sizeof(oratext) * (col_width + 1)); /* define the third column in the results */ result = OCIDefineByPos(cursr, &defp3, errhp, 3, (dvoid *) pLastName, (sword) col_width + 1, SQLT_STR, (dvoid *) NULL, (ub2 *) 0, (ub2 *) 0, OCI_DEFAULT); /* loop through and print the results */ while ((result = OCIStmtFetch(cursr, errhp, (ub4) 1, (ub2) OCI_FETCH_NEXT, (ub4) OCI_DEFAULT)) == OCI_SUCCESS) { printf("Employee ID: %s\n", pEmpId); printf(" First Name: %s\n", pFirstName); printf(" Last Name: %s\n\n", pLastName); } /* free allocated memory */ free(pEmpId); free(pFirstName); free(pLastName); pEmpId = NULL; pFirstName = NULL; pLastName = NULL; /* terminate the session with the database */ result = OCISessionEnd(svchp, errhp, usrhp, OCI_DEFAULT); /* detach from the server */ result = OCIServerDetach(srvhp, errhp, OCI_DEFAULT); /* deallocate the environment handle */ /* OCI will deallocate the child handles */ result = OCIHandleFree((dvoid *) envhp, OCI_HTYPE_ENV); return OCI_SUCCESS; } void checkerr(sword status, OCIError *errhp) { oratext errbuf[512]; sb4 errcode = 0; switch (status) { case OCI_SUCCESS: break; case OCI_ERROR: case OCI_SUCCESS_WITH_INFO: (void) OCIErrorGet((dvoid *) errhp, (ub4) 1, (oratext *) NULL, &errcode, errbuf, (ub4) sizeof(errbuf), OCI_HTYPE_ERROR); (void) printf("Error: %.*s\n", sizeof(errbuf), errbuf); break; case OCI_NEED_DATA: (void) printf("Error - OCI_NEED_DATA\n"); break; case OCI_NO_DATA: (void) printf("Error - OCI_NO_DATA\n"); break; case OCI_INVALID_HANDLE: (void) printf("Error - OCI_INVALID_HANDLE\n"); break; case OCI_STILL_EXECUTING: (void) printf("Error - OCI_STILL_EXECUTING\n"); break; case OCI_CONTINUE: (void) printf("Error - OCI_CONTINUE\n"); break; default: break; } } -
C# Oracle.DataAccess CommandType.StoredProcedure is OracleDbType. Date
I can't get my code to call an oracle procedure that has an order date.
I receive a System.FormatException occurred in Oracle.DataAccess.dll
I tried to assign the param. Value = DateTime and also tried assigning as a string formatted with no luck.
What is the magic formula, I need to call this function?
Here is a code snippet:
OracleCommand cmd = new OracleCommand();
cmd connection group appConn;.
cmd.CommandText = "mypackage.myprocedure";
cmd.CommandType = CommandType.StoredProcedure;
Param = new OracleParameter ("iDateParamter", OracleDbType.Date, ParameterDirection.Input);
Param. Value = "August 31, 2015."
Here are other formats I' tried... ved param. Value = myDateValue.ToString ("dd - MMM-yyyy"). ToUpper(); (/ / "MM/dd/yyyy"); 'YYYY-MM-dd'); "MM-dd-yyyy");
cmd. Parameters.Add (param);
BindByName. cmd = true;
cmd ExecuteNonQuery());
Shame on me..., you can close this message
It was not for the error on my date field, I had another parameter that has been attributed to a string instead of an integer.
For the record, this has worked well for me:
Param = new OracleParameter ("iActvyPerDate", OracleDbType.Date, ParameterDirection.Input);
Param. Value = li. ActvyPerDate.ToString ("dd-MMM-yyyy"). ToUpper();
-
How to call oracle stored procedure with hibernate
Hi all
I wrote the following stored procedure:
create or replace
PROCEDURE SP_GET_NUMBER (p_cursor sys_refcursor, departmentId in number, userId in number, documentTypeId number)
as
Enter the integer;
sqlScript varchar2 (60);
Start
sqlScript: = "select registrationnumber_seq.nextval from dual;
immediately run sqlScript in register;
dbms_output.put_line ('Nextval is: ' |) To_char (Regid));
insert into roketsanuser.registrationnumbers
(id, departmentid, documenttypeid, number, registrationstatus, status, updatedate, updateuserid, version)
values
(enter it, null, null, enter it, 0, 0, sysdate, 0, 0);
commit;
Open the p_cursor for
Select id
roketsanuser.registrationnumbers® systems
where reg.id = regid;
end;
And I define in the annotations in my entity class:
@Entity (name = "Number")
@Table (name = "REGISTRATIONNUMBERS")
@SequenceGenerator (name = "REGISTRATIONNUMBER_SEQ", sequenceName = "REGISTRATIONNUMBER_SEQ")
@org.hibernate.annotations.NamedNativeQuery (name = "SP_GET_NUMBER", query = "{call? "{= SP_GET_NUMBER (: departmentId,: userId,: documentTypeId)}"
Callable = true, readOnly = true, resultClass = RegistrationNumber.class)
@EntityListeners ({BaseEntityListener.class})
Number/public class extends BaseEntity
I call the query in my Dao class:
public number getNumberForIncomingPaperworkByStoredProcedure (EntityManager Manager, number number)
{
A session = (Session) manager.getDelegate ();
query org.hibernate.impl.SQLQueryImpl = (SQLQueryImpl) session.getNamedQuery ("SP_GET_NUMBER");
query.setParameter ("departmentId", ObjectUtil.isNotNull (registrationNumber.getDepartment ())? registrationNumber.getDepartment () .getId (): "");
query.setParameter ("userId", ObjectUtil.isNotNull (registrationNumber.getUser ())? registrationNumber.getUser () .getId (): "");
query.setParameter ("documentTypeId", ObjectUtil.isNotNull (registrationNumber.getDocumentType ())? registrationNumber.getDocumentType () .getId (): "");
Collection list = query.list ();
return new RegistrationNumber();
}
But when I run the application exception occurred:
< 01/02/2013 10:04:24 EET > < opinion > < Stdout > < BEA-000000 > < hibernation:
/ * name of SP_GET_NUMBER native SQL query * / {call? = SP_GET_NUMBER (?,?,?)} >
< 01/02/2013 10:04:27 EET > < opinion > < Stdout > < BEA-000000 > < 10:04:27, 811 ERROR [IncomingPaperworkMBean] EJB Exception:; nested exception is:
org.hibernate.exception.SQLGrammarException: could not execute the query. nested exception is: org.hibernate.exception.SQLGrammarException: could not execute the query >
This is perhaps the reason why, please help me?
Thanks in advanceMessage to research in syntax of:
@org.hibernate.annotations.NamedNativeQuery
It seems that following is a possible cause (but I'm not sure about this one):
Query = "{call?" "{= SP_GET_NUMBER (: departmentId,: userId,: documentTypeId)} '.
You can change this:
Query = "(?)". (= appeler SP_GET_NUMBER (: departmentId,: userId,: documentTypeId)) "...
or
Query = "(call SP_GET_NUMBER (: departmentId,: userId,: documentTypeId)).
and check if that helps...
You can take a look at:
https://Forum.Hibernate.org/viewtopic.php?p=2401604
HTH,
Bravo!
AJ -
call a stored procedure with OUT VARCHAR2 parameter fails
Hi all
I use the Oracle 11.2.0.1 version OLE DB provider. I have a simple stored procedure that contains a VARCHAR2 OUT parameter:
create or replace procedure TestOut (RESULT_CODE OUT VARCHAR2) is
Start
RESULT_CODE: = 'X '.
TestOut end;
The following c# code piece fails:
String ConnStr = "Provider = OraOLEDB.Oracle; User ID = test; Password = test; Data Source = sandbox; « ;
OleDbConnection Conn = new OleDbConnection (ConnStr);
Conn.Open ();
OleDbCommand Cmd new OleDbCommand();
Cmd.Connection = Conn;
OleDbParameter Param = Cmd.CreateParameter ();
Param.ParameterName = "RESULT_CODE ';
Param.Direction = System.Data.ParameterDirection.Output;
Param.OleDbType = OleDbType.BSTR;
Param.Size = 1;
Cmd.Parameters.Add (Param);
Cmd.CommandType = System.Data.CommandType.Text.
Cmd.CommandText = "{TESTOUT (?). CALL} ";
Cmd.ExecuteNonQuery ();
If the stored procedure is modified to contain an OUT parameter, the same code works, after you change the type of parameter to appropriate OleDBType (OleDbType.SmallInt).
What am I doing wrong when handling OUTPUT VARCHAR parameters? Y at - there any limitation on the types of parameters stored procedure using the Oracle OleDB provider?
Published by: user957565 on 1/Ago/2011 06:31I get an access violation, using 11202. What do you get?
In any case, it works fine for me using OleDbType.VarChar instead of OleDbType.BSTR.
Hope this helps, comments welcome.
Greg
-
Calling stored procedures with parameters with the database connectivity Toolkit
Hi all
I'm new to the forum and struggling to find a solution to a particular problem I have in this respect, using the LabVIEW Database Connectivity Toolkit on a project, I am currently working on my work. I have a database in which I tables and stored procedures with parameters. Some of these stored procedures have input, output and return parameters.
I tried to follow this example, but to no avail: http://digital.ni.com/public.nsf/allkb/07FD130746083E0686257300006326C4?OpenDocument
Such a stored procedure I am working on the implementation is named "dbo.getAllowablePNs", running "SELECT * from DeviceType" (DeviceType is the table). In this case, it requires no input parameter, it has an output parameter that generates the table [cluster] and has a return parameter that returns an integer value (status code for execution) to show if an error occurred. The DeviceType table has 3 columns; ID (PK, int not null), PN (nvarchar ((15), null) and NumMACAddresses (int, null).) I have surpassed many examples and I talk to the support OR try to implement this and similar procedures stored in LabVIEW but have not been successful. I am able to connect to the database with the VI of open connection without error, but spin in some confusion as a result of this step. I then try to use the VI of parameter query create to call the stored procedure and set the parameters. I guess I would then use the Set parameter value for each parameter that is connected to the entry of parameters on the previous query with parameters VI VI? I am also having some confusion during and after these steps as well. I would greatly appreciate advice or suggestions that anyone could have in this situation because I am not a SQL expert. Also, I would be happy to provide more information that might be useful.
Kind regards
Jon
Here's what I use to do this. I think I had to change him create parameterized query VI for him to work. There is a post on the forum about this somewhere.
-
Java - a stored procedure with call by result
Hi the Oracle community,
I'm looking for some example Code how to use a Java-Stored procedure with output parameters. Don't get me wrong. I don't want to call a procedure with the parameters Out of Java (there are many examples in this respect over there). I want to just implement the appeal of the concept of results in a Java-Stored procedure. A customer calls this procedure with certain parameters and the Java procedure will fill the. So my first question: is it possible? And my second Question: how to implement it?
Greetings.
I found a solution. It's very simple.
Just setting the parameters as java array (e.g., String() P1). The first value (P1 [0]) is the returned value.
Finally just contained JDeveloper in dialog box "Edit method Signature" the parametermode OUT.
The dialog box are entitled on the stored procedure in the dbexport file. You can read this
in Section 6, publishing Java Classes with call specifications-> defining the Modes parameter in
The Oracle database Java Developer's Guide.
-
Calling stored procedure with an input of DATE parameter
Hello. A question about the Date input parameters when you call a stored procedure.
I have a procedure that takes a DATE as input parameter. I would DATE this value to include a time element.
My Application Module method takes an input as a java.util.Date (myParamDate) parameter - that will preserve a time element (?).
However when I create the CallableStatement, I am trying to set the parameter using setDate like this (for the param 5):
I understand java.sql.Date does NOT include a time element. But setDate() only accepts a java.sql.Date so my parameter of the procedure ends with a zero time element.st = getDBTransaction().createCallableStatement("begin cs_my_pck.request_values(?,?,?,?,?,?,?,?); end;", 0); Connection myConn = st.getConnection(); ArrayDescriptor myArrDesc = ArrayDescriptor.createDescriptor("CS_FIELD_TABT", myConn); Array sqlParamNameArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramNames.toArray()); Array sqlParamValueArray = new oracle.sql.ARRAY(myArrDesc, myConn, paramValues.toArray()); Array sqlFilterNameArray = new oracle.sql.ARRAY(myArrDesc,myConn,filterNames.toArray()); st.setString(1, repType); st.setObject(2, sqlParamNameArray); st.setObject(3,sqlParamValueArray); st.setObject(4,sqlFilterNameArray); java.sql.Date myRepDate = new java.sql.Date(myParamDate.getTime()); st.setDate(5,myRepDate); System.out.println("Report Date = " + myRepDate.toString()); st.setString(6,repUser); st.setString(7,repAttach); // set out param st.registerOutParameter(8, Types.NUMERIC); st.execute();
How to call this procedure keeping the time element?
Thank you.It includes the time element, if you want more precision with time stamp.
http://docs.Oracle.com/javase/6/docs/API/Java/SQL/date.html
-
call the stored procedure to a pop up window problem
Hello
I use jdev 10g. with ADF BC.
I have a page jspx with a command button passing 2 parameters to a window popup using processScope. This window contains an entry form containing the parameters passed and 1 other inputText field. The user will enter a value for the inputText field and click the OK button. When you click this button, I need to pass the value entered by the user as well as the parms passed 2 to the AM that calls my stored procedure. The inputText field is defined as < af:inputText value = "#{bindings.workCode.inputValue}" which works very well but the parms passed show as null in the AM. "
How can I get these 2 parameters to pass to the AM?
Thank you!The following code prints null as well?
public void Oracle_Proc (String seqNo, String yrCode, String subdivided) {}
* System.out.println ("seqNum:" + getELValue("#{processScope.seqNum}")); *
* System.out.println ("yearCode:" + getELValue("#{processScope.yearCode}")); *CallableStatement cs = this.getDBTransaction () .createCallableStatement ("{call user. Oracle_Proc(:1,:2,:3)} ", 1);
try {}cs.setString (1, seqNo);
cs.setString (2, yrCode);
cs.setString (3, subdivided).
DSI Execute();} catch (SQLException e) {}
TODO
e.printStackTrace ();
}
}* public String getELValue (String expr) {*}
* FacesContext fc = FacesContext.getCurrentInstance (); *
* ValueBinding vb = fc.getApplication () .createValueBinding (expr); *
* return (String) vb.getValue (CF); **}*
-
How to call the stored procedure from javascript? (Google suggest, AJAX)
Hi I want to set up a text field so that it behaves like [Google Suggest | http://www.google.com/webhp?complete=1 & hl = en].
I read this post .
Now, I installed everything according to this document. But it simply doesn't. And I don't know why.
I think that problems can fall into the following three categories:
1. the text field and the page invoking the appropriate javascript?
2 - is the JavaScript call the stored procedure?
3. the stored procedure correctly returns the result formatted?
I'm assertive for 1 and 3, but I'm not sure 2. Because I don't know how if a stored procedure has been called? Is there a PL/SQL statement that I can query in SQL * more?
Also, I would like to know how to debug AJAX in the APEX. It involves a lot of things.
Finally, I used APEX 3.2 and Oracle XE. I can't find file dads.conf or marvel.conf. Is ' / apex / "the virtual directory for APEX?
Thank you very much!Buffalo,
I managed to make it work on XE with APEX 3.2!
It took more time than expected because my XE installation was still on an earlier version of the Apex and I had put it first...But that's what I did:
-in the ac.js file, I changed the path ' / apex / "and I added the ac.js file to my candidacy as a static file. So as you did.
-J' copied my request to the XE and copied my procedure on the schema that is related to my request
-J' gave to run anonymous rights my procedureNow at first, it did not work...
Then I suddenly remembered something: If you want to run a procedure through the pl/sql gateway in the XE, XE please how it is.
Do you this by changing the APEX_030200.wwv_flow_epg_include_mod_local function!This is the code for the function changed for my example:
CREATE OR REPLACE function APEX_030200.wwv_flow_epg_include_mod_local( procedure_name in varchar2) return boolean is begin --return false; -- remove this statement when you modify this function -- -- Administrator note: the procedure_name input parameter may be in the format: -- -- procedure -- schema.procedure -- package.procedure -- schema.package.procedure -- -- If the expected input parameter is a procedure name only, the IN list code shown below -- can be modified to itemize the expected procedure names. Otherwise you must parse the -- procedure_name parameter and replace the simple code below with code that will evaluate -- all of the cases listed above. -- if upper(procedure_name) in ( 'MATTHIASH.INCSEARCH') then return TRUE; else return FALSE; end if; end wwv_flow_epg_include_mod_local; /
After that, the AJAX function worked as expected...
HTH
Matthias HoysPublished by: mhoys on August 13, 2009 15:24
-
Hi Experts,
JDeveloper 12.1.3.0.0
I have a VO based on entity object. With a column of the VO is transient attribute (I created).
I need to call a stored procedure for each row in the transitional attribute and display the data in the form of af: table. As well as other attributes.
So can anyone suggest how can I achieve this?
Thank you
AR
I think that you need a stored function (which returns the value) in this case, is not?
Take a look at:
https://docs.Oracle.com/CD/B31017_01/Web.1013/b25947/bcadvgen005.htm
and search for:
Invoking stored function with only Arguments in
call your function in the Get attribute and return value accessor...
-
Call the stored procedure, and bind parameters by name
Hello
I use the Oracle ODBC 12 c driver to pass values from one Interface to our database Oracle 11.2. The Interface software collects data from modbus protocoll and calls a stored procedure. Right now my syntax to call the stored procedure looks like this:
CALL procedure-name ('STRING', 'Timestamp as String', numValue1);
It works very well. Now, I have to add a default setting to my procedure. To stay flexible to make other changes, I want to call the procedure and bind the parameters by name. Release 10.2.0.1.0 ISC ODBC Notes:
Added support for the named parameter, binding the parameters by name. ODBC Oracle driver now allows the application to specify the parameters of a stored procedure by name, in the procedure call. Named parameters are to be used in calls to stored procedures and should not be used in other SQL statements.
So, it shouldn't be a problem to use named notation, but how do I do this in ODBC? I tried like this, but oracle returns an ora-00936 error of missing expression:
call procedure-name (paramName1 = > 'STRING',= paramName2 > 'Timestamp as String',paramName3 = > numValue1).
Thank you for your help.
Finally, I was able to find the error. The syntax of the statement was very good. The problem was caused by another declaration that I edited before and the error has not attracted Attention immediately.
Thanks for reading and looking for an answer.
-
How to call a stored procedure PL/SQL of the Disqualification?
I figured I could do this from a Groovy script but I am unable to make it work.
Let's take the simplest scenario:
At the end of a job, I have a need to call an once stored procedure that has no arguments.
Translated by the logic of the stored procedure with Disqualification is not an option.
If you must call it once at the end of a task, you must use the external task.
If you call a procedure for each record, it can be done using a script.
-
Internal error: catalog view incompatible when calling a stored procedure
Hello
I use JDeveloper 11.1.1.4
When you call a stored procedure from AppModuleImpl, I get this error internal error: inconsistent display catalog
I'll call the stored procedure of this way
String lErrCode;
String lErrMsg;
Result of an integer;
ARRAY inputArray = null;
Table STRUCT that can be passed to a PLSQL PROCEDURE
inputArray =
JdbcSqlMapper.preparePlSqlArrayUsingVOAttrbs (conn, recordType,
view, rm);
OracleCallableStatement st =
(OracleCallableStatement) conn.prepareCall ("{?}") = call ("+
procedureName +.
"(?,?,?))}");
st.registerOutParameter (1, Types.INTEGER);
st.setObject (2, inputArray, OracleTypes.ARRAY);
st.registerOutParameter (2, OracleTypes.ARRAY,
recordType.getTableType ());
st.registerOutParameter (3, Types.VARCHAR);
st.registerOutParameter (4, Types.VARCHAR);
St.Execute ();
I checked the subsidies for this package to all users. All users with grants to this package.
I don't know where I start to debug this issue.
Kindly help.
Thank you and best regards,
John.
Have yo uchecked the right of the types of data used (at least the TABLE) to the user (referred to Pokusak blog: JPublisher - incompatible catalog display)?
Timo
Maybe you are looking for
-
After that the most recent iTunes updated, the ability to reset the counter to play songs seems to be missing. Is there a way to reset the counter of my songs?
-
my own experience of trying to use the fastboot tool I find it weird how after using OEM unlock on a xoom wifi which is normal retail version... which: 1 fastboot flash boot boot.img instantly, works very well 2. when I then try to make the next file
-
How can I remove a former spouse email addresses and my devices iCloud
is it possible to upload a screenshot of a problem
-
Scan chain with variable elements of number?
Hi all I wonder what would be a good way to parse a string containing a variable number of items to search for. I've seen comments of Roberto on the scan function that are very useful (link1, Link2). The string type, I would be sweeping would be "5 2
-
Error loading operating system - version of WHS disks
I have an old MSI k9 & AMD x 2 4600 + Im running WHS v1 (but I don't think it's a problem WHS). Moments ago, the server crashed (bad discs). First, the configuration of this system has always had a problem starting from cd/dvd player and always been