Problem in Oracle Stored function?

Hi,
I have written this function in Oracle which takes every row of data from excel and updates the database.
CREATE OR REPLACE FUNCTION APD_MASS_UPLOAD_UNITS_FUNC
(PRODUCT_ID VARCHAR2,Product_Code VARCHAR2, str_Adpt_Grp VARCHAR2,str_Adpt_Type VARCHAR2,
str_PDC VARCHAR2,str_Release_ID VARCHAR2,str_Created_by VARCHAR2,
str_Last_Updated_By VARCHAR2, dt_created_Date VARCHAR2,dt_Last_Updated_Date VARCHAR2,
StrMonth1 VARCHAR2,strMth2 VARCHAR2,StrMth3 VARCHAR2,StrMth4 VARCHAR2,
StrMth5 VARCHAR2,StrMth6 VARCHAR2,Sample VARCHAR2)
RETURN VARCHAR2 IS
type Month_type is table of varchar(10) index by binary_integer;
str_month Month_Type;
Fac_ID VARCHAR2(20);
Org_ID VARCHAR2(20);
v_Fac_ID VARCHAR2(20);
v_Org_ID VARCHAR2(20);
Cnt_Number NUMBER;
i_POS NUMBER;
i_Month NUMBER;
i_UNIT NUMBER;
v_Count NUMBER;
i_Count NUMBER;
count_no NUMBER;
str_message varchar2(200);
tb_Spec_ID varChar2(20);
BEGIN
Select tblspecification.Spec_id into tb_Spec_ID
from tblspecification inner join tblrelease_xref
on tblspecification.spec_id = tblrelease_xref.spec_id
where tblspecification.spec_code = Product_code
And tblrelease_xref.release_id = APD_Get_Release_ID(str_PDC, str_Release_Id);
     IF TRIM(tb_Spec_ID) IS NOT NULL THEN
     IF Product_id <> tb_Spec_ID THEN
          str_Message := 'Mismatch:Spec Id and Product Code not matching';
               DBMS_OUTPUT.PUT_LINE(STR_MESSAGE);
               RETURN str_Message;
          END IF;
     ELSE
     str_Message := 'Spec_ID not found';
          RETURN str_Message;
     END IF;
--      dbms_output.put_line('hi1' );
IF TRIM(str_Message) IS NULL then
     SELECT COUNT(*) INTO v_count
     FROM TBLLINE_ADOPT_PLAN
     WHERE SPEC_ID = Product_ID
     AND ADOPT_GROUP = str_Adpt_Grp
     AND ADOPT_TYPE = str_Adpt_Type
AND RELEASE_ID = APD_Get_Release_ID(str_PDC,str_Release_ID);
     Count_No := v_count;
IF Count_No = 0 THEN
INSERT INTO TBLLINE_ADOPT_PLAN
          (SPEC_ID,ADOPT_GROUP,ADOPT_TYPE,RELEASE_ID,SAMPLES,
CREATED_BY,CREATED_DATE,LAST_UPDATED_BY,LAST_UPDATED_DATE,SAMPLE_ONLY_IND, GRID_TYPE_CD) VALUES
(Product_ID,str_Adpt_Grp ,str_Adpt_Type,
APD_Get_Release_ID(str_PDC,str_Release_Id),0,str_Created_By,
TO_DATE(dt_Created_Date,'DD/MM/YYYY'),str_Last_Updated_By,
TO_DATE(dt_Last_Updated_Date,'DD/MM/YYYY'),'N','C');
          COMMIT;
     END IF;
str_Month(1) := strMonth1;
str_Month(2) := strMth2;
str_Month(3) := strMth3;
str_Month(4) := strMth4;
str_Month(5) := strMth5;
str_Month(6) := strMth6;
     SELECT FACILITY_ID INTO v_Fac_ID
     FROM TBLADOPT_GROUP_CSC
     WHERE ADOPT_GROUP = str_Adpt_Grp;
Fac_ID := v_Fac_ID;
SELECT ORG_ID INTO Org_ID
     FROM APD_DV_PRODUCT_V
     WHERE SPEC_ID = Product_ID;
     ORG_ID := v_ORG_ID;
SELECT COUNT(*) INTO v_Count
     FROM TBLPROD_CSC
     WHERE PROD_SPEC_ID = Product_ID;
     IF Count_No = 0 THEN
INSERT INTO TBLPROD_CSC(PROD_SPEC_ID,CSC_FACILITY_ID,PROFIT_CENTER_CD,
DEFAULT_IND, CREATED_BY, CREATED_DATE, LAST_UPDATED_BY, LAST_UPDATED_DATE) VALUES
(Product_ID , Fac_ID,Org_id, 'N', str_Created_by ,To_date ( dt_Created_Date,'DD/MM/YYYY') ,
str_Last_updated_by , To_Date (dt_Last_Updated_Date ,'DD/MM/YYYY'));
          COMMIT;
END IF;
FOR i_Count in 1..6 LOOP
i_Pos := Instr(str_month(i_Count),'-');
i_Month := TO_NUMBER(SUBSTR(str_Month(i_Count),1,i_Pos-1));
i_Unit := TO_NUMBER(SUBSTR(Str_Month(i_Count),i_Pos + 1));
Cnt_Number := GET_COUNT_UNITS(Product_ID,str_Adpt_Grp,str_Adpt_Type,str_Release_ID,str_PDC,str_Month(i_Count));
          DBMS_OUTPUT.PUT_LINE(cNT_NUMBER);
IF Cnt_Number = 0 then
INSERT INTO TBLLINE_ADOPT_UNITS (SPEC_ID,ADOPT_GROUP,ADOPT_TYPE,MONTH,UNITS,CREATED_BY,
CREATED_DATE,LAST_UPDATED_BY,LAST_UPDATED_DATE) VALUES (Product_ID,str_Adpt_Grp,
str_Adpt_Type,i_Month,i_Unit,str_Created_By ,to_date(dt_Created_Date ,'DD/MM/YYYY'),
          str_Last_Updated_By,to_date( dt_Last_Updated_Date ,'DD/MM/YYYY'));
               COMMIT;
ELSIF Cnt_Number = 1 Then
          UPDATE TBLLINE_ADOPT_UNITS A
SET A.UNITS = I_UNIT
WHERE A.SPEC_ID || A.ADOPT_GROUP IN
(SELECT B.SPEC_ID || B.ADOPT_GROUP
FROM TBLLINE_ADOPT_PLAN B
WHERE A.SPEC_ID = B.SPEC_ID AND
A.ADOPT_GROUP = B.ADOPT_GROUP AND
B.ADOPT_TYPE = str_Adpt_Type AND
B.ADOPT_GROUP = str_Adpt_Grp AND
B.SPEC_ID = Product_ID and
B.RELEASE_ID = APD_Get_Release_ID(str_PDC,str_Release_Id ) AND
A.MONTH = i_Month);
               COMMIT;
          ELSE
str_Message := 'Record count more than one';
               RETURN str_Message;
     END IF;
     END LOOP;
IF TO_NUMBER(Sample) <> 0 Then
UPDATE TBLLINE_ADOPT_PLAN
SET SAMPLES = TO_NUMBER(Sample)
WHERE SPEC_ID = Product_ID AND
ADOPT_GROUP = str_Adpt_Grp AND
ADOPT_TYPE = str_Adpt_Type AND
RELEASE_ID = APD_Get_Release_ID(str_PDC,str_Release_Id);
          COMMIT;
END IF;
     str_Message := 'Updated';
     END IF;
     COMMIT;
     DBMS_OUTPUT.PUT_LINE(STR_MESSAGE);
     RETURN str_message;
END;
The problem is after I call this function from excel and after running when I check the table the record is not inserted.Pls help...

Check the chapter on PL/SQL in http://www.oracle.com/technology/tech/php/pdf/underground-php-oracle-manual.pdf
The bottom of page 134 (in the current 1.4 version) has an example of calling a PL/SQL function.
-- cj
PS. General reminder to everyone, if you are using PHP 4.4, please upgrade the OCI8 code as also described in the manual above.

Similar Messages

  • Oracle stored functions and where clauses

    Hello everybody,
    I need to call an Oracle stored function and at the same time do a select on
    the result of the query, it works well except when I use a where clause. I
    am connecting to Oracle 8.1.7 through OLEDB using the Oracle provider for
    OLEDB distributed with this Oracle version.
    Here is the query I am doing:
    select * from {call MC.SEC.QryTermbases(?, ?) where ID = ?}
    If I remove the where clause it works well but I need to use the where. I
    know that I could pass the parameter to the procedure instead of doing that
    in the select but there are places where I can not do that since the SQL
    query is generated dynamically. The code above is just a demo.
    Thanks very much for your help,
    Jose.

    Thanks for answering, it is actually possible to do a select on the return of a function, I have tested it with other than "select *" and it has worked well. What has not worked for me is using a "where" clause. That is "select" without "where" has worked but not with the "where".
    I also suspect that it does not work but similar queries work well in MSSQL 2000 and Interbase 6.0 so I thought may be there was a way to do that with Oracle. That is in MSSQL I can treat the result of a function as a normal table and I can do the same thing with a stored procedure that returns a recordset in Interbase.
    Thanks again for answering,
    Jose.

  • Oracle stored function

    Does anybody know how to call Oracle stored function from asp

    This webpage covers this topic
    http://support.microsoft.com/support/kb/articles/Q174/9/81.ASP
    Regards Padraic

  • Problem Calling Oracle Stored Procedure From JAVA

    Hello all. I've been banging my head against this all day:
    Here's the procedure I'm calling:
    GetIDsByLatLonRadius(inLatitude IN NUMBER,
    inLongitude IN NUMBER,
    inRadius IN NUMBER,
    inTableName IN VARCHAR2,
    inIDColName IN VARCHAR2,
    inLatColName IN VARCHAR2,
    inLonColName IN VARCHAR2,
    LocationIDs OUT HomesCom_Types.GenericCursorType,
    ErrorNo OUT VARCHAR2);
    And here's the JAVA code:
    public Hashtable GetInRadius(Hashtable inStruct)
    ResultSet locationIDs = null;
    Hashtable outputHash = new Hashtable();
    float latitude = (float) 30.429;
    float longitude = (float) -84.2585;
    float radius = (float) 10;
    try {
    CallableStatement proc = con.prepareCall("{ call GEOCODING.getidsbylatlonradius(?,?,?,?,?,?,?,?,?) }");
    proc.setFloat(1,latitude);
    proc.setFloat(2,longitude);
    proc.setFloat(3,radius);
    proc.setString(4,"demographics_school");
    proc.setString(5,"onboard_id");
    proc.setString(6,"geocoding_latitude");
    proc.setString(7,"geocoding_longitude");
    proc.registerOutParameter(8,OracleTypes.CURSOR);
    proc.registerOutParameter(9,OracleTypes.VARCHAR);
    proc.execute();
    locationIDs = (ResultSet) proc.getObject(1);
    if (locationIDs != null)
    outputHash.put("query",locationIDs);
    else
    outputHash.put("query","LOCATION ID WAS NULL");
    catch(SQLException sqlException) {  
    System.out.println(
    "The following error occured in reading " +
    "from the table: "
    + sqlException);
    outputHash.put("error",sqlException.getMessage());
    return outputHash;
    This catches and the sqlException I get is: Unhandled sql type
    I'm not a java expert and I'm completely stuck at this point, so I figured a few more eyes on it might help.
    Thanks in advance,
    Danny

    Danny,
    Don't print merely the error message, print the whole stack trace.
    Then post it here.
    What java version are you using?
    What JDBC driver and version are you using?
    What Oracle database version are you using?
    Is the code from a Java ServerPages (JSP) or from a Java Stored Procedure (JSP)?
    I guess "HomesCom_Types" is one of your PL/SQL packages or routines, right?
    If so, then you can't use it in JDBC, you must define a database type using the command:
    create or replace type ...But in later versions of the Oracle database, the REF CURSOR type is built-in.
    Check the Oracle documentation for more details.
    Good Luck,
    Avi.

  • Problem with Oracle Form Function

    Hi All,
    I have built different forms Custom In Oracle Financials, but when I click in the menu option this error appears "Function not available to this responsability. Change responsibilities. or contact your System Administrator". So I can't see the form on the screen.
    Please, I need your help.
    Regards Mariano.-

    Hi,
    Did you register this custom form under a custom responsibility?
    Are you able to access other custom forms from the same responsibility? If not, make sure your CUSTOM_TOP is set in the application env file and bounce the application services.
    Note: 305792.1 - Function Not Available To This Responsibility Error After Creating and Registering a New Form
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=305792.1
    Note: 553014.1 - R12 Error 'Function not available to this responsibility' When Trying to Access Custom Form
    https://metalink2.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=553014.1
    Regards,
    Hussein

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

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

  • Oracle stored ns and where clauses

    Hello everybody,
    I need to call an Oracle stored function and at the same time do a select on the result of the query, it works well except when I use a where clause. I am connecting to Oracle 8.1.7 through OLEDB using the Oracle provider for
    OLEDB distributed with this Oracle version.
    Here is the query I am doing:
    select * from {call MC.SEC.QryTermbases(?, ?) where ID = ?}
    If I remove the where clause it works well but I need to use the where. I know that I could pass the parameter to the procedure instead of doing that in the select but there are places where I can not do that since the SQL
    query is generated dynamically. The code above is just a demo.
    Thanks very much for your help,
    José.

    Thanks for answering, it is actually possible to do a select on the return of a function, I have tested it with other than "select *" and it has worked well. What has not worked for me is using a "where" clause. That is "select" without "where" has worked but not with the "where".
    I also suspect that it does not work but similar queries work well in MSSQL 2000 and Interbase 6.0 so I thought may be there was a way to do that with Oracle. That is in MSSQL I can treat the result of a function as a normal table and I can do the same thing with a stored procedure that returns a recordset in Interbase.
    Thanks again for answering,
    Jose.

  • 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

  • Return 2 values (string, number) multiple rows, from java stored function

    I would like to return 2 values (String, number prefered but String, String will work) from a java stored function.
    I was able to successfully return a varray of varchar2 values but I was wondering if it is possible to return 2 values by using a varray?
    Is it even possible? I tried using combinations of types which included a varray of objects (with 2 attributes) or a type as table of objects but I couldn't figure out how in my java code to set these values. Also what would my java function return type be and what Oracle type would map to it?
    Any help and examples or pointers would be great.
    Thanks,
    Dennis

    Thanks to all. I finally figured it out through all the pieces on the web.
    Here is what worked for me. First create 2 oracle types. One object type to represent the "columns" I will pass back:
    CREATE OR REPLACE TYPE COST_OBJ AS OBJECT (COST_NAME NVARCHAR2(50), COST_VALUE number ) NOT FINAL
    note: make sure the "strings" are defined as NVARCHAR2 or Java will puke if it is just VARCHAR2.
    Then create a table type to hold your objects defined as following:
    CREATE OR REPLACE TYPE COST_OBJ_TABLE is table OF COST_OBJ
    Then create the oracle stored function that is a wrapper to the java function:
    CREATE OR REPLACE FUNCTION get_Costs(Name VARCHAR2, evalDate VARCHAR2, fuelCodeID NUMBER) return COST_OBJ_TABLE
    is language java name
    'com.costs.storedProcedures.Cost.getCosts(java.lang.String, java.lang.String, int) return oracle.sql.ARRAY'
    Once that is done, Oracle is ready. The Java function looks something like this:
    public ARRAY getCosts(String name, String evalDate, int fuelCodeID) {
    DBAccess da = getDBAccess();
    // get a handle on the connection
    Connection conn = da.getConnection();           
    // The stuff that will be returned should be as type object array
    // make it to the size of the number of fuelcomponents passed in
    Object[] returnStuff = new Object[3];
    // create the type of struct that is defined on the database
    StructDescriptor structDesc =
    StructDescriptor.createDescriptor("CY_UMAP.COST_OBJ", conn);
    for (int i = 0; i < returnStuff .size(); i++) {
    Object[] costValues = new Object[]{
         "This is object " + i,
         new Integer ( i ) };
    STRUCT cost_obj = new STRUCT(structDesc, conn, costValues);
    returnStuff[i] = cost_obj;
    ArrayDescriptor x_ad = ArrayDescriptor.createDescriptor (
    "CY_UMAP.COST_OBJ_TABLE", conn);
    ARRAY x_array = new ARRAY(x_ad, conn, returnStuff);
    return x_array;
    I hope this helps others.
    Dennis

  • 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

  • Oracle XML functions return tags for null columns.

    I am currently writing a SOAP Message base on a SQL statement formatted as XML. However, I am having problems with Oracle XML functions not returning tags for null columns as seen in my example below. Is the a way to get Oracle XML functions to return empty tags for null column?
    CREATE TABLE FOREXAMPLE_TABLE (COLUMN_1 VARCHAR2 (4000),
    COLUMN_2 VARCHAR2 (4000),
    COLUMN_3 VARCHAR2 (4000));
    INSERT INTO FOREXAMPLE_TABLE (COLUMN_2)
    VALUES ('This column is not null');
    COMMIT;
    SELECT XMLELEMENT ( "soap:Envelope",
    XMLATTRIBUTES ( 'http://schemas.xmlsoap.org/soap/envelope/' AS "xmlns:soap"),
    XMLELEMENT ( "soap:Body",
    XMLATTRIBUTES ( 'http://Custom_Column/types/' AS "xmlns:ns1"),
    XMLELEMENT ( "ns1:New_Instance",
    XMLELEMENT ( "ns1:Input_XMLDoc",
    XMLFOREST(fe.COLUMN_1 as "Column_1",
    fe.COLUMN_2 as "Column_2",
    fe.COLUMN_3 as "Column_3"))))) as xml
    FROM FOREXAMPLE_TABLE fe
    The results returned from the select statement.
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body xmlns:ns1="http://Custom_Column/types/"><ns1:New_Instance>
    <ns1:Input_XMLDoc><Column_2>This column is not null</Column_2>
    </ns1:Input_XMLDoc></ns1:New_Instance></soap:Body></soap:Envelope>
    The desired results for the select statement.
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body xmlns:ns1="http://Custom_Column/types/"><ns1:New_Instance>
    <ns1:Input_XMLDoc><Column_1></Column_1>
    <Column_2>This column is not null</Column_2><Column_3></Column_3>
    </ns1:Input_XMLDoc></ns1:New_Instance></soap:Body></soap:Envelope>
    jeeman

    An alternative may be be to use xmlconcat instead of xmlforest:
    Time Start: 30.06.2007 18:52:41
    PL/SQL procedure successfully completed.
    michaels>  select xmlelement
              ("soap:Envelope",
               xmlattributes
                      ('http://schemas.xmlsoap.org/soap/envelope/' as "xmlns:soap"),
               xmlelement
                    ("soap:Body",
                     xmlattributes ('http://Custom_Column/types/' as "xmlns:ns1"),
                     xmlelement ("ns1:New_Instance",
                                 xmlelement ("ns1:Input_XMLDoc",
                                             xmlconcat (xmlelement("Column_1", fe.column_1),
                                                        xmlelement("Column_2", fe.column_2),
                                                        xmlelement("Column_3", fe.column_3)
              ).extract('.').getstringval() as xml
      from (select null column_1, 'This column is not null' column_2,
                   null column_3
              from dual) fe
    XML                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
      <soap:Body xmlns:ns1="http://Custom_Column/types/">                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
        <ns1:New_Instance>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 
          <ns1:Input_XMLDoc>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
            <Column_1/>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
            <Column_2>This column is not null</Column_2>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
            <Column_3/>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
          </ns1:Input_XMLDoc>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
        </ns1:New_Instance>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
      </soap:Body>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    </soap:Envelope>                                                                                             

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

  • Stored function call problem

    I've been trying out this feature as it was shown in adfdeveloperguide. that is, on page 3-26/27
    StoredFunctionCall functionCall = new StoredFunctionCall();
    functionCall.setProcedureName("READ_EMPLOYEE");
    functionCall.addNamedArgument("EMP_ID");
    functionCall.setResult("FUNCTION_RESULT", String);
    ReadObjectQuery query = new ReadObjectQuery();
    query.setCall(functionCall);
    query.addArgument("EMP_ID");
    Vector args = new Vector();
    args.addElement(new Integer(44));
    Employee employee = (Employee) session.executeQuery(query, args);
    in my version it is:
    StoredFunctionCall fCall = new StoredFunctionCall();
    fCall.setProcedureName("f_milos");
    fCall.addNamedArgument("x");
    fCall.setResult("FUNCTION_RESULT", String.class);
    ReadObjectQuery query = new ReadObjectQuery();
    query.setCall(fCall);
    query.addArgument("x");
    Vector args = new Vector();
    args.addElement(new Integer(2));
    String result = (String) session.executeQuery(query,args);
    where f_milos is my stored function. as for the session, I got it in this way
    Session session=new SessionFactory("META-INF/sessions.xml", "default").acquireSession();
    like it was done in my session bean.
    dunno, maybe thats the source of the problem.
    now, when I come to executeQuery, following error pops:
    javax.faces.el.EvaluationException: Exception [TOPLINK-6029] (Oracle TopLink - 10g Release 3 (10.1.3.0.0) (Build 060118)): oracle.toplink.exceptions.QueryException
    Exception Description: A reference class must be provided.
    Query: ReadObjectQuery().
    help?

    Well, previously you were calling getDBTransaction() on an explicit Application Module object, whereas now, you do:
    st = getDBTransaction().createCallableStatement("begin ? := "stmt";end;",0);which means that your code must be inside of an application module in order to work. Do you see the difference?
    I'll mention that you shouldn't generally be doing DB calls in your ViewController/UserInterface layer - DB code belongs in the model.
    John

  • 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

Maybe you are looking for