Invoking Stored Function

I have this function defined in my database:
create or replace FUNCTION return_string_func(x VARCHAR2) RETURN VARCHAR2
AS
BEGIN
return 'Hello ' || x;
END;
and i am trying to invoke it as follows:
PLSQLStoredProcedureCall call = new PLSQLStoredProcedureCall (); //------------------------------------A
call.setProcedureName("return_string_func");
call.addNamedArgument("x", JDBCTypes.VARCHAR_TYPE);
DataReadQuery query = new DataReadQuery ();
query.addArgument("x");
query.setCall(call);
Session session = JpaHelper.getEntityManager(em).getServerSession();
List queryArgs = new ArrayList();
queryArgs.add("venkat");
List mylist= (List)session.executeQuery(query,queryArgs);
DatabaseRecord record = (DatabaseRecord) mylist.get(0);
return (String)record.get(0); //------------------------------------B
I am getting the following error:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLException: ORA-06550: line 5, column 3:
PLS-00221: 'RETURN_STRING_FUNC' is not a procedure or is undefined
ORA-06550: line 5, column 3:
Note that a similar code works fine for a stored procedure(with IN-OUT params) though; I dont see something like a PLSQLStoredFuncitionCall being present.
What am i doing wrong?

user8093550 wrote:
I got this working with StoredFunctionCall. To my surprise, i was not able to find PLSQLStoredFunctionCall in the version of eclipselink i am using.
Do you mean JDBC CallableStatement along with JPA? How can this be done?Don't use JPA at all as this has nothing to do with ORM persistence. Obtain the configured Datasource through JNDI, obtain connection from it, execute call, don't forget to close statement and connection.
edit:
also, the PLSQL* classes seem to be internal implementation classes that you should not be using directly as it makes it Oracle specific. Probably there is also a StoredProcedureCall that you can use to make it more portable.

Similar Messages

  • View + stored function + synonym for other user

    Dear All!
    I've got a quite strange problem which I cannot decide whether it's caused by my lack of knowledge on the appropriate topic or by an Oracle bug. I'm already after some heavy googling on the topic and I was unable to track any valuable answers neither in forums nor in the Oracle documentation. I'll try to be as short and specific as possible.
    Database: Oracle 10g
    Result of "SELECT BANNER FROM V$VERSION":
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    "CORE     10.2.0.4.0     Production"
    TNS for Solaris: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    I have two users in the database for a single Web application: UAPP01, which is the owner of application DB objects and UAPP02 which is the application user connecting to the DB. The application runs for quite many years by now and DB structure layout has always been following a simple logic: for each DB object used by the app. (tables, views, packages and stored procedures/functions) and found in the UAPP01 there exists a synonym in the UAPP02 schema. For the privileges to be set correctly a role is created: RL_MY_APPL which is granted the necessary privileges on objects of UAPP01 (CRUD on tables, SELECT on views, EXECUTE on procedures, etc..). This role is granted to UAPP02.
    In the previous days I was about to extend the DB with a view that invokes a stored function. This pattern has already occured in the DB previously so I kept following existing conventions: I've created the stored function and the view in the UAPP01 schema, granted SELECT on the view to RL_MY_APPL and created the synonym for it in the UAPP02 schema. This is where the entire functionality began to act strange. I'll try to explain with a simplified example that was sufficient to reproduce the problem:
    REM ========================================
    REM Execute below code as UAPP01 user.
    REM ========================================
    REM Test function.
    CREATE OR REPLACE FUNCTION testfunction(p_param NUMBER) RETURN NUMBER IS
    BEGIN
    RETURN p_param *2;
    END;
    REM Testview version 1. causing trouble.
    CREATE OR REPLACE VIEW testview AS
    WITH testdata AS
    SELECT /*+ materialize*/ LEVEL AS d
    FROM dual CONNECT BY LEVEL <= 100
    SELECT a, b, c, SUM(d) AS sum_d
    FROM
    SELECT FLOOR(dbms_random.VALUE(1, 100)) a, FLOOR(dbms_random.VALUE(1, 100)) b, FLOOR(dbms_random.VALUE(1, 100)) c, testfunction(d) AS d
    FROM testdata
    GROUP BY CUBE(a, b, c)
    REM Testview version 2. not causing trouble.
    CREATE OR REPLACE VIEW testview AS
    SELECT a, b, c, SUM(d) AS sum_d
    FROM
    SELECT FLOOR(dbms_random.VALUE(1, 100)) a, FLOOR(dbms_random.VALUE(1, 100)) b, FLOOR(dbms_random.VALUE(1, 100)) c, testfunction(d) AS d
    FROM
    SELECT LEVEL AS d FROM dual CONNECT BY LEVEL <= 100
    GROUP BY (a, b, c)
    REM Synonym.
    CREATE OR REPLACE SYNONYM UAPP02.testview FOR UAPP01.testview;
    REM Grants.
    GRANT SELECT ON testview TO RL_MY_APPL;
    When creating TESTVIEW with the 1 ^st^ version I cannot query it using the UAPP02 user, I'm constantly getting the error: ORA-00904: : invalid identifier. However, when I use the 2 ^nd^ version everything runs perfectly. What is common in the two cases is that both versions use the TESTFUNCTION function. I have not granted the EXECUTE rights on TESTFUNCTION to the RL_MY_APPL since it was never needed previously (for other views using stored functions) and as far as I know it's not necessary (as both the view and the function are owned by UAPP01). The strange thing in the above behaviour is that the function is used by both versions, however only one of them fails. This is where I thought it's not a granting issue, otherwise neither of the versions would have worked and I think I would have received a different error stating that UAPP02 lacks the necessary privileges on underlying objects of the view.
    As I further digged into the problem by examining the EXPLAIN PLAN output for the two versions I found that version 1. leads to a TEMP TABLE TRANSFORMATION and to MULTI TABLE INSERTs, whereas version 2. simply executes the query without doing such things. In my setup I presume the MULTI TABLE INSERTs were caused by the GROUP BY CUBE. When I simply removed the CUBE and used only GROUP BY the TEMP TABLE TRANSFORMATION remained in place but the MULTI TABLE INSERTs disappeared. As a result of this small modification the view again began to work when I executed it through the synonym and using the UAPP02 user.
    With the original DB objects of our application the behaviour is even more strange: the error comes up if I select from the view and filter for a column that is grouped in the query whereas it works correctly if I filter for the aggregated columns. However, I couldn't reproduce this with the above simplified example.
    No problem occurs with any of the versions if I query the view using the UAPP01 user.
    This hectic behaviour made me suspect that the TEMP TABLE TRANSFORMATION + MULTI TABLE INSERT + synonym + stored function combo appears to bring a strange Oracle bug to the surface...
    As a final note: when executing GRANT EXECUTE ON TESTFUNCTION TO RL_MY_APPL everything works fine in all cases. I know I could simply live with this but I'd really like to get to the bottom of this. Although this extra GRANT appears to solve the problem I don't really trust it. I'd really like to avoid the bug emerging again in Production in case this extra GRANT were not sufficient due to some unknown misteries.
    Excuse me, the post has become a bit lengthy. Thanks in advance for anyone who's willing to read through and answer it!
    Regards,
    Krisztian Balazs Szaniszlo

    The error is thrown at run-time and only for the UAPP02 (second) user.
    The problem is that the appearance of errors is independent of whether the query contains the call to the stored function or not.
    So far I thought that if I use a stored function indirectly, like in this setup: UAPP02.synonym -> UAPP01.view -> UAPP01.stored function, then I don't need the grant. Of course, I understand that if I had used it directly, like :UAPP02.synonym -> UAPP01.stored function then I'd need the GRANT EXECUTE.
    Shall I just ignore the strange behaviour and go on by adding GRANT EXECUTE privilege on all the functions used indirectly through views? It seems to solve the problem, but this behaviour is disturbing me quite and I fear the real root cause of the problem can emerge later in a different fashion.

  • XSQL: how to invoke stored procedure from XSQL

    Any one has example on how to invoke stored procedure within XSQL with associated *.xsl? What the syntax looks like? Thanks.

    If you want to simply invoke a stored procedure, use:
    <xsql:dml>
    begin
    proc(args);
    end;
    </xsql:dml>
    If you want to return XML that your stored procedure "prints" to the OWA page buffer, then use:
    <xsql:include-owa>
    If you want to invoke a stored function that returns a REF CURSOR function, then use <xsql:ref-cursor-function>
    null

  • Invoking winapi functions

    hi all can i call winapi functions in form 9i as it can be in VB. If yes can any one give me at least one example , suppose i want to shutdown my pc.
    thanks

    Hi,
    Maybe this example cut will work for you. It passes and gets
    string:
    Statement stmt = conn.createStatement ();
    CallableStatement cs = conn.prepareCall ("begin ? :=
    MyFunction(?); end;");
    cs.registerOutParameter(1,Types.CHAR);
    cs.executeUpdate();
    System.out.println (cs.getString(1).trim());
    Robertas
    Sudhir Kulkarni (guest) wrote:
    : How to call Stored Functions from Oracle.. Does JDBC allow
    this
    : to do..
    : Callable Statement allows only Stored Procedures.
    : Does It allow to invoke Database Functions..
    : Pl. Explain is there any other way to invoke Database
    Functions..
    : Thanks in Advance,
    : Sudhir Kulkarni
    null

  • Invoking  Remote Function Module.

    Hi
    I am invoking a remote function module from a web dynpro application(External Appln ).
    The FM contains the following code snippet
    first it inserts the parameters passed into a table
    and then the code is
    SUBMIT <report name > with parameter passing.
    when i comment out the Submit statement and invoke the function module the parameters get populated in the table..but when i enable the SUBMIT statement the same set of parameters dont even get populated in the table. and i get the following exception in the logs of SAP J2ee appln server .
    WDDynamicRFCExecuteException:      Screen output without connection to user.                           , error key: RFC_ERROR_SYSTEM_FAILURE
    i am not able to find a solution to this problem .
    Please help.
    regards
    Nilesh Taunk.

    HI
    GOOD
    GO THROUGH THIS LINKS,THEY MIGHT HELP YOU TO GIVE YOU SOME MORE IDEA.
    Re: RFC Error While Invoking A Remote Function Module.
    RFC Error While Invoking A Remote Function Module.
    http://sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5303c390-0201-0010-e0b2-bfae018377f0
    THANKS
    MRUTYUN

  • Problem with return value of stored function

    Hi,
    I've made a stored function that insert a new row in a table and return the primary key (see at the end of the message the function script).
    In VS 2005 with Visual basic, using the designer, I've created a dataset containing a tableAdapter to be able to use the Pl/SQL function.
    My problem is I can't get the proper return value. The VB code below works without error except that I get 0 as value.
    What's wrong?
    Cheers,
    Sebastien
    VB code
    Dim myAddSession As New ICISDataSetTableAdapters.AddSessionTableAdapter
    Dim intSessionId As Integer
    intSessionId = myAddSession.ADD_SESSION(tbxUsername.Text, _
    tempFolder.Substring(tempFolder.LastIndexOf("\") + 1), _
    "toto", Environment.GetEnvironmentVariable("COMPUTERNAME"), _
    myLevelAccess.icisUserId, myLevelAccess.levelId)
    The debugger tells me that the ADD_SESSION function return value is Object.
    add_session PL/SQL script:
    CREATE OR REPLACE FUNCTION ICISSEC.add_session (
    orausername IN icis_session.ora_user_name%TYPE,
    ctxsessionid IN icis_session.ctx_session_id%TYPE,
    ctxsessionname IN icis_session.ctx_session_name%TYPE,
    ctxservername IN icis_session.ctx_server_name%TYPE,
    icisuserid IN icis_session.icis_user_id%TYPE,
    startlevelid IN icis_session.start_lvl_id%TYPE
    RETURN icis_session.ICIS_SESSION_ID%TYPE
    IS
    tmpvar icis_session.ICIS_SESSION_ID%TYPE;
    BEGIN
    INSERT INTO icis_session
    (ora_user_name, ctx_session_id, ctx_server_name,
    icis_user_id, start_lvl_id, ctx_session_name
    VALUES (orausername, ctxsessionid, ctxservername,
    icisuserid, startlevelid, ctxsessionname
    RETURNING icis_session_id
    INTO tmpvar;
    COMMIT;
    RETURN tmpvar;
    EXCEPTION
    WHEN OTHERS
    THEN
    RAISE;
    END add_session;

    naama wrote:
    that if a value is null to convert it to 0 ? . i mean in the part of the declaration of parameter
    Nope, can't do that in the signature. You'll need to handle that by validating the passed parameters at the start of the function.
    It's simple enough. In your case you might just as well test for NULL and fail the function like this:
        FUNCTION date_post_message(
                user_lock_in IN NUMBER,
                form_type_in IN NUMBER DEFAULT 0 ,
                date_in      IN DATE)
            RETURN BOOLEAN
        IS
            v_num NUMBER(1);
        BEGIN
            dbms_output.put_line('Value of parameters : user_lock_in : '||user_lock_in || ' : form_type_in : '||form_type_in||' : date_in : '||date_in );
            IF user_lock_in = 1 THEN
                RETURN FALSE;
            END IF;
            IF form_type_in IS NULL THEN
                RETURN FALSE;
            ELSIF form_type_in NOT IN (1,2) THEN
                RETURN FALSE;
            END IF;
            RETURN TRUE;
        EXCEPTION
        WHEN NO_DATA_FOUND THEN
            RETURN FALSE;
        END;In other use cases I would declare a local variable and process it like this:
            IF form_type_in IS NULL THEN
                l_form_type := 0;
            ELSE
                 l_form_type := form_type_in;
            END IF;Obviously the code should use the local variable rather than the parameter.
    Validating the values passed in parameters at the start of a function is good practice. If you really want to go to town, read about Design By Contract.
    Cheers, APC
    Edited by: APC on Nov 9, 2011 1:36 PM
    Added example, as requested by OP

  • Using Stored Function with a datagridview

    Hi All,
    I have a problem using a stored function in a datagridview control. My problem is, when the user adds a new row to the grid, the stored function is called to insert the next item number in a grid column. For some reason I cannot figure out why this isn’t just working. The stored function is working alright, as I can call it from SQL Plus or PL/SQL and get the return value back but my problem is inserting it into the grid as the user creates a new row. Can some please help.
    Function NextItemNum RETURN NUMBER
    IS
    varItemNum NUMBER(8);
    Begin
    SELECT MAX(ITEM_NUM) + 1
    INTO varItemNum
    FROM ORDERITEMS;
    IF varItemNum IS NULL THEN
    varItemNum = 1
    END IF;
    RETURN varItemNum;
    END NextItemNum;
    /* Code to insert into datagridview */
    ig = myOrdersInsertCommand.Parameters.Add(New OracleParameter("pVal", Client.OracleDbType.Int32, 8, ParameterDirection.ReturnValue))
    myOrdersInsertCommand.ExecuteNonQuery()
    ItemNum = (myOrdersInsertCommand.Parameters("pVal").Value.ToString())
    For Each r As DataGridViewRow In OrderItemsDataGridView.Rows
    ORDER_ITEMSTableAdapter.InsertOrderItems(r.Cells(0).Value, r.Cells(1).Value, r.Cells(2).Value, r.Cells(3).Value, r.Cells(4).Value, r.Cells(5).Value, r.Cells(6).Value)
    Next

    Firstly, thank you for the help. I have attempted to code the advice you gave but it still does not seem to compile properly. Can you suggest what is wrong with my code please?
    Here is the code I am trying to configure:
    forceDriver.h
    static int32 CVICALLBACK static_callback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void* callbackData);
    int32 EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples);
    int32 DoneCallback(TaskHandle taskHandle, int32 status, void *callbackData);
    forceDriver.cpp
    DAQmxErrChk (DAQmxRegisterEveryNSamplesEvent(taskHandle,DAQmx_Val_Acquired_Into_Buffer,2500,0,&forceDriver::static_callback,panel));
    **START TASK**
    int32 forceDriver::EveryNCallback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples)
           panel->(member_function);
    int32 CVICALLBACK forceDriver::static_callback(TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void* callbackData)
    forceDriver* static_object = static_cast<forceDriver*>(callbackData);
    return static_object->EveryNCallback(taskHandle, everyNsamplesEventType, nSamples);
    where panel is the object I have created. 

  • SQL LOADER: how to load CLOB column using stored function

    Hi,
    I am a newbie of sql loader. Everything seems to be fine until I hit a
    road block - the CLOB column type. I want to load data into the clob
    column using a stored function. I need to do some manipulation on the
    data before it gets saved to that column. But I got this error when I
    run the sql loader.
    SQL*Loader-309: No SQL string allowed as part of "DATA" field
    specification
    DATA is my CLOB type column.
    here is the content of the control file:
    LOAD DATA
    INFILE 'test.csv'
    BADFILE 'test.bad'
    DISCARDFILE 'test.dsc'
    REPLACE
    INTO TABLE test_table
    FIELDS TERMINATED BY ','
    OPTIONALLY ENCLOSED BY '"'
    TRAILING NULLCOLS
    codeid          BOUNDFILLER,
    reason          BOUNDFILLER,
    Checkstamp     "to_date(:CHECKSTAMP, 'mm/dd/yyyy')",
    "DATA"          "GetContent(:codeid, :reason)"
    All references are suggesting to use a file to load data on
    CLOB column but I want to use a function in which it generates
    the content to be saved into the column.
    Any help is greatly appreciated.
    Thanks,
    Baldwin
    MISICompany

    *** Duplicate Post ... Please Ignore ***

  • How can i return a SDO_GEOMETRY value in a Java-Stored-Function?

    For a example, Ive got a java-function witch returns a
    oracle.sdoapi.geom.Geometry like:
    public static Geometry GetQPoint(String sF_TABLE_NAME, long lFID)
    And now, Ill try to deploy this function as a PL-SQL stored-function like:
    GET_Q_POINT(
    F_TABLE_NAME IN VARCHAR2,
    FID IN NUMBER
    ) RETURN MDSYS.SDO_GEOMETRY;
    I can't deploy this above mentioned java-function with Oracle9i JDeveloper because oracle.sdoapi.geom.Geometry can not mapped in any PL-SQL data type.
    Is there any possibility to do it in a other way?
    Please help me.

    a quick example that takes as input a longitude and latitude,
    and return a point geometry in wgs 84:
    CREATE OR REPLACE FUNCTION get_geom (
         longitude IN          NUMBER,
         latitude     IN          NUMBER )
         RETURN mdsys.sdo_geometry
         DETERMINISTIC IS
         BEGIN
    RETURN mdsys.sdo_geometry (2001,8307,
              mdsys.sdo_point_type (longitude, latitude, NULL), NULL, NULL );
    END;
    other pl/sql examples:
    REM
    REM This function doesn't really do anything, but demonstrates some simple
    REM mechanisms on how to manipulate the array portion of the geometry object, and
    REM also how to write a function that returns a geometry object.
    REM
    REM The function demonstrates:
    REM 1) .EXTEND (there is also .DELETE)
    REM 2) .COUNT
    REM 3) Any function that returns an object (including the SDO_GEOMETRY object)
    REM should be declared as DETERMINSTIC (see below).
    REM
    create or replace function create_geometry return mdsys.sdo_geometry deterministic as
    temp_geom mdsys.sdo_geometry := mdsys.sdo_geometry (2002, 8307, null,
    mdsys.sdo_elem_info_array (1,2,1),
    mdsys.sdo_ordinate_array ());
    begin
    for i in 1 .. 10 loop
    temp_geom.sdo_ordinates.extend (2);
    temp_geom.sdo_ordinates(temp_geom.sdo_ordinates.count-1) := i;
    temp_geom.sdo_ordinates(temp_geom.sdo_ordinates.count) := i+1;
    end loop;
    return temp_geom;
    end;
    select create_geometry from dual;
    set linesize 80
    set pages 1000
    drop table TEST_MODIFY;
    create table TEST_MODIFY (geom mdsys.sdo_geometry);
    insert into TEST_MODIFY values
    (mdsys.sdo_geometry (2002, 8307, null,
    mdsys.sdo_elem_info_array (1,2,1),
    mdsys.sdo_ordinate_array (1,1, 2,2, 3,3, 4,4)));
    insert into TEST_MODIFY values
    (mdsys.sdo_geometry (2002, 8307, null,
    mdsys.sdo_elem_info_array (1,2,1),
    mdsys.sdo_ordinate_array (21,21, 22,22, 23,23, 24,24)));
    REM
    REM Select values before update.
    REM
    select geom from TEST_MODIFY;
    REM
    REM This PL*SQL block updates all the ordinates of a geometry by adding 10 to each x value
    REM and 20 to each y value.
    REM
    declare
    i NUMBER;
    cursor c1 is select geom, rowid
    from TEST_MODIFY;
    begin
    for r in c1 loop
    i := 1;
    while (i < r.geom.sdo_ordinates.count) loop
    r.geom.sdo_ordinates(i) := r.geom.sdo_ordinates(i) + 10;
    r.geom.sdo_ordinates(i+1) := r.geom.sdo_ordinates(i+1) + 20;
    i := i + 2;
    end loop;
    update TEST_MODIFY set geom = r.geom where rowid = r.rowid;
    end loop;
    end;
    REM
    REM Select values after update.
    REM
    select geom from TEST_MODIFY;

  • Stored function

    Hi guys!
    I have a stored function which searches if a product exists in the DB and
    return the appropriate value, something like a bool variable (here there is a
    problem too, because if it returns a bool value, I can't find this tipe in ODP
    and I must use number and decimal types).
    Anyway, the function works perfectly but I have I problem with mapping the
    response value in ODP.I put it the first in ParamCollection, I have assigned
    it the correct type, so I can't figure out why I get this message
    ORA-22060: argument [{0}] is an invalid or uninitialized number
    CREATE OR REPLACE PROCEDURE "ADMIN"."PRODUCTEXISTS"
    Iname in varchar2,
    Imanufacturer in varchar2
    return number is
    b number(1);
    nr number(4);
    cursor c is
    SELECT product FROM products
    WHERE name=Iname AND manufacturer=Imanufacturer;
    begin
    b:=0;
    OPEN c;
    LOOP
    FETCH c INTO nr;
    IF c%FOUND THEN
    b:=1;
    END IF;
    EXIT WHEN b=1 OR c%NOTFOUND;
    END LOOP;
    CLOSE c;
    RETURN b;
    end;
    This is the cs procedure:
    public bool PRODUCTS_CheckProduct(string name, string manufacturer)
                   OracleCommand cmd = new OracleCommand("PRODUCTEXISTS", dbConn);
                   cmd.CommandType = CommandType.StoredProcedure;
                   OracleParameter [] prm = new OracleParameter[3];
                   prm[1] = cmd.Parameters.Add("name", OracleDbType.Varchar2, name, ParameterDirection.Input);
                   prm[2] = cmd.Parameters.Add("manufacturer", OracleDbType.Varchar2, manufacturer, ParameterDirection.Input);
                   prm[0] = cmd.Parameters.Add("RetVal", OracleDbType.Decimal, ParameterDirection.ReturnValue);
                   prm[0].Size=1;
                   dbConn.Open();
                   cmd.ExecuteNonQuery();
                   dbConn.Close();
                   if (prm[2].Value.ToString())               
                        return true;
                   else
                        return false;

    When binding function parameters by position, the
    function return value comes first.
    And you want a stored function, not a stored procedure.
    Your c# code should be something like:
          public static OracleConnection connect()
            OracleConnection con = new OracleConnection(...);
            con.open();
            return con;
          using (OracleConnection con = connect())
            OracleCommand cmd = new OracleCommand("PRODUCTEXISTS", con);
            cmd.CommandType = CommandType.StoredProcedure;
            OracleParameter rv = cmd.Parameters.Add("RetVal", OracleDbType.Decimal, ParameterDirection.ReturnValue);     
            rv.Size=1;
            cmd.Parameters.Add("name", OracleDbType.Varchar2, name, ParameterDirection.Input);
            cmd.Parameters.Add("manufacturer", OracleDbType.Varchar2, manufacturer, ParameterDirection.Input);
            cmd.ExecuteNonQuery();
            OracleDecimal d = (OracleDecimal)rv.Value;
            if (d == 1)
              return true;
            else
              return false;
          }David

  • 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

  • DBMS_XMLQuery behavior when using stored function within cursor select

    Consider the following SQL Statement
    select t1.id
    , t1.name
    , cursor ( select t2.id
    from tab t2
    where t2.t1_id
    = t1.id
    and validate(t2.xyz,:bd1)
    = 1
    from tab t1
    where t1.id = :bd2
    DBMS_XMLQuery is used to create a context and to bind the appropriate values. In this case 'validate' is a stored function. I get the following error message upon execution:
    ORA-29532: Java call terminated by uncaught Java exception:
    java.sql.SQLException: Missing IN or OUT parameter at index:: 1
    Issuing a similar statement in SQL*Plus works fine. I was wondering whether this is a known issue when using a stored function in the cursor select statement in the context of DBMS_XMLQuery or whether I'm doing something wrong.

    Hi Jan,
    This problem has been identified and fixed. The fix should be available in the next release. Thank you for bringing this up to our attention.
    visar

  • Read item from Java class and call to stored function/procedure of database

    Hi,
    I am looking solution that I was trying to find becasue of I am not expert and novice of ADF so I am getting problem to do. I am trying migrating from oracle forms to JDeveloper[ADF].
    I want to call database stored function from JSF pages by java bean class of a button press event (manually created) and after button event I have called java class which I created manually. But I can not read that values what I given into jsp page.
    question1: How can I read jsp pages items value to java class ?
    question2: How can I call to database stored function/procedure with that parameter?
    question3: How can I use return value of that stored function/procedure ?
    Please reply me .
    Thanks,
    zakir
    ===
    Edited by: Zakir Hossain on Mar 29, 2009 10:22 AM

    ---

Maybe you are looking for

  • Connecting iPhone to G5 powerMac

    Got an old powermac G5 with Mac OS X 5.8 installed with latest editions of iphoto and itunes installed. thing is whenever i connect an iphone 3 or 4th gen they do not show up on the desktop like ipods and other devices do. itunes sees the iphones but

  • Expand for More Details

    On a page of my website built in Flash and uploaded as DW .html, I have 6 text items listed. I would like the viewer to be able to "Read More" about the particular item. What is the easiest but effective way for me to accomplish this task?  I have lo

  • Cannot get filezilla to work on mac 10.5.8

    I have downloaded the file from the filezilla website, however after unarchiving the file, when I try to open it, an error reads "failed to write xml file" I've tried other FTPs but they don't work very well.

  • Could be a fix for Tomcat 6 issue

    Getting Eclipse 3.2, Tomcat 6.0 and JSF 1.2 playing together nicely is a task that is certainly not for the faint of heart. Tomcat 6 seems to have issues at the moment but I'm loathed to push too much of the blame on to it as generally Tomcat has bee

  • Substitute rule for default profit center

    Hi all, I have a One GL for VAT account for three regions. in each region we have 30 profit centers. Here my problem is when i post the sales transaction it is posting into  relavent profit center but my client wants  to post into regional office pro