Calling an Oracle Function

Hi,
i'm trying to call a Function from a BPEL Process
I have the following TYPE on the Oracle DB
BALANCETYPE AS OBJECT
     "ACCT_EXT_ID" VARCHAR2(144),
     "TRANS_TYPE" VARCHAR2(240),
     "TRANS_REFERENCE" VARCHAR2(180),
"FROM_DATE" VARCHAR2(15),
     "TO_DATE" VARCHAR2(15),
     "STATEMENT_DATE" VARCHAR2(15),
     "PAYMENT_DUE_DATE" VARCHAR2(15),
     "DEBIT_AMOUNT" NUMBER(18,4),
     "CREDIT_AMOUNT" NUMBER(18,4),
     "AMOUNT" NUMBER(18,4),
     "BALANCE_AMOUNT" NUMBER(18,4),
     "ORIG_TRANS_REF" VARCHAR2(180),
     "PAYMENT_TRACKING_ID" NUMBER(10,0)
I have a convertion function
create or replace FUNCTION fnc_convertBalance (cbalance SYS_REFCURSOR,collname VARCHAR2,objname VARCHAR2) RETURN BALANCE
AS
     LANGUAGE JAVA
     NAME 'ResultSetConverter.convert(java.sql.ResultSet, java.lang.String, java.lang.String) return java.sql.Array';
And i have a my own function that calls the original SP
FUNCTION bpm_art_rpt_account_balance(v_nif IN VARCHAR2,
v_phone IN VARCHAR2,
v_acct_ext_id IN VARCHAR2,
v_acct_no IN NUMERIC,
v_invoice_ref IN VARCHAR2)
RETURN BALANCE
IS
     cursor_billing SYS_REFCURSOR;
     balanceobjct BALANCE := NULL;
BEGIN
     art_rpt_account_balance(v_nif,v_phone,v_acct_ext_id,v_acct_no,v_invoice_ref,cursor_billing);
     balanceobjct := fnc_convertBalance(cursor_billing, 'BALANCE','BALANCETYPE');
return balanceobjct;
END bpm_art_rpt_account_balance;
When i call this function from the Oracle DB with a DB GUI everything works fine, but when i call it from a BPEL Process i get the following error
ORA-00932: inconsistent datatypes: expected OUT Conversion failed� got ORA-06512: at "ARBOR.FNC_CONVERTBALANCE", line 0 ORA-06512: at "ARBOR.BPM_ART_RPT_ACCOUNT_BALANCE", line 12 ORA-06512: at line 1
Any ideas ?
Thanks

Note that ResultSetConverter.convert(java.sql.ResultSet, java.lang.String, java.lang.String) returns a java.sql.Array. I don't know what BALANCE is (you left out its definition), but it appears to be a single object (i.e. a java.sql.Struct), which is wrong. The purpose of the ResultSetConverter API is to convert a Ref Cursor into something the adapter can handle (i.e. a java.sql.Array), which you may then use to process the array elements.

Similar Messages

  • OTL call for oracle function

    Hi,
    I created a Oracle function like get_employee_id() which will return the employee id if the name and department exists.
    If not exists it will insert the record and return the emp_id.
    get_employee_id(name,department)
    if name and department exists id will be returned
    else record will be inserted and emp id will be returned.
    emp_id is a sequence which will be triggered to auto increment.
    Problem is::
    Not getting a correct way to access get_employee_id() from OTL interface.
    I am trying like
    query << "BEGIN :3<int> := get_employee_id(:1<char[128]>,:2<char[1024]>); END;" ;
    otl_stream oos(1, query.str().c_str(), db());
    oos << emp_name ;
    oos << emp_dept ;
    while(true){
    oos >> emp_id ;
    if(!oos) break ;
    Please let me know what is the correct way of accessing this.Thanks for the help in advance.
    Edited by: jagdish1206 on Nov 6, 2012 3:21 AM

    Sorry. I posted this in wrong Forum.
    Posted in "C++ Call Interface (OCCI) : forum".
    Thanks,
    Jagdish.

  • Calling an Oracle function of BOOLEAN return type

    I am facing a situation, where I have defined an overloaded function in one package (2 variants) which both return a type BOOLAN value under Oracle 9i R1.
    I am having trouble to setting up an CallableStatemnt to call one of this functions from Java. Whenever I set the parameter with a BIT or NUMBER data type, I get an exception with java.lang.boolean during my
    callablestatement.setobject( index, parameter, OracleTypes.BIT );
    or
    callablestatement.setobject( index, parameter, OracleTypes.NUMBER );
    I have no problem calling the function from SQLPlus, but doing so from Java raises the exception. I have found no exact match in OracleTypes or java.sql.Types for a BOOLEAN data type.
    In your response do you mean to modify the Function to return a NUMBER instead of a BOOLEAN, or do you mean to set the parameter as Types.NUMBER in the calling java code?
    Thanks,
    Fedro

    look at BOOLEAN type mapping using JPublisher
    http://otn.oracle.com/docs/products/oracle9i/doc_library/release2/java.920/a96658.pdf

  • Call a Oracle function in a JSP

    Hello sir,
    Is there a way to call a function written in Oracle to be called in a JSP?
    Krish Reddy

    try your luck at here...
    http://www.dbforums.com/showthread.php?t=653256

  • Oracle Function call from JDBC Adapter

    Hi,
      Is it possible to call Custom Oracle Function from JDBC Adapter? 
    I know we can call stored procedure but I need to call Oracle function. Please explain how?
    Regards,
    Shweta.

    You'll need to provide a column alias for the function call:
    select func(val) as alias from dual

  • Calling Oracle Function in PHP

    Hi,
    I'm calling a oracle function in php, the function has 1 IN parameter and 1 OUT parameter. The OUT parameter is BOOLEAN type.How to bind php variable for BOOLEAN type?
    Thanks.
    srinath.

    I think you're going to have to use it as a string and use string comparison.
    ~Jer

  • Problem calling Oracle function from Access 2007 / ADO

    Hopefully, I'm posting this in the correct forum. I'm also posting on an Access forum as I'm not entirely sure where the issue lies.
    I'm calling an Oracle function from Access 2007 using an ADO Command object.
    The function takes three input parameters and has a return value and an output parameter. The output parameter is a BLOB, and the return value is varchar2 (either "T" or "N") based on the outcome of the function.
    If I pass correct values to the function, I get the following error message (errs out on the command.execute line):
    Run-time error '-2147467259 (80004005)':
    [Oracle][ODBC][Ora]ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at line 1
    Here's the function:
    FUNCTION GET_ITEMREV_ATTACH(P_ORGANIZATION_ID IN NUMBER,
    P_INVENTORY_ITEM_ID IN NUMBER,
    P_REVISION IN VARCHAR2,
    X_DRAWING OUT BLOB) RETURN VARCHAR2 IS
    RESULT VARCHAR2(1);
    BEGIN
    RESULT := 'T';
    BEGIN
    SELECT L.FILE_DATA
    INTO X_DRAWING
    FROM FND_ATTACHED_DOCUMENTS AD,
    MTL_ITEM_REVISIONS_B IR,
    FND_DOCUMENTS_TL D,
    FND_LOBS L
    WHERE AD.ENTITY_NAME = 'MTL_ITEM_REVISIONS' AND
    AD.PK1_VALUE = IR.ORGANIZATION_ID AND
    AD.PK2_VALUE = IR.INVENTORY_ITEM_ID AND
    AD.PK3_VALUE = IR.REVISION_ID AND
    AD.CATEGORY_ID = 1001216 AND
    D.DOCUMENT_ID = AD.DOCUMENT_ID AND
    D.LANGUAGE = 'US' AND
    L.FILE_ID = D.MEDIA_ID AND
    IR.ORGANIZATION_ID = P_ORGANIZATION_ID AND
    IR.INVENTORY_ITEM_ID = P_INVENTORY_ITEM_ID AND
    IR.REVISION = P_REVISION;
    EXCEPTION
    WHEN OTHERS THEN
    RESULT := 'N';
    END;
    RETURN(RESULT);
    END GET_ITEMREV_ATTACH;
    Here's the VB code I'm using to call the function:
    Private Sub Command8_Click()
    Dim CMD As New ADODB.Command
    Dim conn As ADODB.Connection
    Dim Param1 As ADODB.Parameter
    Dim Param2 As ADODB.Parameter
    Dim Param3 As ADODB.Parameter
    Dim ParamBlob As ADODB.Parameter
    Dim ParamReturn As ADODB.Parameter
    Set conn = New ADODB.Connection
    With conn
    .ConnectionString = "Driver={Oracle in OraHome92};Dbq=OAPLY;UID=***;PWD=*******"
    .CursorLocation = adUseClient
    .Open
    End With
    Set CMD = New ADODB.Command
    Set CMD.ActiveConnection = conn
    CMD.CommandText = "immi_attach_pub.get_itemrev_attach"
    CMD.CommandType = adCmdStoredProc
    Set ParamReturn = CMD.CreateParameter("RESULT", adVarChar, adParamReturnValue, 1)
    CMD.Parameters.Append ParamReturn
    Set Param1 = CMD.CreateParameter("P_ORGANIZATION_ID", adInteger, adParamInput, 1, 6)
    CMD.Parameters.Append Param1
    Set Param2 = CMD.CreateParameter("P_INVENTORY_ITEM_ID", adInteger, adParamInput, 4, 5207)
    CMD.Parameters.Append Param2
    Set Param3 = CMD.CreateParameter("P_REVISION", adVarChar, adParamInput, 2, "04")
    CMD.Parameters.Append Param3
    Set ParamBlob = CMD.CreateParameter("X_DRAWING", adLongVarBinary, adParamOutput, 200000)
    CMD.Parameters.Append ParamBlob
    CMD.Execute , , adExecuteNoRecords *** this is where the error occurs
    conn.Close
    MsgBox CMD.Parameters("RESULT")
    End Sub
    I've tried using different data types for the varchar2 parameters (adVarChar, adBSTR, adChar) with no difference.
    If I pass a bogus value for Param3...."'04'"...the function returns "N" indicating that it actually executed something. But, when I pass the correct value "04", it returns the above mentioned error.
    I can execute the function in PL/SQL just fine, so I'm thinking there's something wrong with the parameters, datatype, or other definitions on the Access side.
    Does anyone have any thoughts? I'm at a dead end with this. Sorry for the long post. Thank you.

    I tried your code with 11107 ODBC/client/database (but with a NULL output blob for convenience sake) and got no errors.
    If you're using 92 ODBC/client, you may want to try upgrading to something more current, or at least getting the latest patch(9208) to see if that helps. Since it works for me I'm guessing it may be a resolved bug in that version.
    Hope it helps,
    Greg

  • Calling ORACLE Functions from within CF Builder report

    Hi, I have an ORACLE function that I would like to call from within my CF REPORT.
    I know there is a section in the report builder where you can write coldfusion code to perform tasks, but I would rather simply call the ORACLE function for each detail row in the report
    I do not want to call this function from within my main ORACLE query that I use for the report, so please don't suggest that.
    Thanks so much.
    -Jim

    6.0.5 is not certified against 10g database, so I suggest to upgrade to 6.0.8.26 (6i patch 17) first to see if the problem is gone.

  • Hibernate: Oracle function call

    Hi,
    I want to call a oracle function through Hibernate.
    Can you please tell me steps how i can achieve the same.
    What ever i have read, i am mentioning below. Please let me if i am wrong
    1. Create a class TestFunction.java having getter setter methods
    2. Create TestFunction.hbm.xml which will be having following code
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE hibernate-mapping PUBLIC    "-//Hibernate/Hibernate Mapping DTD 3.0//EN"     "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
    <hibernate-mapping>   
    <sql-query name="callFunction" callable="true">     
    <return class="TestFunction">               
    </return>     
    { call TestFunctionSQL(?,   :Name, :Age) } 
    </sql-query>
    </hibernate-mapping>I just copy pasted the code from some website and modified as per my need. Please let me know if anything is wrong above.
    3. I need to put the entry of TestFunction.hbm.xml in hibernate-cfg.xml
    4. I need to put the code in java to call teh stored proc. I dont have any idea how to do that.
    Please help
    ~Aman

    Before beginning : sorry if my answer isn't relevant but you asked no clear question
    I don't know a lot about it, even if all looks fine to me...
    the way to call a named query in hibernate is:
    List l =session.getNamedQuery("callFunction")
        .setString("param1", param1)
        .setString("param2, param2)
        .setMaxResults(50)
        .list(); // named parameters are betterSEE: http://www.hibernate.org/hib_docs/v3/reference/en/html/querysql.html
    specially $16.2 and $16.2.2
    //extract
    For Oracle the following rules apply:
    * A function must return a result set. The first parameter of a procedure must be an OUT that returns a result set. This is done by using a SYS_REFCURSOR type in Oracle 9 or 10. In Oracle you need to define a REF CURSOR type, see Oracle literature.

  • Call Oracle function using PI

    Can we call a Oracle function using PI? If yes then what should be the structure i.e. shoule that be built like a select ? or SQL_DML or ? Stored Procudure ?
    Sample structure with example will help

    Sure, is possible. You can use an JDBC Adapter (receiver or sender type).
    Take a look here:
    JDBC ADAPTER
    http://help.sap.com/saphelp_nw04/helpdata/en/22/b4d13b633f7748b4d34f3191529946/content.htm
    JDBC RECEIVER
    http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/content.htm
    JDBC MESSAGE FORMAT
    http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
    The option to use is an your chose, in according to your requirement.
    Usually, I use a StoredProcedure, except for very simple requirements.

  • RoR Calling Oracle Function/Procedure

    Hello,
    Has anyone got experience of calling an Oracle Function or Procedure from RoR?
    thanks
    David

    Hello for calling function/procedure at RoR in Oracle I write muself classes and use they.
    Module:
    module SQLStatement
    class NoTypeResult < StandardError
    end # class
    class SQLProc
    attr_accessor :name, :arguments
    def initialize( args = nil )
    @name = args[:name] unless args[:name].nil?
    @arguments = args[:arguments] unless args[:arguments].nil?
    @conn = ActiveRecord::Base.connection.raw_connection
    end # def initialize
    def exec( args = nil )
    unless args.nil? || ( !args.is_a? Hash )
    args.each { |k, v| @arguments[k.to_s.intern] = args[k] }
    end # unless
    func_args = ''
    @arguments.each { |k, v| func_args += "#{func_args == '' ? '' : ', '}#{k.to_s} => :#{k.to_s}"}
    sql = "BEGIN {#@name}( #{func_args} );END;"
    cursor = @conn.parse( sql )
    @arguments.each do |k, v|
    cursor.bind_param( ":#{k.to_s}", v )
    end # each
    cursor.exec()
    end # def exec
    end # class SQLProc
    class SQLFunc < SQLProc
    attr_reader :result
    attr_accessor :result_type
    def initialize( args = nil )
    @result_type = args[:result_type] unless args[:result_type].nil?
    super( args )
    end # def
    def exec( args = nil )
    if @result_type.nil?
    raise NoTypeResult, 'No type for result setting', caller
    end # if
    unless args.nil? || ( !args.is_a? Hash )
    args.each { |k, v| @arguments[k.to_s.intern] = args[k] }
    end # unless
    func_args = ''
    @arguments.each { |k, v| func_args += "#{func_args == '' ? '' : ', '}#{k.to_s} => :#{k.to_s}"}
    sql = "BEGIN :result := #{@name}( #{func_args} );END;"
    cursor = @conn.parse( sql )
    @arguments.each do |k, v|
    cursor.bind_param( ":#{k.to_s}", v )
    end # each
    cursor.bind_param( ":result", nil, @result_type )
    cursor.exec()
    @result = cursor[':result']
    cursor
    end # def exec
    end # class
    end # module SQLStatment
    Example of use:
    function = SQLStatement::SQLFunc.new(
    :name => 'f_test_ins',
    :result_type => Fixnum,
    :arguments => {
    :login =>'asdf',
    :password => 'asdf',
    :email => '[email protected]'
    function.exec
    raise function.result.inspect

  • Call Oracle function from Stored Procedure

    Hi,
    I have function Which returning one number. I want to use that number in a procedure. How to call the Oracle Function from the Procedure
    Create procedure
    AS
    Begin
    Check number;
    Select Function1 into check from dual;
    It is giving error.
    Can anyone provide me example for this.
    Thanks in advance

    Put the Check Number; before begin
    SQL> create or replace procedure abc as
      2 begin
    3 val number;
      4  select abcd into val from dual;
      5  dbms_output.put_line(val);
      6  end;
      7  /
    Warning: Procedure created with compilation errors.
    Elapsed: 00:00:00.00
    SQL> show error
    Errors for PROCEDURE ABC:
    LINE/COL ERROR
    3/5      PLS-00103: Encountered the symbol "NUMBER" when expecting one of
             the following:
             := . ( @ % ;
             The symbol ":=" was substituted for "NUMBER" to continue.
    SQL> create or replace procedure abc as
      2 val number;
    3 begin
      4  select abcd into val from dual;
      5  dbms_output.put_line(val);
      6  end;
      7  /
    Procedure created.
    Elapsed: 00:00:00.00
    SQL> exec abc;
    100.22
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    SQL>

  • Invoking oracle function thru JDBC Receiver.

    Hi Crew,
    I have a scenario in which JDBC receiver have to call a Oracle function. Can somebody help me deriving out JDBC sender Data type definition format?
    Thanks in Advance
    Karthik Kaveriselvan.

    Hi
    /people/siva.maranani/blog/2005/09/16/xi-how-to-on-jdbc-receiver-response
    /people/jegathees.waran/blog/2007/03/02/oracle-table-functions-and-jdbc-sender-adapter
    /people/bhavesh.kantilal/blog/2006/07/03/jdbc-receiver-adapter--synchronous-select-150-step-by-step
    http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/frameset.htm
    Thanks

  • XML Error while calling webservice from oracle function.

    I am getting an error while I am trying to call webservice from oracle function. Any ideas? Thanks.
    select get_new_string ('proxy:80', 'http://xxx/PatternVariations/SourceTest/WebMethods','Scott') from dual
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00225: end-element tag "H4" does not match start-element tag "P"
    Error at line 9
    ORA-06512: at "SYS.XMLTYPE", line 0
    ORA-06512: at "DORSBP00.DEMO_SOAP", line 82
    ORA-06512: at "DORSBP00.GET_NEW_STRING", line 11

    The error message implies that the web service is returning something that is not well formed xml. Can you verify what is being returned by the web service call

  • PHP- Oracle not working- Call to undefined function OCILogon() ERROR

    Hi,
    I am trying to just do a test program to test php - oracle connection,
    My versions are: php5.2.1-Win32 and Oracle 10g
    I have made the following settings:
    1.) Uncommented the following lines in php.ini:
    extension=php_oci8.dll
    extension=php_oracle.dll
    2.) Set extension_dir = "C:\php-5.2.1-Win32\ext"
    Changed the httpd.conf file as: ADDED
    1.)LoadModule php5_module C:/php-5.2.1-Win32/php5apache2.dll
    2.)PHPIniDir "C:/Program Files/Apache Group/Apache2/conf-"
    3.) LoadFile "C:/php/php5ts.dll"
    4.)<IfModule php5_module>
    <Location />
    AddType text/html .php .phps
    AddHandler application/x-httpd-php .php
    AddHandler application/x-httpd-php-source .phps
    </Location>
    </IfModule>
    5.) AddType application/x-httpd-php .php
    AddType application/x-httpd-php .phtml
    AddType application/x-httpd-php-source .phps
    But when I am tryin to run the following program:
    <?php
    echo "<h1>OCI Test</h1>\n";
    $conn=OCILogon("system", "sheetal16", "orcl");
    $stmt = OCIParse($conn, "SELECT table_name FROM user_tables ORDER BY table_name");
    OCIExecute($stmt, OCI_DEFAULT);
    while (OCIFetch($stmt)) {
         $table_name = OCIResult($stmt, "TABLE_NAME");
         echo "$table_name<br />\n";
    OCIFreeStatement($stmt);
    OCILogoff($conn);
    ?>
    I am getting the following error:
    OCI Test
    Fatal error: Call to undefined function OCILogon() in C:\Program Files\Apache Group\Apache2\htdocs\test2.php on line 3
    Please help me to solve this problem.
    Thanks,
    Sheetal

    See Re: PHP- Oracle not working- Call to undefined function OCILogon() ERROR

Maybe you are looking for

  • Want to import avchd footage from a media card into FCE.

    Trying to import avchd video from a media card into Final Cut Express. Panasonic DMC-ZS3 / FCE 4.0.1 / MBP 10.6.8. Have taken a look at the footage using a trial version of Pavtube MTS Converter.

  • Connecting Samsung mobile to Mac

    Hello, Wasn't sure where to post this as it's a long shot but does anyone know how we can connect my sons new Samsung monte mobile to one of our macs, the software supplied is Windows only & we have no pc's. We have I phones but i didn't want to buy

  • Choose paper source as either Letter or Tabloid by PDF page size

    Hi, When i check choose paper source by PDF page size, it seems like its find best fitting paper for PDF size. Can i force it to be either Letter size or Tabloid? Thank you

  • How to connect e66 to pc

    i have a small office with small network LAN (wired) as well as wlan router. i want to acces my computer data using wlan on network with my e66 . can it be possible if yes than how.

  • Itunes taking more time to Sync after IOS 6 upgrade

    itunes taking more time to Sync apps data after IOS 6 upgrade in iphone 4s. Also itunes is getting hanged and is very slow. I tried twice and still having the same issue.