Named parameters in stored function

Hi,
I am trying to execute stored function from java in oracle . I am using Oracle 9.2.0.1.0 and the newest JDBC drivers, ie. for 10g which are compatible. I have flicked through JDBC Named Parameters example but it only addresses stored procedures.
The problem I have is that I do not know what name the return value of stored procedure has.
stored function parameter names:
1. ????
2. test1 Mode: IN
3. test2 Mode: IN
?=call test_function(?,?);
When I am trying to set values as indexes everything works perfect.
CallableStatement cs = .....
cs.registerOutParameter(1, Types.VARCHAR);
cs.setString(2, "a");
cs.setString(3, "b");
cs.execute();
String returnedValue = cs.getString(1);
However, when I am trying to use named parameters the code looks like this:
CallableStatement cs = .....
cs.registerOutParameter(1, TYPES.VARCHAR);
cs.setString("test1", "a");
cs.setString("test2", "b");
and the question is what is the name of return parameter.
I have tried to put the same name as the name of stored function but is reports error.
Instead I had to first getmetadata from oracle and in case of stored functions utilize it, unfortunatelly getting metadata has perfomance issues and I heard that oracle 10g is even slower in getting metadata.
If anyone knows the answer to my question, please answer.
Thank you in advance,
Mateusz Szczap
Java Programmer
NCDC
[email protected]
http://www.ncdc.pl

Hi,
I am trying to execute stored function from java in oracle . I am using Oracle 9.2.0.1.0 and the newest JDBC drivers, ie. for 10g which are compatible. I have flicked through JDBC Named Parameters example but it only addresses stored procedures.
The problem I have is that I do not know what name the return value of stored procedure has.
stored function parameter names:
1. ????
2. test1 Mode: IN
3. test2 Mode: IN
?=call test_function(?,?);
When I am trying to set values as indexes everything works perfect.
CallableStatement cs = .....
cs.registerOutParameter(1, Types.VARCHAR);
cs.setString(2, "a");
cs.setString(3, "b");
cs.execute();
String returnedValue = cs.getString(1);
However, when I am trying to use named parameters the code looks like this:
CallableStatement cs = .....
cs.registerOutParameter(1, TYPES.VARCHAR);
cs.setString("test1", "a");
cs.setString("test2", "b");
and the question is what is the name of return parameter.
I have tried to put the same name as the name of stored function but is reports error.
Instead I had to first getmetadata from oracle and in case of stored functions utilize it, unfortunatelly getting metadata has perfomance issues and I heard that oracle 10g is even slower in getting metadata.
If anyone knows the answer to my question, please answer.
Thank you in advance,
Mateusz Szczap
Java Programmer
NCDC
[email protected]
http://www.ncdc.pl

Similar Messages

  • Named Parameters in Functions: Possible?

    I want to use named parameters to call PL/SQL functions using JDBC, as is best practice and necessary for default values to work. Unfortunatley all the examples I found are for procedures only. Using a positional registerOutParameter with named register / get methods on the CallableStatement does not work, obiviously.
    Is there any proper way to use named parameters with functions ? Proper does not include writing wrapper procedures nor turning functions into procedures.

    Hi Avi,
    as far as I know the return value of a PL/SQL function does not have a name, as oposed to the parameters of a PL/SQL function, which must have a name. One could argue that the return value of a function is called the same as the function itself. I have tried that option but it does not work.
    Unfortunatley the method OraclePreparedStatement.registerReturnParameter refers to something else than the return value of a PL/SQL function. Is it possible that the developers of the driver have forgotten something?

  • Calling a stored function in Oracle 8.1.5 which has out parameters

    Hi,
    The issue is, I am unable to call or execute a Oracle8.1.5 stored function which has 1 return value and 1 out parameter from neither from .NET nor from VB6.
    If I use MSDAORA.1 : wrong number or types of arguments in call to function displays even though everything is perfect.
    If i use OraOLEDB.Oracle.1 provider (even though my client and server are 8.1.5,i used this) it says Provider cannot be found. It may not be properly installed. as it is not 8.1.7 or higher. I want to use 8.1.5 only. Kindly give me a solution for this.
    If i use 8.1.7 client for the server 8.1.5 my stored function is executing and returning the out parameter perfectly in .NET using MSDAORA.1. But I have to use 8.1.5 client and servers only. Please Help me.
    Thanks a lot in advance
    Krishna Mohan
    Hyderabad

    Functions normally have only 'in' parameters and return a single out value. Writing a function with an out parameter is risky, at best.
    Rewrite the function, and make it a procedure instead. Then I would bet the problem will no longer exist.

  • 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. 

  • 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

  • XML Embedded in Stored Function - Performance Considerations

    A developer in my company approached us with a question about performance considerations while writing stored procedures or functions that embed XML.
    The primary use for this function would be to provide a quick decision given a set of parameters. The function will use the input parameters along with some simple calculations and DB lookups to come up with an answer. These parameters will be stored in the database. Potentially even more parameters that are currently represented in the xml will be available in the DB and therefore could be looked up by the function.
    My biggest question is if this way of using XML as an input parameter introduces any performance considerations or concerns for storage/bandwidth etc.
    Thank you
    Edited by: user8699561 on May 19, 2010 9:24 AM

    user8699561 wrote:
    A developer in my company approached us with a question about performance considerations while writing stored procedures or functions that embed XML.
    The primary use for this function would be to provide a quick decision given a set of parameters. The function will use the input parameters along with some simple calculations and DB lookups to come up with an answer. These parameters will be stored in the database. Potentially even more parameters that are currently represented in the xml will be available in the DB and therefore could be looked up by the function.
    My biggest question is if this way of using XML as an input parameter introduces any performance considerations or concerns for storage/bandwidth etc.
    Thank you
    Edited by: user8699561 on May 19, 2010 9:24 AMStorage/bandwith will be determined regarding the size of the XML doc, but there are ways to minimize those to the minimum (binary XML support in JDBC eg.). Performance overhead in general...eh..."it depends" (how you set it up)...

  • 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

  • Wrong  value  in java stored function

    Hi All,
    i have written a java stored function,
    at the end of the code it insert record into the database
    among other columns also a number(18,3) column,
    when I debug it (out side of server) - works fine.
    when I load it to database i get wrong values in column
    (like instead of 76.546 i get 77.667) I can't figure out where it comes from.
    I use big decimal in java code.
    if i Hard code the value in java code it works fine!
    am I missing something ?, calculations/ data type different out side then inside database? using oracle 10.2.0.2
    Cheers
    Sahar

    Hi
    the code calculate some averages of amounts ( money) according to several
    conditions,and parameters given to the function and stores the average into table in the database
    the money columns are of data type 18,3 , both source and target tables have same structure.
    thanks
    Sahar

  • 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

  • Using named parameters with an sql UPDATE statement

    I am trying to write a simple? application on my Windows 7 PC using HTML, Javascript and Sqlite.  I have created a database with a 3 row table and pre-populated it with data.  I have written an HTML data entry form for modifying the data and am able to open the database and populate the form.  I am having trouble with my UPDATE function.  The current version of the function will saves the entry in the last row of the HTML table into the first two rows of the Sqlite data table -- but I'm so worn out on this that I can't tell if it is accidental or the clue I need to fix it.
    This is the full contents of the function . . .
         updateData = new air.SQLStatement();
         updateData.sqlConnection = conn;
         updateData.text = "UPDATE tablename SET Gsts = "Gsts, Gwid = :Gwid, GTitle = :GTitle WHERE GId = ":GId;
              var x = document.getElementsById("formname");
              for (var i = 1, row, row = x.rows[i]; i++) {
                   updateData.parameters[":GId"] = 1;
                   for (var j = 0, col; col=row.cells[j]; j++) {
                        switch(j) {
                             case 0: updateData.parameters[":GTitle"] = col.firstChild.value; break;
                             case 1: updateData.parameters[":Gsts"] = col.firstChild.value; break;
                             case 2: updateData.parameters[":Gwid"] = col.firstChild.value; break;
    Note: When I inspect the contents of the col.firstChild.value cases, they show the proper data as entered in the form -- it just isn't being updated into the proper rows of the Sqlite table.
    Am I using the named parameters correctly? I couldn't find much information on the proper use of parameters in an UPDATE statement.

    Thank you for the notes.  Yes, the misplaced quotes were typos.  I'm handtyping a truncated version of the function so I don't put too much info in the post. And yes, i = 1 'cuz the first rows of the table are titles.  So the current frustration is that I seem to be assigning all the right data to the right parameters but nothing is saving to the database.
    I declare updateData as a variable at the top of the script file
    Then I start a function for updating the data which establishes the sql connection as shown above.
    The correctly typed.text statement is:
            updateData.text = "UPDATE tablename SET Gsts=:Gsts, Gwid=:Gwid, GTitle=:GTitle WHERE GId=:GId";
    (The data I'm saving is entered in text boxes inside table cells.) And the current version of the loop is:
            myTable = document.getElementById("GaugeSts");
            myRows= myTable.rows;
              for(i=1, i<myRows.length, i++) {
                   updateData.parameters[":GId"]=i;
                   for(j=0; j<myRows(i).cells.length, j++) {
                        switch(y) {
                             case 0: updateData.parameters[":GTitle"]=myrows[i].cells[y].firstChild.value; break;
                             case 1: updateData.parameters[":Gsts"]=myrows[i].cells[y].firstChild.value; break;
                             case 2: updateData.parameters[":Gwid"]=myrows[i].cells[y].firstChild.value; break;
                             updateData.execute;
    The whole thing runs without error and when I include the statements to check what's in myrows[i].cells[y].firstChild.value, I'm seeing that the correct data is being picked up for assignment to the parameters and the update. I haven't been able to double check that the contents of the parameters are actually taking the data 'cuz I don't know how to extract the data from the parameters. ( The only reference  I've found so far has said that it is not possible. I'm still researching that one.) I've also tried moving the position of the updateData execution statement to several different locations in the loop andstill nothing updates. 
    I am using a combination of air.Introspector.Console.log to check the results of code and I'm using Firefox's SQlite manager to handle the database.  The database is currently sitting on the Desktop to facilitate testing and I have successfully updated/changed data in this table through the SQLite Manager so I don't think I'm having permission errors and, see below, I have another function successfully saving data to another table.
    I currently have another function that uses ? for the parametersin the .text of a INSERT/REPLACE statement and that one works fine.  But, only one line of data is being saved so there is no loop involved.  I tried changing the UPDATE statement in this function to the INSERT/REPLACE just to make something save back to the database but I can't make that one work either.I've a (And, I've tried so many things now, I don't even remember what actually saved something --albeit incorrectly --to the database in one of my previous iterations with the for loops.)
    I'm currently poring through Sqlite and Javascript tomes to see if I can find what's missing but if anything else jumps out at you with the corrected code, I'd appreciate some ideas.
    Jeane

  • Oracle 8i stored functions

    Can one use collections as parameters to an Oracle 8i stored function and can it return a collection? Does anyone have examples?

    Can one use collections as parameters to an Oracle 8i stored function and can it return a collection? Does anyone have examples?

  • How to get result of Select from stored function.

    I need to get result of select from a stored function.
    In the end of my stored function I makes final select (four columns).
    How it can be retrived from function?

    Hi,
    A function can only return one value, but it sounds like you want to return 4 values.
    The one value that you return can be a record, with many columns, such as a ROWTYPE, or a TYPE that you define.
    You can return an XMLTYPE that has whatever elements you want.
    You can write a procedure that has several OUT parameters. (You can have OUT parameters in a function, but a lot of people find that confusing.)
    In very special circumstance, you might consider returning a string that is a delimited list of values, such as '7639,SMITH,,17-DEC-1980'.
    Someoneelse has a good point.
    We could give a better answer if you ask a specific question, like:
    "I have this table ...
    I want a function such that, if I call it with these parameters ... I get ...
    but if I call it like this ... then I get ..."

  • How to get BOOLEAN from STORED FUNCTION

    We are calling legacy PLSQL stored procedures and functions via named queries. This has worked fine so far, but there are some functions which return the type 'BOOLEAN'. e.g.
    FUNCTION some_function( some_argument IN NUMBER) RETURN BOOLEAN;
    Where the return type is BOOLEAN calling the named query fails with
    Local Exception Stack:
    Exception [TOPLINK-4002] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.DatabaseException
    Internal Exception: java.sql.SQLException: ORA-06550: line 1, column 13:
    PLS-00382: expression is of wrong type
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Error Code: 6550
    A couple of threads have hinted that what we are trying to do is not possible:
    How to get BOOLEAN from STORED PROCEDURES
    Re: Creating Named Query: from OracleCallableStatement
    This would possibly be due to 'restriction in the OCI layer'. Can anyone help? Is there really now way to call a valid PLSQL stored function via a named query when the return type is BOOLEAN?
    thanks

    I can't comment on possible issues you might have with the driver, but if it can be done in JDBC, it should be possible in TopLink.
    TopLink has the StoredFunctionCall which extends the StoredProcedureCall but adds an unnamed ouput parameter in the first spot of its parameter list. You will need to get the databasefield and set its type to BOOLEAN ie:
      DatabaseField returnField = (DatabaseField)yourStoredFunctionCall.getParameters().firstElement();
            returnField.setName(name);
            returnField.setSqlType(Type.BOOLEAN);Be sure not to use the setType() method, as I believe TopLink will try to use the Type.BIT when a boolean class is used as the classtype.
    Best Regards,
    Chris

  • Getting result of stored functions in UCM components

    Hi,
    I have to create UCM component that executes function stored in DB and somehow "inject" it's return value to iDoc.
    How can I get return value of DB stored function?
    I managed to run the function, but I can not get it's return value.
    The only documentation I found is inside "documentation" folder from HowToComponents bundle, but there is no even javadoc for executeCallable that returns CallableResults.
    The queries I used are:
    { ? = call package.func(?) }
    or
    BEGIN ? := package.func(?); END;
    I added 2 parameters to these queries ( in queries html file)
    In both cases the function gets executed (I see changes in DB)
    after the execution I try to getInteger("param1_name") on returned CallableResults and recieve NullPointerException:
    Runtime error: java.lang.NullPointerException
    at oracle.jdbc.driver.OracleCallableStatement.getInt(OracleCallableStatement.java:1119)
    at intradoc.jdbc.JdbcCallableResults.getData(JdbcCallableResults.java:203)
    at intradoc.jdbc.JdbcCallableResults.getInteger(JdbcCallableResults.java:98)
    at DatabaseProvider.DatabaseProviderHandler.executeReservation(DatabaseProviderHandler.java:224) <------ calling getInteger("param1_name")
    the param1_name is not changed in iDoc.
    Thanks.
    Edited by: dpd on Jan 13, 2010 8:24 AM

    Hi,
    you can do this with just one script object.
    For example the "MyTexts" script object with the string variables and a function to return the values.
    var infotext1 = "Lorem ipsum dolor sit amet"
    var infotext2 = "Non eram nescius Brute cum"
    function getText(FieldNumber) {
              return eval("infotext" + FieldNumber);
    To populate a field you can call the function in the script object with an argument, which is the alias for the varaible number you want to return.
    You don't need to enter the full somExpression to your script object, the name is enough.
    Textfeld1.rawValue = MyTexts.getText(1);

Maybe you are looking for