Help on CAST function, defining TYPE TABLE and using a REF cursor

Hi,
I have written a procedure (lookup) inside a package (lookup_pkg) as shown below.
Procedure has an output variable of type PL/SQL TABLE which is defined in the package.
I want to write a wrapper procedure lookupref to the procedure lookup to return a ref cursor.
CREATE OR REPLACE PACKAGE lookup_pkg AS
TYPE t_lookup_refcur IS REF CURSOR;
CURSOR c_lookup IS
     Select columns1,2,3,....100
               FROM A, B, C, D, E
               WHERE ROWNUM < 1;
TYPE t_lookup IS TABLE OF c_lookup%ROWTYPE;
Procedure lookup(id Number, o_lookup OUT t_lookup);
End lookup_pkg;
CREATE OR REPLACE PACKAGE BODY lookup_pkg As
Procedure lookup(id Number, o_lookup OUT t_lookup) IS
BEGIN
END lookup;
Procedure lookupref(id Number, o_lookupref OUT t_lookup_refcur) IS
o_lookup t_lookup;
BEGIN
lookup(id, o_lookup t_lookup);
OPEN t_lookup_refcur FOR
SELECT *
     FROM TABLE(CAST(o_lookup AS t_lookup));
Exception
End lookupref;
END lookup_pkg;
When I compile this procedure, I am getting invalid datatype Oracle error and
cursor points the datatype t_lookup in the CAST function.
1. Can anyone tell me what is wrong in this. Can I convert a PL/SQL collection (pl/sql table in this case) to PL/SQL datatype table or does it need to be a SQL datatype only (which is created as a type in database).
Also, to resolve this error, I have created a SQL type and table type instead of PL/SQL table in the package as shown below.
create or replace type t_lookuprec as object
               (Select columns1,2,3,....100
               FROM A, B, C, D, E
               WHERE ROWNUM < 1);
create or replace type t_lookup_tab AS table of t_lookuprec;
CREATE OR REPLACE PACKAGE BODY lookup_pkg As
Procedure lookup(id Number, o_lookup OUT t_lookup) IS
BEGIN
END lookup;
Procedure lookupref(id Number, o_lookupref OUT t_lookup_refcur) IS
o_lookup t_lookup;
BEGIN
lookup(id, o_lookup t_lookup);
OPEN t_lookup_refcur FOR
SELECT *
     FROM TABLE(CAST(o_lookup AS t_lookup_tab));
Exception
End lookupref;
END lookup_pkg;
When I compile this package, I am getting "PL/SQL: ORA-22800: invalid user-defined type" Oracle error and
points the datatype t_lookup_tab in the CAST function.
2. Can anyone tell me what is wrong. Can I create a type with a select statement and create a table type using type created earlier?
I have checked the all_types view and found that
value for Incomplete column for these two types are YES.
3. What does that mean?
Any suggestions and help is appreciated.
Thanks
Srinivas

create or replace type t_lookuprec as object
(Select columns1,2,3,....100
FROM A, B, C, D, E
WHERE ROWNUM < 1);You are correct that you need to use CREATE TYPE to use the type in SQL.
However unless I am mistaken you appear to have invented your own syntax for CREATE TYPE, suggest you refer to Oracle documentation.

Similar Messages

  • Problem declaring and using a REF CURSOR

    I'm having a real problem using a REF CURSOR type
    Here's the DECLARE and the start of the BEGIN I've so far developed.
    DECLARE
    TYPE r1 IS RECORD (
    szvcapc_pidm szvcapc.szvcapc_pidm%TYPE,
    szvcapc_term_code szvcapc.szvcapc_term_code%TYPE,
    szvcapc_request_no szvcapc.szvcapc_request_no%TYPE);
    szvcapc_rec r1;
    TYPE cursor_1 IS REF CURSOR RETURN r1;
    szvcapc_cv cursor_1;
    TYPE r2 IS RECORD (
    stvests_code stvests.stvests_code%TYPE
    stvests_rec r2;
    TYPE cursor_2 IS REF CURSOR RETURN stvests_rec;
    stvests_cv cursor_2;
    BEGIN
    OPEN szvcapc_cv FOR
    SELECT szvcapc_pidm, szvcapc_term_code, szvcapc_request_no
    FROM szvcapc
    WHERE szvcapc_passed_ind = 'Y'
    AND szvcapc_award_credits = 'N';
    LOOP
    FETCH szvcapc_cv INTO szvcapc_rec;
    EXIT WHEN szvcapc_cv%NOTFOUND;
    END LOOP;
    OPEN stvests_cv FOR
    SELECT stvests_code
    FROM stvests
    WHERE stvests_eff_headcount = 'Y';
    LOOP
    FETCH stvests_cv INTO stvests_rec;
    EXIT WHEN stvests_cv%NOTFOUND;
    END LOOP;
    SELECT *
    FROM (
    <snip>
    INNER JOIN stvests_rec
    ON SFBETRM.SFBETRM_ESTS_CODE = stvests_rec.STVESTS_CODE
    <snip>
    I later try to use the stvests_rec and szvcapc_rec in the main SELECT statement it doesn't recognise stvests_rec and szvcapc_rec as a "Table or View".
    I have to use a REF CURSOR as this code is ultimately for use in Oracle Reports.
    What am I doing wrong?

    > The reason I'm trying to use a REF CURSOR is that I was told that you
    couldn't use CURSORs in Oracle Reports.
    That does not change anything ito what happens on the Oracle server side. A cursor is a cursor is a cursor.
    Every single SQL winds up as a cursor. Each cursor has a reference handle to access and use. HOW this handle is used in the language differs. But that is a language issue and not an Oracle RDBMS issue.
    For example. An EXECUTE IMMEDIATE in PL/SQL creates a cursor handle and destroys it after use - automatically. An implicit cursor works the same. An explicit cursor you have the handle fetch from it and close from it when done.
    A ref cursor is simply a handle that can be returned to an external client - allowing that application to use the handle to fetch the rows.
    Do not think that a ref cursor is any different from the RDBMS side than any other cursor. The RDBMS does not know the difference. Does not care and nor should it.
    > I'm trying to reduce the hits on the database from nested selects by
    removing the dataset from the main SELECT statement and performing it only
    once outside and then referencing this previously collected dataset inside the
    main SELECT statement.
    Good stuff that you are considering SQL performance. But you need to make sure that you
    a) identify the performance inhibitor issue correctly
    b) address this issue correctly
    And you need to do that within SQL. Not PL/SQL. PL/SQL will always be slower at crunching data than SQL. For example, wanting to cache the data somehow to reduce the read overhead - that is exactly what the DB buffer cache does. It caches data. That is also exactly what the CBO will attempt - reduce the amount of data that needs to be read and processed.
    Not saying that the RDBMS can do it all. It needs help from you - in the form of a SQL that instructs it to process only the minimum amount of data required to get the required results. In the form of a sound physical design that provides optimal usage of data storage and access (like indexing, partitioning, clustering, etc).
    Bottom line - you cannot use a REF CURSOR to make a SQL go faster. A REF CURSOR is simply a cursor in the SQL Engine. A cursor is nothing but the "compiled-and-executable" code of a SQL "source program".

  • Passing values to an internal table and use it with the table painter

    Hi,
    I have seen this topic here before but the answers didn't help me. Maybe I,m doing something wrong.
    The problem is that I defined the following structure on the |Types| tab of the |Global Definitions| section:
    TYPES: BEGIN OF DETAILS,
           EBELP  TYPE EKPO-EBELP,
           BSMNG  TYPE EBAN-BSMNG,
           LFDAT  TYPE RM06P-LFDAT,
    END OF DETAILS.
    Then defined the following definition on the |Global Data| section:
    WA_DETAILS TYPE STANDARD TABLE OF DETAILS WITH HEADER LINE
    The problem is that when I try to assign a value to one of the fields in the program code like this:
    LOOP AT WA_EKPO.
         WA_DETAILS-EBELP = WA_EKPO-EBELP.
         WA_DETAILS-EMATN = WA_EKPO-EMATN.
         MODIFY WA_DETAILS.
    ENDLOOP.
    gives me the following error:
    "WA_DETAILS" is not an internal table -the "OCCURS n" specification is missing.
    Then if I add the "OCCURS 10" to the definition of the Global Data the error "OCCURS 10" is not expected.
    How can I define, assign values and use as a parameter an internal table defined with types for use it with the table painter?

    Hi,
    if it is one record in wa_details. you can directly write as follows..
    REPORT  ZCR_TEST1                               .
    TYPES: BEGIN OF details,
              ebelp TYPE ekpo-ebelp,
              bsmng TYPE eban-bsmng,
              lfdat TYPE rm06p-lfdat,
              ematn TYPE ekpo-ematn,
           END OF details.
    DATA: wa_details TYPE STANDARD TABLE OF details WITH HEADER LINE,
          wa_ekpo    TYPE STANDARD TABLE OF details WITH HEADER LINE.
    wa_details-ebelp = '1'.
    append wa_details.
    wa_ekpo-ebelp = '3'.
    append wa_ekpo.
    LOOP AT wa_ekpo.
      wa_ekpo-ebelp = wa_details-ebelp.
      wa_ekpo-ematn = wa_details-ematn.
      modify wa_ekpo.
    endloop.
    Normally it wont be one record, so u need to put <b>read statement with key</b> in LOOP and ENDLOOP.
    Regards,
    Sriram

  • DB proc - do you need to create a table to pass a ref cursor record type?

    I want to pass a limited selection of columns from a large table through a DB procedure using a REF CURSOR, returning a table rowtype:
    CREATE OR REPLACE package XXVDF_XPOS_DS021_ITEMS AS
         TYPE XXVDF_XPOS_DS021_ITEM_ARRAY
         IS REF CURSOR
         return XXVDF_XPOS_DS021_ITEM_TABLE%ROWTYPE;
    Do I need to create this dummy table?
    I can't get a TYPE to work, where the type is an OBJECT with the desired columns in it.
    So a dummy empty table will sit in the database...
    Is there another way?
    thanks!

    You can use RECORD type declaration:
    SQL> declare
      2   type rec_type is record (
      3    ename emp.ename%type,
      4    sal emp.sal%type
      5   );
      6   type rc is ref cursor return rec_type;
      7   rc1 rc;
      8   rec1 rec_type;
      9  begin
    10   open rc1 for select ename, sal from emp;
    11   loop
    12    fetch rc1 into rec1;
    13    exit when rc1%notfound;
    14    dbms_output.put_line(rec1.ename || ' ' || rec1.sal);
    15   end loop;
    16   close rc1;
    17  end;
    18  /
    SMITH 800
    ALLEN 1600
    WARD 1250
    JONES 2975
    MARTIN 1250
    BLAKE 2850
    CLARK 2450
    SCOTT 3000
    KING 5000
    TURNER 1500
    ADAMS 1100
    JAMES 950
    FORD 3000
    MILLER 1300or use, for example, VIEW to declare rowtype:
    SQL> create view dummy_view as select ename, sal from emp;
    View created.
    SQL> declare
      2   type rc is ref cursor return dummy_view%rowtype;
      3   rc1 rc;
      4   rec1 dummy_view%rowtype;
      5  begin
      6   open rc1 for select ename, sal from emp;
      7   loop
      8    fetch rc1 into rec1;
      9    exit when rc1%notfound;
    10    dbms_output.put_line(rec1.ename || ' ' || rec1.sal);
    11   end loop;
    12   close rc1;
    13  end;
    14  /
    SMITH 800
    ALLEN 1600
    WARD 1250
    JONES 2975
    MARTIN 1250
    BLAKE 2850
    CLARK 2450
    SCOTT 3000
    KING 5000
    TURNER 1500
    ADAMS 1100
    JAMES 950
    FORD 3000
    MILLER 1300 Rgds.

  • Can you input records to a COLLECTION TYPE object and use it as a table??

    My PL/SQL stored procedure creates a list of employee number and phone number records. I don't want to store them in a table. I will be passing this list from one procedure to another in my package.
    I created the object type (record) and collection type (table) using this statements.
    CREATE TYPE obj_emp_phone_rec AS OBJECT
         emp_number   NUMBER,
         emp_phone    VARCHAR2(100)
    CREATE TYPE obj_emp_phone_recs_table AS TABLE OF obj_emp_phone_rec
    /Thing is, can I use the obj_emp_phone_recs_table "table type" as a table?
    I.e. can I insert records to this in the package procedure and pass reference to it in called sub-procedures.
    i.e. something like this
    PACKAGE BODY abc IS
      PROCEDURE kdkddk IS
      BEGIN
        -- Insert records to the  obj_emp_phone_recs_table
        obj_emp_phone_recs_table(1).emp_number := '1';
        obj_emp_phone_recs_table(1).emp_phone   := '0774949494';
        obj_emp_phone_recs_table(2).emp_number := '234';
        obj_emp_phone_recs_table(2).emp_phone   := '285494';
        -- Pass the table to the sub procedure
        xyx(obj_emp_phone_recs_table);
      END kdkddk;
    END abc;If so how to insert to the obj_emp_phone_recs_table ???
    Nothing on the net. In the Net I found only where u define a normal table's column as an object type and then inserting records to it.
    Any help would be greatly appreciated.
    Edited by: user12240205 on Oct 6, 2011 2:08 AM

    mhouri > drop type obj_emp_phone_recs_table;
    Type dropped.
    mhouri > drop type obj_emp_phone_rec ;
    Type dropped.
    mhouri > CREATE TYPE obj_emp_phone_rec AS OBJECT
      2    (
      3       emp_number   NUMBER,
      4       emp_phone    VARCHAR2(100)
      5    )
      6  /
    Type created.
    mhouri > CREATE TYPE obj_emp_phone_recs_table AS TABLE OF obj_emp_phone_rec
      2  /
    Type created.
    mhouri > create or replace procedure p1(pin_tab IN obj_emp_phone_recs_table)
      2  is
      3   begin
      4     for j in 1..pin_tab.count
      5     loop
      6      dbms_output.put_line('record number '||j ||'-- emp number --'||pin_tab(j).emp_number);
      7     end loop;
      8 
      9  end p1;
    10  /
    Procedure created.
    mhouri > create or replace procedure p2
      2  is
      3  lin_tab  obj_emp_phone_recs_table := obj_emp_phone_recs_table();
      4  begin
      5  FOR i IN 1 .. 5
      6     LOOP
      7        lin_tab.extend;
      8        lin_tab(i) := obj_emp_phone_rec(i, 'i-i-i');
      9     END LOOP;
    10 
    11    p1(lin_tab);
    12 
    13  end p2;
    14  /
    Procedure created.
    mhouri > set serveroutput on
    mhouri > exec p2
    record number 1-- emp number -- 1                                                                                                                                                                                                                         
    record number 2-- emp number --2                                                                                                                                                                                                                         
    record number 3-- emp number --3                                                                                                                                                                                                                         
    record number 4-- emp number --4                                                                                                                                                                                                                         
    record number 5-- emp number --5                                                                                                                                                                                                                         
    PL/SQL procedure successfully completed.Best Regards
    Mohamed Houri

  • Insertion in XML Type table and fetching the data in Pro*C

    I have a Pro*C program written which populate one temp table. That temp table is used for writing the records to a flat file and then the table is purged by this program itself. Now my requirement is to write a new procedure in this progarm which simultaneously populate new XML Type table. Also i have to write some other procedures/functions to query the XML type table
    in Pro*C. I am new to XML part of database. Could somebody suggest how to go ahead with this problem

    Please check the Oracle Database 10g: XML DB Developer's Guild for example.

  • Help on Business Function "Reporting Financials 2" and its impact

    Hi All,
    I am looking at 'SAP Help' for Reporting Financials 2 (EhP4).
    http://help.sap.com/erp2005_ehp_04/helpdata/EN/6a/cd7dbd74694af3ac13b3c24a10def4/frameset.htm
    basically I want to use the standard extractor 0FI_AA_20 FI-AA: Transactions and Depreciation . when i try to run the extractor i get an error saying: Business Function "Reporting Financials 2" is not switched on
    In order to use the new data sources the pre requisites are:
    1. SAP Enhancement Package 4 for SAP ERP 6.0
    2. Activated the Reporting Financials 2 business function.
    The EnP4 is already implemented what i have do next is to activate the business function.
    Can any one help me with more details on what all gets activated with this business function 'Reporting Financials 2' and its impact.
    With Best Regards
    Shilpa.

    Hi,
    in SFW5 you can get an overview over the business functions. There you could activate the appropriate Business Function.
    But I would recommend you strongly before to read some information and documentation about business functions and the enhancement package concept.
    Regards,
    Markus

  • Call type table and service threshold value

    I see for the call types where the service threshold value is set to default, the service threshold is shown as NULL in the Call type table. 
    Howver when you decide to override it, it shows the actual value.  Any reason why Cisco decided to have a NULL value for default and not the numeric one . (it is actually 20s)

    Please go through documentaton of all features that you required
    For India Payroll
    40ECS
    40CLM
    40LTR
    40EPF
    40PTX
    PPMOD
    DTAKT
    40ECC
    40ACK
    LGMST
    TARIFF
    For Time Management
    SCHKZ
    TMSTA
    QUOMO
    WWEEK
    WRKHR
    VTART
    MASEX
    HRSIF
    LDAYW
    TIMTA
    are some features, go to each and individual feature through PE03 and check the documentation , you can able to get an idea about the return values
    >If you want to see the complete list of feature
    >Go to PE03 give ***** at the field of feature name and press F4
    OR
    >Please run the program program RPUMKD00 ( through SE38)
    >Give value ***** in the FROM  field and keep the TO filed blank   for the selection of FeaturesLeave the Person Responsible fields blank
    >Give 1 for as in put  to the field Type of feature
    >Give 1 for as in put  to the field Version
    >Give 1 for as in put  to the field Activation indicator
    >and execute (F8)
    Select the required one from the list and go for documentation
    Edited by: Sujith Nambiar on Sep 17, 2010 2:48 PM

  • User defined types,refnums,and program autoupdating

    Hello all the Masters,
       I am working now on a large program.And tried to do the next thing: to put  controls and indicators at the cluster,
    make it "strict type definition",and pass a reference to this cluster to the sub vi's.The main point is,that the sub vi's update
    the values of this cluster too.Here I come to the point : I wanted that if would be easy to add/remove controls to/from the cluster.
       The solution that I "wired" is attached.It uses  .xml file for indication,if the datatype was updated,and if yes,promts user to choose
    which variable he wants to update.
      I would like to know your opinion about this "trick".
     Thanks,
    Michael .
    LV 8.2 at Windows & Linux
    Attachments:
    update_averaging_index.zip ‏49 KB

    Sorry about been not clear: no indicators,just controls at cluster.
    The main goal was to do the whole program easy to make changes,such as changing datatypes.Now,the vi's that posted performs a check,
    if there were a change at the datatype,if yes,the vi promts the programmer what variables he wants to pass now to be updated and saves the selection.
          I am shure that I am not the first one who thinked about it,just wanted to hear opnion of people who more experienced than me.
      Thanks for reply.
    Message Edited by mishklyar on 01-14-2008 03:10 PM
    LV 8.2 at Windows & Linux

  • Creating a master table and using it to populate other tables.

    Hi everyone.
    I am a novice at using Numbers and I need some direction.
    I am looking to create a master table with information for our summer camp. This table will include vital information such as name, address, etc. along with cabin assignments, tuitions received, and more.
    We will separate this information into smaller tables that different portions of that master table for specific use. Such as: names and addresses for leaders, names and tuitions for registration, etc.
    My goal is to type the information into the master table and have it update the other tables automatically. Can someone direct me how to format the master and sub tables so that this is possible?
    I would greatly appreciate it and it will greatly reduce the record-keeping time for our camp.
    Thank You!
    Roy

    Hi Roy,
    Welcome to the Numbers discussions. You are giving us a tall order, especially when we don't know your level of experience in programming spreadsheets.
    Here are a couple of basics to start the conversation...
    In normal spreadsheet programming, we Pull data from one location into another, we don't Push it or Send it. This should help you to understand that the hard work is done in the sub tables, not the master.
    You will use LOOKUP functions to pull the data to your sub tables. Download the Numbers User Guide and the Formulas and Functions User Guide and read up on them.
    In your master table, make sure you have one column that uniquely identifies each participant so it will be easy to reference that person in your sub tables.
    Regards,
    Jerry

  • Get Total of a Column of Advanced Table and use it in Controller in OAF

    I have an advanced table on my custom page. I am calculating total of a column in my footer. I am acheiving this using the standard functionality of advanced table by setting total value property of my column to "TRUE" and displaying the total in the tablefooter components.
    In addition to this I want to retreive the total value from my footer and use it in my Controller for further validations but I am not able to acheive this.
    I tried some code already present in the Community for the same but nothing turned out right for me.
    Can anyone please help me on this.

       Hi there ,
      You can manually add the values of each row of a  column and make use of the value obtained in your controller .
    Here is the logic ,
    1) get the vo instnace attached to that table .
    2) Loop through every single row in the table .
    3) get the value and sum up the value and use it in your controller .
    int fetchRowCount = vo.getFetchRowCount();  
    voRowImpl row = null;  
    int count =0;
    if (fetchRowCount  > 0) { 
    RowSetIterator iter = vo.createRowSetIterator("Iter"); 
    iter.setRangeStart(0);
      iter.setRangeSize(fetchBidderRowCount);
       for (int i = 0; i < fetchBidderRowCount; i++) {
      row = voRowImpl iter.getRowAtRangeIndex(i);
       //use RowImpl getters   10.   
             Number personId = row.getPersonId();
    count =personId+count;         // add each and every value and have in variable
    iter.closeRowSetIterator();
    Regards ,
    Keerthi

  • MS Access, ODBC and SPs returning ref cursor

    I have some functions and procedures in a package returning ref cursors that work fine in my C++ batch applications. I would like for the GUI to be able to call these as well.
    Unfortunately, we are using Access as the front end (for now), and we have not been able to get the ref cursors to work. Is this supported? We are using Oracle 8.0.5 on Solaris, and our clients is Access 97 on NT using Intersolv's ODBC driver.
    My procedure looks something like:
    package jec is
    procedure open_sale_cur(
    p_client_id number,
    sale_curvar out sale_curtype)
    is begin
    open sale_curtype for select ... ;
    end;
    end;
    And the Access code looks like this:
    strSql = "begin jec.open_sale_cur(27, ?); end;"
    qdfTemp = conMain.CreateQueryDef("", strSql)
    qdfTemp.Parameters(0).Direction = dbParamOutput
    qdfTemp.Execute()
    This is the error when Execute() is called:
    PLS-00306: wrong number or types of arguments in call to 'OPEN_SALE_CUR'
    I am not an Access programmer; I am simply passing along this information. Any help would be greatly appreciated.

    We tried the {call...} syntax originally, but when we use it, we get an Oracle syntax error for the statement
    SELECT * FROM {call ...}
    Apparently Access prepends "SELECT..." before passing the SQL text to Oracle.
    This is also the case for procedures with normal scalars, such as numbers, returned as OUT values. When we use anon PL/SQL syntax and "?" placeholders with such procedures, they work. When we use {call ...} syntax or omit OUT placeholders, they do not.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Justin Cave ([email protected]):
    I suspect that you want to simply execute the statement
    strSql = {call open_sale_cur( 27 )}
    The ODBC driver will automatically figure out that there's an output parameter which is a ref cursor and return that as the result set. Note that you may want to download the latest 8.0.5 ODBC driver (8.0.5.10 I believe) if there are any problems.
    Justin<HR></BLOCKQUOTE>
    null

  • Retrieving nested table columns through a REF CURSOR in php

    Hello.
    I have been able to execute REF CURSORS returned by pl/sql functions succesfully with php. I have also been able to bind collections to the input/output of pl/sql functions/procedures.
    However, what I am unable to do, is to execute a cursor returned by a pl/sql function that has one of the columns a named datatype (a simple one-dimensional nested table):
    create type stab is table of varchar2(255);
    create table lp_landing (
    token varchar2(255),
    text varchar2(512),
    country varchar2(255),
    creator varchar2(255),
    is_active char(1),
    css_file char(1),
    autofollowing stab default stab(),
    constraint lp_landing_pk primary key (token)) organization index
    nested table autofollowing store as lp_landings_af_nt
    (constraint autofollowing_pk primary key (nested_table_id,column_value)) organization index compress
    function landings_usercountry (in_uname in lp_users.uname%type, in_country in lp_country.cname%type) return Landing_curType
    is
    ret Landing_curType;
    begin
    open ret for
    select * --token,text,country,creator,is_active,css_file,tab2str(autofollowing) as autofollowing
    from lp_landing
    where country = (select country
    from lp_permissions
    where country = in_country and uname = in_uname);
    return ret;
    end landings_usercountry;
    here is the php:
    $sql = 'BEGIN :res := LP_PKG.landings_usercountry(:user, :country); END;';
    $stmt = oci_parse($c, $sql);
    $cursor = oci_new_cursor($c);
    oci_bind_by_name($stmt,':user',$name, 32);
    oci_bind_by_name($stmt,':country',$country, 32);
    oci_bind_by_name($stmt,':res', $cursor, -1, OCI_B_CURSOR);
    $name = "root";
    $country = "Spain";
    try {
       @oci_execute($stmt);
       $m = oci_error($stmt);
       if($m){
           throw new Exception($m['message'], $m['code']);
       }else{
           @oci_execute($cursor);
           $m = oci_error($cursor);
           if($m){
               throw new Exception($m['message'], $m['code']);
           }else{
               while ( $entry = oci_fetch_object($cursor) ) {
                    var_dump($entry);
    } catch (Exception $e) {
       print_r($e);
    With "select *" in the function, the autofollowing column (of datatype stab) fails to bind, giving an ORA-932 error. The workaround for the moment is to convert the nested table to a comma delimited string (via the tab2str function).
    However, I would like to be able to tell php to accept a collection within the cursor, but I cannot figure out how to do this.
    Any ideas?
    thx in advance

    yes, it is an ORA-932:
    Warning: oci_fetch_object() [function.oci-fetch-object]: ORA-00932: inconsistent datatypes: expected CHAR got ADT in /home/apolion/apache2/htdocs/old/test1.php on line 104

  • Performance problem with sproc and out parameter ref cursor

    Hi
    I have sproc with Ref Cursor as an OUT parameter.
    It is extremely slow looping over the ResultSet (does it record by record in the fetch).
    so I have added setPrefetchRowCount(100) and setPrefetchMemorySize(6000)
    pseudo code below:
    string sqlSmt = "BEGIN get_tick_data( :v1 , :v2); END;";
    Statement* s = connection->createStatement(sqlStmt);
    s->setString(1, i1);
    // cursor ( f1 , f2, f3 , f4 , i1 ) f for float type and i for interger value.
    // 5 columns as part of cursor with 4 columns are having float value and
    // 1 column is having int value assuming 40 bytes for one rec.
    s->setPrefetchRowCount (100);
    s->PrefetchMemorySize(6000);
    s->registerOutParam(2,OCCICURSOR);
    s->execute();
    ResultSet* rs = s->getCursor(2);
    while (rs->next()) {
    // do, and do v slowly!
    }

    Hi,
    I have the same problem. It seems, when retrieving cursor, that "setPrefetchRowCount" is not taking into account by OCCI. If you have a SQL statement like "SELECT STR1, STR2, STR3 FROM TABLE1" that works fine but if your SQL statement is a call to a stored procedure returning a cursor each row fetching need a roudtrip.
    To avoid this problem you need to use the method "setDataBuffer" from the object "ResultSet" for each column of your cursor. It's easy to use with INT type and STRING type, a lit bit more complex with DATE type. But until now, I'm not able to do the same thing with REF type.
    Below a sample with STRING TYPE (It's assuming that the cursor return only one column of STRING type):
    try
      l_Statement = m_Connection->createStatement("BEGIN :1 := PACKAGE1.GetCursor1(:2); END;");
      l_Statement->registerOutParam(1, oracle::occi::OCCINUMBER, sizeof(l_CodeErreur));
      l_Statement->registerOutParam(2, oracle::occi::OCCICURSOR);
      l_Statement->executeQuery();
      l_CodeErreur = l_Statement->getNumber(1);
      if ((int) l_CodeErreur     == 0)
        char                         l_ArrayName[5][256];
        ub2                          l_ArrayNameSize[5];
        l_ResultSet  = l_Statement->getCursor(2);
        l_ResultSet->setDataBuffer(1, l_ArrayName,   OCCI_SQLT_STR, sizeof(l_ArrayName[0]),   l_ArrayNameSize,   NULL, NULL);
        while (l_ResultSet->next(5))
          for (int i = 0; i < l_ResultSet->getNumArrayRows(); i++)
            l_Name = CString(l_ArrayName);
    l_Statement->closeResultSet(l_ResultSet);
    m_Connection->terminateStatement(l_Statement);
    catch (SQLException &p_SQLException)
    I hope that sample help you.
    Regards                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Ref cursor to object  and return to ref cursor

    how i will call object type from refcursor and return value to ref cursor .

    I need a help. please help me.
    takes oracle object types as input/output.
    PROCEDURE createserviceorder(
    P_serviceorder IN serviceorder,
    P_serviceid in out p_sm_type.serviceid,
    P_serviceorderid out p_sm_type.serviceorderid,
    Returnstatus out callstatus);
    The serviceorder, callstatus are oracle object types.
    The wrapper procedure for this API would be something like the example with pseudo code below
    PROCEDURE createserviceorderwrapper(
    P_serviceorder IN REFCURSOR,
    P_serviceid in out p_sm_type.serviceid,
    P_serviceorderid out p_sm_type.serviceorderid,
    Returnstatus out REFCURSOR)
    Map from ref cursor P_serviceorder to oracle object for serviceorder;
    Map from other data types to local variables;
    Call createserviceorder (pass the parameters here and get output….);
    Map output callstatus to its equivalent REF CURSOR variable;
    Return callstatus (and other out parameters if any )as REF CURSORS;
    }

Maybe you are looking for

  • Can't open Email Settings after firmware updated a...

    Hi, I've upgrated my E71 with new 3.00 firmware yesterday and then restored phone memory from saved backup (yes, restoring is still a great pain for Nokia phones owners - you know, not all the software installed restores and so on, but that's another

  • Trying to call HANA procedure via ABAP

    Hi everyone,    I am using ABAP in Eclipse in order to call a HANA procedure within a BPC process chain. While referring to an SCN blog written by Baris Cekic, I have put together a working ABAP Class. This works as my proxy to a functioning HANA sto

  • Export CLOB field (long= 4202083) to a file with UTL_FILE.PUT or PUT_LINE

    Hello, I'm trying to export a CLOB field to a txt file. It's a xml string in the CLOB. I have used different methods but the only which i can use is PUT, PUT_LINE. But: - PUT does only export the 32565 characters. I see that the output of l_pos is 42

  • Opening arw files from Sony SLT a33 in PSE 9

    Hi All, I'm trying to edit photos from my newly purchased Sony SLT a33 but Camera Raw kept coming up with "wrong file type" error messages.  When I tried to open up arw files from my Sony a350 it works fine. The only way so far for me to edit my Sony

  • How can we create a work schedule number

    Dear pp masters i have one issue in our client side, we are in repetitive manufacturing(with mrp),how to create the work schedule number,,,, ,in that we have see only semifinished not finished,what is the t-code pls reply back thanks in adavance deve