Calling a member procedure??

Ive got to write a member procedure for actioned_child but ive been banging my head against the wall when it comes to calling the procedure i was wondering how i would go about calling it.
CREATE OR REPLACE TYPE BODY child_objtyp AS
MEMBER PROCEDURE actioned_child (new_actioned in VARCHAR2, date_actioned in DATE) IS
BEGIN
self.actioned := new_actioned;
self.actioned_date := date_actioned;
IF actioned = 'N' THEN
SELF.actioned := 'Y';
SELF.actioned_date := SYSDATE;
COMMIT;
END IF;
END actioned_child;
END;
SHOW ERRORS;

Your code does not make sense. There is a default constructor that you are ignoring. This will typically be called to instantiate an object of the class you have defined. E.g.
declare
  --// define object variable
  obj child_objtyp;
begin
  --// construct the object and set the properties
  obj := new child_objtyp( 'Y', sysdate );
end;The question is now how does your member procedure actioned_child() impacts the constructed object. Simply overwriting the property values that it was constructed with, does not make much sense.
Instead the following approach makes more sense. And note no ugly and silly write-reserved-words-in-uppercase standard - instead apply the de facto standards used in all programming languages from Java to .Net:
SQL> create or replace type TChildObject is object(
  2          actioned        varchar2(1),
  3          created         date,
  4          action_date     date,
  5 
  6          constructor function TChildObject( createDate date default sysdate )
  7          return self as result,
  8 
  9          member procedure Action,
10          member procedure UnAction,
11          member function Display return varchar2
12  ) final;
13  /
Type created.
SQL>
SQL> create or replace type body TChildObject is
  2 
  3          constructor function TChildObject( createDate date default sysdate )
  4          return self as result is
  5          begin
  6                  self.created := createDate;
  7                  self.actioned := 'N';
  8                  return;
  9          end;
10 
11          member procedure Action is
12          begin
13                  self.actioned := 'Y';
14                  self.action_date := sysdate;
15          end;
16 
17          member procedure UnAction is
18          begin
19                  self.actioned := 'N';
20                  self.action_date := null;
21          end;
22 
23          member function Display return varchar2 is
24          begin
25                  return(
26                          'Created='||to_char(self.created,'hh24:mi:ss' ) ||
27                          ' Actioned='||self.Actioned||
28                          ' ActionedOn='||to_char(self.action_date,'hh24:mi:ss' )
29                  );
30          end;
31  end;
32  /
Type body created.
SQL>
SQL> declare
  2          obj     TChildObject;
  3  begin
  4          --// construct object
  5          obj := new TChildObject();
  6          DBMS_OUTPUT.put_line( obj.Display );
  7 
  8          --// action object
  9          obj.Action();
10          DBMS_OUTPUT.put_line( obj.Display );
11 
12          --/// unaction object
13          obj.UnAction();
14          DBMS_OUTPUT.put_line( obj.Display );
15 
16          --// no destructor can be called as
17          --// PL/SQL handles garbage collection for
18          --// out of scope objects automatically
19  end;
20  /
Created=18:15:33 Actioned=N ActionedOn=
Created=18:15:33 Actioned=Y ActionedOn=18:15:33
Created=18:15:33 Actioned=N ActionedOn=
PL/SQL procedure successfully completed.
SQL>

Similar Messages

  • Calling a Member Function from within a Cursor in a Procedure

    Hello Folks
    I'm a newbie to oracle and am in the process of learning 10G. My question is:
    I created a type called row_po and defined a member function getCost() which returns the total cost of the order with line items as nested table, which i intend to call from within a procedure. In the procedure my SELECT returns multiple records and hence I need to use a cursor. For each record I've got to display the order_no, qty and order_cost (qty and order_cost are part of a line items nested table). I'm able to get to the order_no and qty but don't know how to call the member function to get the order_cost. Here's my procedure:
    CREATE OR REPLACE PROCEDURE get_podet(part_num in number)
    AS
    CURSOR c2 is
    SELECT *
    FROM tab_po po, TABLE (po.LineItemList_nestab) L
    WHERE L.PartNo = part_num;
    BEGIN
    FOR crec in c2 LOOP
    DBMS_OUTPUT.PUT_LINE('ORDER NUMBER: ' || crec.PONo);
    DBMS_OUTPUT.PUT_LINE('LINE QTY: ' || crec.Qty);
    {color:#ff0000}*DBMS_OUTPUT.PUT_LINE('ORDER VALUE: ' || ''); -- order_cost which should be returned from the member function i've mentioned --*
    {color}END LOOP;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('Failed' || 'SQLCODE: ' || SQLCODE);
    DBMS_OUTPUT.PUT_LINE('SQL ERROR MESSAGE ' || SQLERRM);
    END;
    The line in red is where i want to call my function getCost() which is a member of tab_po po as mentioned in my SELECT.
    Any thoughts highly appreciated.
    Thanks and Regards

    One way would be to just run the query in a editor (sqlplus or toad) and see whats the column name.
    Before that can you show us the structure of the type.
    If you declare a table type without an object then the default column name is COLUMN_VALUE else the object filed name is taken.
    Example without object in table type.
    SQL> create or replace type tbl as table of integer
      2  /
    Type created.
    SQL> create or replace function fn return tbl
      2  as
      3     ltbl tbl;
      4  begin
      5     select level bulk collect into ltbl
      6       from dual
      7    connect by level <= 10;
      8
      9     return ltbl;
    10  end;
    11  /
    Function created.
    SQL> select * from table(fn)
      2  /
    COLUMN_VALUE
               1
               2
               3
               4
               5
               6
               7
               8
               9
              10
    10 rows selected.
    Example with object in table type.
    SQL> create or replace type obj as object(no integer)
      2  /
    Type created.
    SQL> create or replace type tbl as table of obj
      2  /
    Type created.
    SQL> edit
    Wrote file afiedt.buf
      1  create or replace function fn return tbl
      2  as
      3     ltbl tbl;
      4  begin
      5     select obj(level) bulk collect into ltbl
      6       from dual
      7    connect by level <= 10;
      8     return ltbl;
      9* end;
    10  /
    Function created.
    SQL> select * from table(fn)
      2  /
            NO
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.Edited by: Karthick_Arp on Jan 13, 2009 5:00 AM

  • Errors in calling Oracle stored procedure using java CallableStatement

    Hello,
    I have an oracle stored procedure below, it has been tested in PL/SQL without errors. During testing, in_c_file_type="F"; out_n_seqno_freeformat=120139596 and out_n_seqno_commaseprated is null (empty in value column).
    When I run the program in Eclipse (windows xp), error messages is below: (It stopped at line 'cstme.execute();' )
    Message:ORA-06550: line 1, column 26: PLS-00103: Encountered the symbol "" when expecting one of the following:   . ( ) , * @ % & | = - + < / > at in is mod remainder not   range rem => .. <an exponent (**)> <> or != or ~= >= <= <>   and or like LIKE2_ LIKE4_ LIKEC_ as between from using ||   indicator multiset member SUBMULTISET_ The symbol ", was inserted before "" to continue. Error code:6550 SQL statement:65000 {code} Does anyone know what cause the error? It seems like something is missing in the stored procedure. But the stored procedure passes the test in the PL/SQL. The oracla driver I used is Oracle thin driver. Oracle version is 10.2.g Thanks in advance. northcloud {code} create or replace procedure SP_GET_SEQNO_2( in_c_file_type in char, out_n_seqno_freeformat out integer, out_n_seqno_commaseprated out integer) is n_seqno_commaseprated    integer; n_seqno_freeformat        integer; begin if in_c_file_type ='F' THEN  SELECT message_counter.nextval INTO n_seqno_freeformat FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_freeformat,empty_clob(),empty_clob()); elsif in_c_file_type ='C' THEN  SELECT message_counter.nextval INTO n_seqno_commaseprated FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_commaseprated,empty_clob(),empty_clob()); else SELECT message_counter.nextval INTO n_seqno_freeformat FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_freeformat,empty_clob(),empty_clob()); SELECT message_counter.nextval INTO n_seqno_commaseprated FROM dual; insert into temp_stroperations (record_id,OUTPUT_STR,INPROCESS_STR) values (n_seqno_commaseprated,empty_clob(),empty_clob()); end if; out_n_seqno_freeformat        := n_seqno_freeformat; out_n_seqno_commaseprated    := n_seqno_commaseprated; end SP_GET_SEQNO_2; {code} ----- A part of java code I used to call the stored procedure is here. {code} String escapeString = "{call SP_GET_SEQNO_2 (? ? ?)}"; CallableStatement cstme = null; try { cstme = con.prepareCall(escapeString); cstme.setString(1, "F"); cstme.registerOutParameter(2, java.sql.Types.INTEGER); cstme.registerOutParameter(3, java.sql.Types.INTEGER); cstme.execute(); int seqNoFreeformat=0, seqNocommasepreted=0; seqNoFreeformat = cstme.getInt(2); seqNocommasepreted = cstme.getInt(3); System.out.println ("In ConvertXML.processStoredProcedure(), seqNoFreeformat= "+seqNoFreeformat+";seqNocommasepreted="+seqNocommasepreted); } catch (SQLException e) { //System.out.println ("In ConvertXML.processStoredProcedure(), SQLException: "+e); System.err.println("Message:"+e.getMessage()); System.err.println("Error code:"+e.getErrorCode()); System.err.println("SQL statement:"+e.getSQLState()); log.log(Level.INFO, log.getName() + " - SQLException : "+e); } {code}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    es5f2000 wrote:
    jschell wrote:
    That works?I dunno. The below definitely works, but like I said, I've only
    ever done it with one output parameter (and that has always
    been a ResultSet).
    String callableQuery = "{?= call my_package.my_call(?, ?)}"
    Yes I have done that and at least in terms of my code it wasn't just a result set.
    But not with two.

  • Calling Oracle stored procedure from java

    The following query calls a stored procedure TRANSLATE_ZONEPATH_ID defined in a package MT by the user MTDBA. currentZone is a member variable of the class, and currently has value 1
    This query works just fine when I run it from SQLPlus* connected as MTDBA.
    But from java, the following piece throws exception saying "invalid column name"
    String query = "SELECT MTDBA.MT.TRANSLATE_ZONEPATH_ID('"+currentZone+"') "
    + "FROM DUAL ";
    try
    Statement stmt = conn.createStatement();
    ResultSet rst = stmt.executeQuery(query);
    if (rst.next())
    fullName = rst.getString(1);
    stmt.close();
    Anyone got any clue ?

    I always use CallableStatement to execute a stored procedure or function in a database (Oracle).
    try this:
    <code>
    CallableStatement cs = dbConnection.prepareCall("{ ? =
    MTDBA.MT.TRANSLATE_ZONEPATH_ID(?)}");
    cs.setString(1, currentZone);
    cs.registerOutParameter(1, Types.VARCHAR);
    cs.executeUpdate();
    fullname = cs.getString(1);
    cs.close();
    </code>
    There is also a jdbc forum, where your should post this kind of problem :-)
    Hope this help's
    ThK

  • Member function and member procedure inside an object type in Oracle.

    Hi All,
    Please do have a look at these codes and help me understand. I have no idea about this member function and member procedure. How do they work? Please explain me about this.
    Regards,
    BS2012
    create type foo_type as object (
      foo number,
      member procedure proc(p in number),
      member function  func(p in number) return number
    create type body foo_type as
      member procedure proc(p in number) is begin
        foo := p*2;
      end proc;
      member function func(p in number) return number is begin
        return foo/p;
      end func;
    end;
    /

    Methods are just like functions or procedures in a package, except they're not in a package, their part of an object type.
    The object has attributes (which are the variables declared in it).
    To use such an object you would do things like this...
    SQL> set serverout on
    SQL>
    SQL> declare
      2    v_foo foo_type;
      3    v_val number;
      4  begin
      5    v_foo := foo_type(20); -- instantiate the object and initialize the object attributes
      6    v_foo.proc(20); -- call the object method (proc)
      7    v_val := v_foo.func(4); -- call the object method (func)
      8    dbms_output.put_line(v_val);
      9  end;
    10  /
    10
    PL/SQL procedure successfully completed.The Type definition you've declared creates the object class, but not actually an object itself.
    To actually have an object you need to declare a variable of that object class type, and then instantiate it. When you instantiate the object you need to initialize all the attributes (generally you can pass null if required for each of them to initialize them).
    Once you have your object instantiated, you can call the methods within that object as demonstrated above, a bit like calling functions and procedures in a package, except they are methods within the object type itself, and therefore called directly by referencing them from the variable.
    The documentation goes into a lot more detail of objects if you look it up.

  • Error while calling a stored procedure using SQLJ

    I am calling a stored procedure defined inside a package through a SQLJ script. The first parameter of that procedure is a IN OUT parameter which is used as a ROWID for creating a cursor. That ROWID value is the same for every record in the table, thereby enabling us to create a cursor.
    When I give a hard-coded value as a parameter, I get an error stating that the assignment is not correct as the query is expecting a variable and not a literal. Hence I removed the hard-coded value and included a dymanic value in the SQLJ call.
    String strVal = "A";
    #sql{CALL ASSIGNMENTS_PKG.INSERT_ROW :{strVal},'SALARY_CODE_GROUP','BU',3,105,sysdate,1,sysdate,1,1)};
    Here "ASSIGNMENTS_PKG" is a package name and INSERT_ROW is the procedure.
    When the SQLJ program is run, I get an error stating:
    "PLS-00201: identifier 'A' must be declared"
    I read the error message, but I am not able to understand where I need to give the GRANT permission to.

    If you're using Oracle Provider for OLE DB (OraOLEDB) to execute this stored procedure, you need to set PLSQLRSet attribute. This attribute can be set in registry, connection string, or command object. Please refer to User Documentation for more information.

  • I am getting ORA-01403: no data found error while calling a stored procedur

    Hi, I have a stored procedure. When I execute it from Toad it is successfull.
    But when I call that from my java function it gives me ORA-01403: no data found error -
    My code is like this -
    SELECT COUNT(*) INTO L_N_CNT FROM TLSI_SI_MAST WHERE UPPER(CUST_CD) =UPPER(R_V_CUST_CD) AND
    UPPER(ACCT_CD)=UPPER(R_V_ACCT_CD) AND UPPER(CNSGE_CD)=UPPER(R_V_CNSGE_CD) AND
    UPPER(FINALDEST_CD)=UPPER(R_V_FINALDEST_CD) AND     UPPER(TPT_TYPE)=UPPER(R_V_TPT_TYPE);
         IF L_N_CNT >0 THEN
              DBMS_OUTPUT.PUT_LINE('ERROR -DUPlicate SI-1');
              SP_SEL_ERR_MSG(5,R_V_ERROR_MSG);
              RETURN;
         ELSE
              DBMS_OUTPUT.PUT_LINE('BEFORE-INSERT');
              INSERT INTO TLSI_SI_MAST
                   (     CUST_CD, ACCT_CD, CNSGE_CD, FINALDEST_CD, TPT_TYPE,
                        ACCT_NM, CUST_NM,CNSGE_NM, CNSGE_ADDR1, CNSGE_ADDR2,CNSGE_ADDR3,
                        CNSGE_ADDR4, CNSGE_ATTN, EFFECTIVE_DT, MAINT_DT,
                        POD_CD, DELVY_PL_CD, TRANSSHIP,PARTSHIPMT, FREIGHT,
                        PREPAID_BY, COLLECT_BY, BL_REMARK1, BL_REMARK2,
                        MCC_IND, NOMINATION, NOTIFY_P1_NM,NOTIFY_P1_ATTN , NOTIFY_P1_ADDR1,
                        NOTIFY_P1_ADDR2, NOTIFY_P1_ADDR3, NOTIFY_P1_ADDR4,NOTIFY_P2_NM,NOTIFY_P2_ATTN ,
                        NOTIFY_P2_ADDR1,NOTIFY_P2_ADDR2, NOTIFY_P2_ADDR3, NOTIFY_P2_ADDR4,
                        NOTIFY_P3_NM,NOTIFY_P3_ATTN , NOTIFY_P3_ADDR1,NOTIFY_P3_ADDR2, NOTIFY_P3_ADDR3,
                        NOTIFY_P3_ADDR4,CREATION_DT, ACCT_ATTN, SCC_IND, CREAT_BY, MAINT_BY
                        VALUES(     R_V_CUST_CD,R_V_ACCT_CD,R_V_CNSGE_CD,R_V_FINALDEST_CD,R_V_TPT_TYPE,
                        R_V_ACCT_NM,R_V_CUST_NM ,R_V_CNSGE_NM, R_V_CNSGE_ADDR1,R_V_CNSGE_ADDR2, R_V_CNSGE_ADDR3,
                        R_V_CNSGE_ADDR4,R_V_CNSGE_ATTN,     R_V_EFFECTIVE_DT ,SYSDATE, R_V_POD_CD,R_V_DELVY_PL_CD,R_V_TRANSSHIP ,R_V_PARTSHIPMT , R_V_FREIGHT,
                        R_V_PREPAID_BY ,R_V_COLLECT_BY ,R_V_BL_REMARK1 ,R_V_BL_REMARK2,R_V_MCC_IND,
                        R_V_NOMINATION,R_V_NOTIFY_P1_NM, R_V_NOTIFY_P1_ATTN, R_V_NOTIFY_P1_ADD1, R_V_NOTIFY_P1_ADD2,
                        R_V_NOTIFY_P1_ADD3, R_V_NOTIFY_P1_ADD4, R_V_NOTIFY_P2_NM, R_V_NOTIFY_P2_ATTN, R_V_NOTIFY_P2_ADD1,
                        R_V_NOTIFY_P2_ADD2, R_V_NOTIFY_P2_ADD3, R_V_NOTIFY_P2_ADD4, R_V_NOTIFY_P3_NM, R_V_NOTIFY_P3_ATTN,
                        R_V_NOTIFY_P3_ADD1, R_V_NOTIFY_P3_ADD2, R_V_NOTIFY_P3_ADD3, R_V_NOTIFY_P3_ADD4,
                        SYSDATE,R_V_ACCT_ATTN,R_V_SCC_IND,R_V_USER_ID,R_V_USER_ID
                        DBMS_OUTPUT.PUT_LINE(' SI - REC -INSERTED');
         END IF;

    Hi,
    I think there is a part of the stored procedure you did not displayed in your post. I think your issue is probably due to a parsed value from java. For example when calling a procedure from java and the data type from java is different than expected by the procedure the ORA-01403 could be encountered. Can you please show the exact construction of the call of the procedure from within java and also how the procedure possible is provided with an input parameter.
    Regards, Gerwin

  • Error while calling a stored procedure with OUT parameter.

    Hi,
    I am trying to call a Stored Procedure(SP) with an OUT parameter(Ref Cursor) from a third party tool. It is called using OLE-DB Data provider. In one database the procedure works fine but when I change the database the procedure call is giving following error.
    Distribution Object:     COM Error. COM Source: OraOLEDB. COM Error message: IDispatch error #3092. COM Description: ORA-06550: line 1, column 7:
         PLS-00306: wrong number or types of arguments in call to 'TEST1'
         ORA-06550: line 1, column 7:
         PL/SQL: Statement ignored.
    I am not able to find as to why is this happening. Please let me know any clues /help to solve this problem.
    Thanks in advance.

    If you're using Oracle Provider for OLE DB (OraOLEDB) to execute this stored procedure, you need to set PLSQLRSet attribute. This attribute can be set in registry, connection string, or command object. Please refer to User Documentation for more information.

  • With JDBC, calling a stored procedure with ARRAY as out parameter

    Hi,
    I want to use the data type ARRAY as an out parameter in an Oracle stored procedure. I want to call the stored procedure from
    my java program using JDBC.
    The problem it's i use a 8.1.7 client to acces with oci to a 7.1.3 Database.
    With this configuration I can get back a Cursor but not an Array.
    Does it's possible ?
    Thanks for your help !
    Michakl

    Originally posted by JDBC Development Team:
    It's very similar to other datatype except that it uses OracleTypes.ARRAY typecode and the value is mapped to a oracle.sql.ARRAY instance. The code looks as follows --
    cstmt.registerOutParameter (idx, OracleTypes.ARRAY, "VARRAY_TYPE_NAME_HERE");
    cstmt.execute ();
    ARRAY array = (ARRAY) cstmt.getObject (idx);
    Thanks for your reply.
    I have to use:-
    OracleCallableStatement cs1 = (OracleCallableStatement )conn.prepareCall
    ( "{call proj_array(?)}" ) ;
    for retrieving a collection as an OUT parameter.
    This gives me the errors:-
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Blob getBlob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Array getArray(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Clob getClob(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    C:\jdbc\VarraySQL.java:0: The method oracle.jdbc2.Ref getRef(int) declared in class oracle.jdbc.driver.OracleCallableStatement cannot override the method of the same signature declared in interface java.sql.CallableStatement. They must have the same return type.
    import java.sql.*;
    ^
    How do I get rid of these errors?
    null

  • Call a custom procedure in release 2

    How do I call a custom procedure as an HTML form action. I am using release 2. I have a proceudre in my table that runs an update statement when I submit the form. I can't get the form to properly call the procedure. Anyone Know.
    Thanks
    Cal

    why don't you create a dynamic page & just call that custom procedure inside.
    as you know your dynamic page will give you url to call from HTML forms action.
    /pls/portal/.......
    vikas

  • How to call a stored procedure from my JSP?

    Hi to all,
              I have a very simple jsp page and a simple sql server stored procedure!
              I need to call this stored procedure by passing two parameters.
              My result set will have 4 columns.
              I would really appreciate any input on how to issue this call to a SP.
              I am new to JSP.
              Regards,
              Sam
              

              Sam,
              BEA provides examples that are shipped with the product under
              <beahome>\weblogic700\samples\server\src\examples\
              Look at the jsp directory for JSP examples that access a database and look at
              say the jdbc\oracle\storedprocs.java for an example of java code calling out to
              a stored procedure - - by combining one of the jsp database examples with this
              stored procedure example you should be 'good to go'
              Chuck Nelson
              DRE
              BEA Technical Support
              

  • Returning Multiple Rows From DBAdapter Calling PL/SQL Procedure

    Oracle XE 10g Express Edition
    JDeveloper 11.1.1.2.0
    WebLogic Server 11g
    Guys,
    I have a table of orders, which I need to interrogate, and pass back any matching rows which meet certain criteria (e.g. status = 'OPEN').
    However, rather than create a DBAdapter using an Operation Type of "Peform an Operation on a Table/Select", I need to use an Operation Type of "Call a Stored Procedure or Function".
    I therefore need the procedure to return all the matching rows, rather than a single row.
    I have looked at declaring return parameters for the procedure of the following types:
    RECORD - is good because it allows me to return the elements of the row with their correct datatypes, but does not meet my needs because it will only support the return of a single row.
    VARRAY - good because it can contain many row elements, but not good because it only supports a single row return, and also because all elements of the VARRAY must be of the same data type.
    TABLE - good because it can contain many rows, but bad because each row can contain only two elements - the index element and the data element.
    I think I could first define a RECORD (to hold a row), and then define a TABLE, with the data element being the RECORD, but I have found JDeveloper very fussy indeed when dealing with 'non-standard' data types in the DBAdapter.
    Apologies if I am missing something obvious, but can anyone suggest a way of doing this?
    Many thanks in advance.
    Edited by: user2541290 on 17-Feb-2010 02:48

    Hi, I've been able to create process that seems to work. My platform is a but different but I don't think this is important for your question.
    Here is the PL/SQL code. Just make Db Adapter for Calling stored procedure and it returns all rows!
    Be aware of possible limitations on how manyrows you could return in one select! This can have severe impact on performance.
    Succes.
    Jos Baan
    CREATE OR REPLACE PACKAGE lab2_multiple_rows IS
    -- Author : 801455
    -- Created : 18-2-2010 8:05:52
    -- Purpose :
    -- Public type declarations
    TYPE rrows IS RECORD(
    mutdat DATE,
    opmerking VARCHAR2(20));
    TYPE trows IS TABLE OF rrows INDEX BY BINARY_INTEGER;
    -- Public constant declarations
    -- Public variable declarations
    -- Public function and procedure declarations
    FUNCTION retrows RETURN trows;
    END lab2_multiple_rows;
    CREATE OR REPLACE PACKAGE BODY lab2_multiple_rows IS
    -- Private type declarations
    -- Private constant declarations
    -- Private variable declarations
    -- Function and procedure implementations
    FUNCTION retrows RETURN trows IS
    lrows trows;
    lidx binary_integer := 1;
    BEGIN
    FOR rsql IN (SELECT t.* FROM jba_transactions t ORDER BY t.mutdat)
    LOOP
    lrows(lidx).mutdat := rsql.mutdat;
    lrows(lidx).opmerking := rsql.opmerking;
    lidx := lidx + 1;
    END LOOP;
    RETURN(lrows);
    END;
    BEGIN
    -- Initialization
    NULL;
    END lab2_multiple_rows;
    Edited by: Baan, Jos on 18-feb-2010 8:53

  • How to call a stored procedure from WorkShop

    Hello Everyone .. I'm quite new with WebLogic 8.1 & WorkShop, so please bare with
    me .. Today I'm simply trying to find out how to call a stored procedure from
    within workshop, using any of the DB Controls .. I see workshop provides a way
    create a Java Control, Rowset Control, but it wont easily allow for a stored procedured
    to be entered in place of the inline query .. Perhaps I've over looked it. Any
    advise on the best way to tackle this task will be appreciated.
    Atahualpa

    Atahualpa--
    Maybe this will help:
    http://edocs.bea.com/workshop/docs81/doc/en/workshop/guide/controls/database/conStoredProcedures.html
    Eddie
    Atahualpa wrote:
    Hello Everyone .. I'm quite new with WebLogic 8.1 & WorkShop, so please bare with
    me .. Today I'm simply trying to find out how to call a stored procedure from
    within workshop, using any of the DB Controls .. I see workshop provides a way
    create a Java Control, Rowset Control, but it wont easily allow for a stored procedured
    to be entered in place of the inline query .. Perhaps I've over looked it. Any
    advise on the best way to tackle this task will be appreciated.
    Atahualpa

  • Ssrs 2008 r2 report dataset call a stored procedure

    I am modifying an existing SSRS 2008 r2 report. In a dataset that already exists within the ssrs 2008 r2 report I need execute
    a stored procedure called StudentData and pass 3 parameter values to the stored procedure. The stored procedure will then return 5 values that are now needed for the modified ssrs report. My problem is I do not know how to have the dataset call the stored procedure
    with the 3 parameter values and pass back the 5 different unique data values that I am looking for.
    The basic dataset is the following:
    SELECT  SchoolNumber,
            SchoolName,
            StudentNumber,      
     from [Trans].[dbo].[Student]
     order by SchoolNumber,
              SchoolName,
              StudentNumber
    I basically want to pass the 3 parameters of SchoolNumber, SchoolName, and StudentNumber to the
    stored procedure called StudentData from the data I obtain from the [Trans].[dbo].[Student]. The 3 parameter values will be obtained from the sql listed above.
    The  columns that I need from the stored procedure called  StudentData will return the following data columns
    that I need for the report: StudnentName, StudentAddress, Studentbirthdate, StudentPhoneNumber, GuardianName.
    Thus can you show me how to setup the sql to meet this requirement I have?

    Hi wendy,
    After testing the issue in my local environment, we can refer to the following steps to achieve your requirement:
    Create three multiple parameters named SchoolNumber, SchoolName and StudentNumber in the report. Those available values from the basic dataset SchoolNumber, SchoolName and StudentNumber fields.
    If you want to pass multiple values parameter to stored procedure, we should create a function as below to the database:
    CREATE FUNCTION SplitParameterValues (@InputString NVARCHAR(max), @SplitChar VARCHAR(5))
    RETURNS @ValuesList TABLE
    param NVARCHAR(255)
    AS
    BEGIN
    DECLARE @ListValue NVARCHAR(max)
    SET @InputString = @InputString + @SplitChar
    WHILE @InputString!= @SplitChar
    BEGIN
    SELECT @ListValue = SUBSTRING(@InputString , 1, (CHARINDEX(@SplitChar, @InputString)-1))
    IF (CHARINDEX(@SplitChar, @InputString) + len(@SplitChar))>(LEN(@InputString))
    BEGIN
    SET @InputString=@SplitChar
    END
    ELSE
    BEGIN
    SELECT @InputString = SUBSTRING(@InputString, (CHARINDEX(@SplitChar, @InputString) + len(@SplitChar)) , LEN(@InputString)-(CHARINDEX(@SplitChar, @InputString)+ len(@SplitChar)-1) )
    END
    INSERT INTO @ValuesList VALUES( @ListValue)
    END
    RETURN
    END
    Use the query below to create a stored procedure, then use it to create a dataset to return 5 values:
    create proc proc_test(@SchoolNumber nvarchar(50),@SchoolName nvarchar(50),@StudentNumber nvarchar(50))
    as
    begin
    select StudnentName, StudentAddress, Studentbirthdate, StudentPhoneNumber, GuardianName
    from table7 where SchoolNumber in (SELECT * FROM SplitParameterValues (@SchoolNumber,','))  and SchoolName in(SELECT * FROM SplitParameterValues (@SchoolName,','))  and StudentNumber in (SELECT * FROM SplitParameterValues (@StudentNumber,','))
    end
    Right-click the new dataset to modify the parameter value in the Parameters pane as below:
    =join(Parameters!SchoolNumber.Value,",")
    =join(Parameters!SchoolName.Value,",")
    =join(Parameters!StudentNumber.Value,",")
    For more details about pass multi-value to stored procedure, please see:
    http://munishbansal.wordpress.com/2008/12/29/passing-multi-value-parameter-in-stored-procedure-ssrs-report/
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    If you have any feedback on our support, please click
    here.
    Katherine Xiong
    TechNet Community Support

  • How to call an Oracle Procedure and get a return value in Php

    Hi Everyone,
    Has anyone tried calling an Oracle procedure from Php using the ora functions and getting the return value ? I need to use the ora funtions (no oci)because of compatibility and oracle 7.x as the database.
    The reason why I post this here is because the ora_exec funtion is returning FALSE but the error code displayes is good. Is this a bug in the ora_exec funtion ?
    My code after the connection call is as follows:
    $cur = ora_open($this->conn);
    ora_commitoff($this->conn);
    $requestid = '144937';
    echo $requestid;
    $rc = ora_parse($cur, "begin p_ins_gsdata2
    (:requestid, :returnval); end;");
    if ($rc == true) {
    echo " Parse was successful ";
    $rc2 = ora_bind ($cur, "requestid", ":requestid", 32, 1);
    if ($rc2 == true) echo " Requestid Bind Successful ";
    $rc3 = ora_bind ($cur, "returnval", ":returnval", 32, 2);
    if ($rc3 == true) echo " Returnval Bind Successful ";
    $returnval = "0";
    $rc4 = ora_exec($cur);
    echo " Result = ".$returnval." ";
    if ($rc4 == false) {
    echo " Exec Returned FALSE ";
    echo " Error = ".ora_error($cur);
    echo " ";
    echo "ErrorCode = ".ora_errorcode($cur);
    echo "Error Executing";
    ora_close ($cur);
    The Oracle procedure has a select count from a table and it returns the number of records in that table. It's defined as:
    CREATE OR REPLACE procedure p_ins_gsdata2 (
    p_requestid IN varchar2 default null,
    p_retcode OUT varchar2)
    as
    BEGIN
    SELECT COUNT (*) INTO p_retcode
    FROM S_GSMRY_DATA_SURVEY
    WHERE request_id = p_requestid ;
    COMMIT;
    RETURN;
    END;
    Nothing much there. I want to do an insert into a table,
    from the procedure later, but I figured that I start with a select count since it's simpler.
    When I ran the Php code, I get the following:
    144937
    Parse was successful
    Requestid Bind Successful
    Returnval Bind Successful
    Result = 0
    Exec Returned FALSE
    Error = ORA-00000: normal, successful completion -- while
    processing OCI function OBNDRA
    ErrorCode = 0
    Error Executing
    I listed the messages on separate lines for clarity. I don't understand why it parses and binds o.k. but the exec returns false.
    Thanks again in advance for your help. Have a great day.
    Regards,
    Rudi

    retcode=`echo $?`is a bit convoluted. Just use:
    retcode=$?I see no EOF line terminating your input. Your flavour of Unix might not like that - it might ignore the command, though I'd be surprised (AIX doesn't).
    replace the EXEC line with :
    select 'hello' from dual;
    and see if you get some output - then you know if sqlplus commands are being called from your script. You didn't mentioned whether you see the banner for sqlplus. Copy/paste the output that you get, it will give us much more of an idea.

Maybe you are looking for