Executing DML-ing stored function from EntityManager

Hi,
Is there some way of getting the result from a DML-ing stored function from the EntityManager? I can use a native query and just select the function from dual if it doesn't do any DML but when it does, it is not permitted. I can't use getDelegate() to get the raw connection either :-/
Edited by: nickarls on Sep 25, 2007 2:19 AM
Edited by: nickarls on Sep 25, 2007 2:20 AM
Hmmm. the *** should be "ing". Probably looks like a curse

anyone, anyone?

Similar Messages

  • Calling database stored  function from Entity Object

    Hi,
    I want to call a database stored function from create() method of Entity Object.
    Database function returns some value.
    Can anybody suggest me some way to do it.

    You can try the following:
    make a String whit your function call, I dont know if this is the correct SQL syntax for a function, it should be for a stored procedure.
    String call = "begin; callyourfunction; end;"
    PreparedStatement ps = getDBTransaction().createPreparedStatement(call,0);
    ps.execute();
    ResultSet rs = ps.getResultSet();
    You can now read the data from the function from the rowset.
    Be sure to cleanup the PreparedStatement when your done whit it to avoid open database connections.
    ps.close();ps=null;

  • How to execute a HANA stored proc from Data Services

    Hi
    How do i execute a HANA stored procedure from Data Services.
    in the HANA SQL editor , we run the stored procedure "name_of_sp" as
    call name_of_sp ();
    call name_of_sp ( 1 , 2 ) // suppose 1 and 2 are two integer input parameters.
    so how do I call the above from Data Services .
    SQL('name_of_datastore', 'call name_of_sp()') does not seem to work , ,
    Rishi

    I got the answer , we dont need to import sp .
    i was just having a syntax error:
    the statement below works
    SQL('name_of_datastore', 'call name_of_sp()');

  • Execute a stored function from command line

    Hello,
    I have a db stored function and I need to execute it from command line. I've tried by this way:
    (I need to connect with sys credentials)
    sqlplus sys/mypwd@mydb AS SYSDBA @myfile.sql
    and myfile.sql is:
    exec myschema.sf_test;
    but I get this error:
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00221: 'sf_test' is not a procedure or is undefined
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored

    You can use exec command for the execution of a procedure with out bind variable, but for a function always use bind variable.
    Function should return a value, so you must have to assign the function return value to a variable.
    like given below(or simply query the function using select statement)
    Method 1
    ======
    variable v1 number;
    exec :v1 := t_func;
    Method 2
    ======
    declare
    x1 NUMBER;
    begin
    x1 := t_func;
    end;
    SQL> create function t_func return number
    2 as
    3 begin
    4 return 0;
    5 end;
    6 /
    Function created.
    SQL> exec t_func;
    BEGIN t_func; END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00221: 'T_FUNC' is not a procedure or is undefined
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Method 3
    ======
    SQL> select t_func from dual;
    T_FUNC
    0
    Regards
    JJ

  • Executing an Oracle Stored Procedure from Sender JDBC adapter

    I could really use some help from someone who had done this before. 
    I've read the help about using the JDBC sender adapter, but it's not helping enough.
    I found this line: "Specify an SQL EXECUTE statement to execute a stored procedure, which contains exactly one SELECT statement.
    The expression must correspond to the SQL variant supported by the relevant JDBC driver. It can also contain table JOINs."
    That's definately what we want to do, but we can't figure out the syntax.
    The procedure in oracle looks like this:
    CREATE OR REPLACE PROCEDURE test_ref_cursor
    ( cur_generic IN OUT result_sets.cur_generic)
    as
    BEGIN
    Open cur_generic for
    select
       proposal_number,
       to_char(sequence_number),
       column_name,
       column_value,
       update_timestamp,
       update_user
       from
       coeus.sap_test;
    END test_ref_cursor;
    And we have tried every kind of statement we can think of, but the file adapter always gives us an "invalid sql statement" error.
    Does anyone know what syntax we need to put in the "Query SQL Statement" in the JDBC sender adapter in order to call this procedure?  Or is there something wrong with the procedure that is causing the error?
    <i>I will absolutely return and give points, but PLEASE read my whole post before answering and do not just link me to or quote the help for configuring a sender JDBC adapter or blogs that are about the JDBC adapter in general but do not deal with the issues I am having. Thank you.</i>

    Hi Vanda,
    Unfortunately, the sender JDBC adapter does not support Oracle's store procedure/function.  Unlike stored procedures from other database vendors, Oracle returns a cursor, not a resultset.  The sender JDBC adapter must send a resultset to XI.
    There are 2 possible ways you can accomplish this:
    1.  Use BPM and call the Oracle stored procedure using a receiver adapter via a asynch-synch bridge.
    2.  Develop a user-module for the adapter, which can be used with a sender adapter.
    Thanks
    Prasad

  • Cannot call ANY stored functions from my Java program

    My problem is that I cannot call ANY stored procedure from my Java
    program. Here is the code for one of my stored procedures which runs
    very well in PL/SQL:
    PL/SQL code:
    CREATE OR REPLACE PACKAGE types AS
    TYPE cursorType IS REF CURSOR;
    END;
    CREATE OR REPLACE FUNCTION list_recs (id IN NUMBER)
    RETURN types.cursorType IS tracks_cursor types.cursorType;
    BEGIN
    OPEN tracks_cursor FOR
    SELECT * FROM accounts1
    WHERE id = row_number;
    RETURN tracks_cursor;
    END;
    variable c refcursor
    exec :c := list_recs(11)
    SQL> print c
    COLUMN1 A1 ROW_NUMBER
    rec_11 jacob 11
    rec_12 jacob 11
    rec_13 jacob 11
    rec_14 jacob 11
    rec_15 jacob 11
    Here is my Java code:
    import java.sql.*;
    import java.io.*;
    import oracle.jdbc.driver.*;
    class list_recs
    public static void main(String args[]) throws SQLException,
    IOException
    String query;
    CallableStatement cstmt = null;
    ResultSet cursor;
    // input parameters for the stored function
    String user_name = "jacob";
    // user name and password
    String user = "jnikom";
    String pass = "jnikom";
    DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
    try { Class.forName ("oracle.jdbc.driver.OracleDriver"); }
    catch (ClassNotFoundException e)
    { System.out.println("Could not load driver"); }
    Connection conn =
    DriverManager.getConnection (
    "jdbc:oracle:thin:@10.52.0.25:1521:bosdev",user,pass);
    try
    String sql = "{ ? = call list_recs(?) }";
    cstmt = conn.prepareCall(sql);
    // Use OracleTypes.CURSOR as the OUT parameter type
    cstmt.registerOutParameter(1, OracleTypes.CURSOR);
    String id = "11";
    cstmt.setInt(2, Integer.parseInt(id));
    // Execute the function and get the return object from the call
    cstmt.executeQuery();
    ResultSet rset = (ResultSet) cstmt.getObject(1);
    while (rset.next())
    System.out.print(rset.getString(1) + " ");
    System.out.print(rset.getString(2) + " ");
    System.out.println(rset.getString(3) + " ");
    catch (SQLException e)
    System.out.println("Could not call stored function");
    e.printStackTrace();
    return;
    finally
    cstmt.close();
    conn.close();
    System.out.println("Stored function was called");
    Here is how I run it, using Win2K and Oracle9 on Solaris:
    C:\Jacob\Work\Java\Test\Vaultus\Oracle9i\FunctionReturnsResultset>java
    list_recs
    Could not call stored function
    java.sql.SQLException: ORA-00600: internal error code, arguments:
    [ttcgcshnd-1], [0], [], [], [], [], [], []
    at
    oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:208)
    at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:543)
    at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1405)
    at oracle.jdbc.ttc7.TTC7Protocol.fetch(TTC7Protocol.java:889)
    at
    oracle.jdbc.driver.OracleStatement.<init>(OracleStatement.java:490)
    at
    oracle.jdbc.driver.OracleStatement.getCursorValue(OracleStatement.java:2661)
    at
    oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:4189)
    at
    oracle.jdbc.driver.OracleStatement.getObjectValue(OracleStatement.java:4123)
    at
    oracle.jdbc.driver.OracleCallableStatement.getObject(OracleCallableStatement.java:541)
    at list_recs.main(list_recs.java:42)
    C:\Jacob\Work\Java\Test\Vaultus\Oracle9i\FunctionReturnsResultset>
    Any help is greatly appreciated,
    Jacob Nikom

    Thank you for your suggestion.
    I tried it, but got the same result. I think the difference in the syntax is due to the Oracle versus SQL92 standard
    conformance. Your statament is the Oracle version and mine is the SQL92. I think both statements are acceptable
    by the Oracle.
    Regards,
    Jacob Nikom

  • Simple call to stored function from asp (vbscript) adodb

    please let me know if this question would be better suited to another forum.
    i am simply attempting to call an oracle stored function that returns a varchar2 from an asp vbscript page using adodb. i have calling of stored procedures working fine.
    attempting to call the function with the following code:
    set sp_aprvd_cr = Server.CreateObject("ADODB.Command")
    sp_aprvd_cr.ActiveConnection = MM_MHR_CONN_STR_STRING
    sp_aprvd_cr.CommandType = 4
    sp_aprvd_cr.CommandTimeout = 0
    sp_aprvd_cr.Prepared = true
    sp_aprvd_cr.CommandText = "PMS.sp_hpmsq054_aprvd_cr"
    sp_aprvd_cr.Parameters.Append sp_aprvd_cr.CreateParameter("IP_PMSPT_ID", 200, 1,10,sp_aprvd_cr__P_PMSPT_ID)
    sp_aprvd_cr.Parameters.Append sp_aprvd_cr.CreateParameter("return_param", adVarchar, adParamOutput)
    set rst_aprvd_cr = sp_aprvd_cr.Execute
    suspect that preparing the return code is where i am having troubles.
    any examples or assistance would be greatly appreciated.
    thanks in advance.

    Return value from stored function must be the first parameter in the parameters collection.
    So, try this instead,
    sp_aprvd_cr.Parameters.Append sp_aprvd_cr.CreateParameter("return_param", adVarchar, adParamOutput)
    sp_aprvd_cr.Parameters.Append sp_aprvd_cr.CreateParameter("IP_PMSPT_ID", 200, 1,10,sp_aprvd_cr__P_PMSPT_ID)Cheers,
    NH

  • Calling Stored Function from Excel

    Folks,
    Can someone help me with an Excel Macro that will call an Oracle stored function taking in parameter from one of the Excel Cell and return the value from the function into a different cell in the spreadsheet?
    Thanks

    This is not the right Forum for this query still here is something for you to start with
    The oracle function to add 1 to the input parameter
    create or replace function AddOne(ID Number) return number is
    Numout Number:=0;
    begin
    numout:=id+1;
    return numout;
    end;
    The Macro in Excel file to run the above function(Please add necessary references for ado connectivity)
    Option Explicit
    Dim Objconn As ADODB.Connection
    Sub Macro1()
    Dim StrSql As String
    Dim ObjRs As New ADODB.Recordset
    Dim I As Long
    StrSql = "Provider=OraOLEDB.Oracle.1;Password=swallocation;Persist Security Info=True;User ID=swallocation;Data Source=dumpdb"
    Set Objconn = New ADODB.Connection
    Objconn.Open StrSql
    For I = 2 To Sheet1.Rows.Count
    If Not CStr(Sheet1.Cells(I, 1)) = "" Then
    ObjRs.Open "select AddOne(" + CStr(Sheet1.Cells(I, 1)) + ") from dual", Objconn
    If Not ObjRs.EOF And Not ObjRs.BOF Then
    ObjRs.MoveFirst
    Sheet1.Cells(I, 2) = ObjRs(0).Value
    End If
    ObjRs.Close
    Else
    Exit For
    End If
    Next
    Set ObjRs = Nothing
    Objconn.Close
    Set Objconn = Nothing
    End Sub
    Hope you get something to start with
    Prakash...

  • Calling Stored Function from DOT NET

    Hi,
    I am trying to call a stored function "PKG_MIS_USER_MASTER.ADD_USER(userid varchar2, password varchar2) return NUMBER" from my DOT NET application.
    Everything works fine within TOAD. Can anyone please help me in writing the C# code for calling a stored function along with its return value.
    Thanks in Advance.

    You can (as of 15-JUL-2005) get chapter 5 and chapter 7 of my book from the ODP.NET homepage, which is located here:
    http://www.oracle.com/technology/tech/windows/odpnet/index.html
    The link is at the bottom of the page.
    The direct link is:
    http://www.oracle.com/technology/books/pdfs/dotnet_ch5_7.pdf
    Chapter 5 covers using PL/SQL from .NET.
    - Mark

  • Calling Stored Function from TopLink

    I have a simple Stored Function that I'm trying to call using TopLink API:
    TopLink Version: 10.1.3.3.
    Oracle JDBC Driver: ojdbc5.jar (Oracle JDBC Driver version - "11.1.0.6.0-Production+")
    Stored Procedure:
    Function Get_Email_Address_Id(P_EMAIL_ADDRESS IN varchar2) return number;
    TopLink Code:
    public String executeStoredFunction() {
    TopLinkTemplate tlTemplate = getTopLinkTemplate();
    StoredFunctionCall call = new StoredFunctionCall();
    call.setProcedureName("EMAIL_ADDRESS_PKG.Get_Email_Address_Id");
    call.setResult("FUNCTION_RESULT", String.class);
    call.addNamedArgument("P_EMAIL_ADDRESS");
    ValueReadQuery query = new ValueReadQuery();
    query.setCall(call);
    query.addArgument("P_EMAIL_ADDRESS");
    Vector parameters = new Vector();
    parameters.addElement("1009");
    String result = (String)tlTemplate.executeQuery(query, parameters.toArray());
    return result;
    Error I'm getting:
    Exception [TOPLINK-7121] (Oracle TopLink - 10g Release 3 (10.1.3.3.0) (Build 070428)): oracle.toplink.exceptions.ValidationException
    Exception Description: DatabasePlatform does not support stored functions
         at oracle.toplink.exceptions.ValidationException.platformDoesNotSupportStoredFunctions(ValidationException.java:1299)
         at oracle.toplink.queryframework.StoredFunctionCall.prepareInternal(StoredFunctionCall.java:52)
         at oracle.toplink.internal.databaseaccess.DatabaseCall.prepare(DatabaseCall.java:494)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.prepareCall(CallQueryMechanism.java:102)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.prepareExecuteSelect(CallQueryMechanism.java:203)
         at oracle.toplink.queryframework.DataReadQuery.prepare(DataReadQuery.java:150)
         at oracle.toplink.queryframework.DatabaseQuery.checkPrepare(DatabaseQuery.java:405)
         at oracle.toplink.queryframework.DatabaseQuery.checkPrepare(DatabaseQuery.java:375)
         at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:598)
         at oracle.toplink.queryframework.DataReadQuery.execute(DataReadQuery.java:96)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:2089)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:993)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:965)
    Observations:
    Why is TopLink complaining about DatabasePlatform?
    I'm using Oracle 10g as my database platform. Did anyone encounter this problem?
    I have tried various combinations but it always have same complaint.
    Thanks in advance for help.

    Hello,
    It is complaining because the DatabasePlatform being used doesn't support functions. So the problem is that it is using the DatabasePlatform instead of the Oracle10Platform that you are expecting. How have you defined it? Could you have multiple sessions.xml files, and the one that is being picked not define the Oracle10Platform? Or could you be overriding the login somehow (prelogin event etc) and setting it to use the default DatabasePlatform by accident?
    Best Regards,
    Chris

  • Running Stored functions from PHP

    Hi all,
    I cannot find any proper example in which it is detailed how to run an oracle stored function (or function within a package) from php.
    i.e. this is my function
    create or replace function myfunction return date is
    begin
    return sysdate;
    end myfunction;
    this is my php (but doesn't work)
    function OracleExecutefunction($pconnection){
    $sql = "declare v_date date; begin v_date:=myfunction; end;";
    $result = OCIParse($pconnection,$sql) or OracleProblem();
    OCIExecute($result, OCI_DEFAULT) or OracleProblem();
    return $result;
    This is what I get: Resource id #4
    I would appreciate any help or much better a working example.
    Cheers

    OK, i have it working now by doing the following:
    function OracleExecutefunction($pconnection){
    $sql = 'select myfunction mdate from dual';
    $result = OCIParse($pconnection,$sql) or OracleProblem();
    OCIExecute($result, OCI_DEFAULT) or OracleProblem();
    OCIFetch($result);
    #echo "My function=" . ociresult($result, "MDATE");
    return ociresult($result, "MDATE");
    Is there any other better way of doing it?
    Thanks

  • Execute more than 1 function from process code IDOC

    Hello,
    Is it possible to execute more than 1 function via process code of an IDOC?
    I am talking about inbound IDOC.
    Sara

    Hi Sara,
    What is the exact requirement.
    Regards,
    Madhu.

  • How to execute a procedure or function from Java Stored procedure

    Hi,
    I am new to Java Stored Procedures. I am working on Oracle 8i and JVM 1.3.1. I want to call a PL/SQL procedure from within Java. I have tried looking at severa; cources but they are quite high level for me. Can someone provide a simple example including the Source Code for .java file and also the calling function's code?
    Heres a sample of what I have been working on: I an including Java code, and Function code and how I call the function. Instead of doing "select sysdate from dual" I want to do like "create table temp1(var1 varchar2(10))" or similar... like "exec procname(var1)" etc.
    Thanks in advance.
    PS. The variable passed in function is just a dummy variable.
    -----Begin Java code-------
    import java.sql.SQLException;
    import java.sql.PreparedStatement;
    import java.sql.Statement;
    import java.sql.Connection;
    import java.sql.ResultSet;
    //Oracle Extensions to JDBC
    import oracle.jdbc.driver.OracleDriver;
    public class Test2{
    public static String Testing(String d) {
    Connection connection = null; // Database connection object
    try {
    // Get a Default Database Connection using Server Side JDBC Driver.
    // Note : This class will be loaded on the Database Server and hence use a
    // Se[i]Long postings are being truncated to ~1 kB at this time.

    what your after is
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:oci:@<hoststring>", "scott", "tiger");
    CallableStatement cs = conn.prepareCall ("begin ? := foo(?); end;");
    cs.registerOutParameter(1,Types.CHAR);
    cs.setString(2, "aa");
    cs.executeUpdate();
    String result = cs.getString(1);
    a more complete description can be found in the documentation at
    http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm#1001934
    Dom

  • ORA-29531 when i execute a java stored function

    I get the following error when i tried to execute java stored procedure
    ORA-29531: no method secondConcat in class secondProcedure
    The code below will explain my problem clearly
    Java Class:(secondProcedure)
    import java.lang.*;
    public class secondProcedure
    public static String secondConcat(String inStr1, String inStr2, String outStr)
    System.out.println("Calling secondProcedure.secondConcat\n");
    outStr = inStr1 + inStr2;
    String retStr = outStr;
    return retStr;
    Database Function:(fn_sec_concat)
    FUNCTION fn_sec_concat(Str1 IN VARCHAR2, Str2 IN VARCHAR2, Str3 OUT VARCHAR2)
    RETURN VARCHAR2
    AS LANGUAGE JAVA
    NAME 'secondProcedure.secondConcat(java.lang.String, java.lang.String, java.lang.String[])
    return java.lang.String';
    I used loadjava utility to load the java class into database which went fine.
    I searched for the error message on the web, & i response i got from everywhere is to add the static attribute to method, which was already there in my code.
    Please help!
    null

    I get the following error when i tried to execute java stored procedure
    ORA-29531: no method secondConcat in class secondProcedure
    The code below will explain my problem clearly
    Java Class:(secondProcedure)
    import java.lang.*;
    public class secondProcedure
    public static String secondConcat(String inStr1, String inStr2, String outStr)
    System.out.println("Calling secondProcedure.secondConcat\n");
    outStr = inStr1 + inStr2;
    String retStr = outStr;
    return retStr;
    Database Function:(fn_sec_concat)
    FUNCTION fn_sec_concat(Str1 IN VARCHAR2, Str2 IN VARCHAR2, Str3 OUT VARCHAR2)
    RETURN VARCHAR2
    AS LANGUAGE JAVA
    NAME 'secondProcedure.secondConcat(java.lang.String, java.lang.String, java.lang.String[])
    return java.lang.String';
    I used loadjava utility to load the java class into database which went fine.
    I searched for the error message on the web, & i response i got from everywhere is to add the static attribute to method, which was already there in my code.
    Please help!
    null

  • Problem executing a Java Stored Procedure from Forms6i

    I'm executing a Stored Procedure which invokes a Java Stored procedure.Till the invoking it works fine but for accessing a particular class it gives an error:
    PDE-PLU022 Don't have access to the stored program unit XMLPARSERCOVER in schema CARE
    where care is the schema name....
    Please assist me for this...

    hi Jignesh
    Maybe you can find some useful information in:
    "Oracle Database Java Developer's Guide"
    http://download-west.oracle.com/docs/cd/B14117_01/java.101/b12021.pdf
    success
    Jan Vervecken

Maybe you are looking for

  • Question on BPEL Process Performance

    Hello, We have a BPEL process reading the datafile through file adapter and upserting into DB using DB Adapter. Our requirement is If there are 10 records to process and two records (record 5 and 9) fail while inserting/updating for some reason(i.e d

  • UNABLE TO IMPORT TRANSPORT INTO QA system.

    I am trying to load Transport Request (Customizing) from DEV to QAS. The Request has been released in DEV system using SE10, But the released request is not showing up in QAS queue. I have performed all 3 test (TP, Transport Directory etc) , and it d

  • ABAP Webdynpro ADOBE interactive form

    Hi All, I have a problem when reading attachments from online adobe interactive form in Webdynpro ABAP. I have tried two options: Option1: Get FP reference. l_fp = cl_fp=>get_reference( ). try. Create PDF Object. l_pdfobj = l_fp->create_pdf_object( c

  • In time capsule, can ethernet ports used for windows pc as a LAN?

    in time capsule, can ethernet ports used for windows pc as a LAN?

  • Query taking too long to execute on Oracle 9i

    Mark, If you remember, I was working on a large xml document with deep nested complex elements. I am trying to query the document and as such I am running a join query. The database is not able to run this query and I am wondering if there is any alt