Test a SP with the object type

Hi, I have a MS in which I created an object of TYPE and through multiple values as param.

TYPE typ_clint_id_rec AS OBJECT
( CLIENT_ID VARCHAR2(20);

TYPE typ_clinet_id_tab AS TABLE OF  typ_clint_id_rec;
SP signature
PROCEDURE test( in_username IN char
                          in_client_name IN   typ_clinet_id_tab,
                          in_out_cur IN OUT out_cursor)
;
Now, I'm testing the PC like this:
declare

ref_cursor sys_refcursor;
in_client_name typ_clinet_id_tab := typ_clinet_id_tab ();
begin

in_client_name := typ_clinet_id_tab ('AAA','BBB');
test(in_username=> 'test' , in_client_name=>in_client_name ,in_out_cur => ref_cursor);
end;
But it gives wrong number or types of arguments in the call to typ_clinet_id_tab?

Can someone tell me what is wrong with that?

Aashish

Each attribute of your object to table table must consist of the typ_clint_id_rec object.

So the data must be wrapped as follows;

typ_clinet_id_tab (typ_clint_id_rec'AAA'),typ_clint_id_rec('BBB'));

Tags: Database

Similar Questions

  • Where I'm going wrong with the object Type

    Hello world
    I am trying to insert data into a table using a type of object
    Here is my code
    Please help me where I'm wrong...
    Thank you

    Code for the object. Type
    create or replace type emp_rec_type as object 
    ( empno number
     ,name varchar2(20)
     ,salary number(7,2)
     ,job varchar2(10)
     ,hiredate date
     ,commno number(7,2)
     ,deptno number(4));
     
    Now I want to insert data into the table like this
    begin
      insert into emp5 values(emp_rec_type(5,'jack',1000,'salesman','12-apr-2000',300.00,20));
    end;
    I don't want to create a variable of the object... Initialization type I want to create just to insert the value using the default constructor.

    Concerning
    Prost

    You can create the table of the object:

    create table emp5 of emp_rec_type;
    

    Kind regards
    Sayan M.

  • Function returning the tree used with the object type

    Hi guys!

    I'm fighting for some time now of a function that should return the tree structure of the employees. Let me clarify...
    I have a table say Manager and employees (two columns for an example)
    MANAGER_ID
    EMPLOYEE_ID

    Example:

    MAN_ID - 1; EMPLOYE_ID - 2;
    MAN_ID - 2; EMPLOYE_ID - 3;
    MAN_ID - 2; EMPLOYE_ID - 4;
    MAN_ID - 4; EMPLOYE_ID - 5

    The purpose of my function is back for a specified MAN_ID everyone in the tree...

    Example:

    RETURN_TREE (1) return {2,3,4,5};
    RETURN_TREE (2) returns {3,4,5};
    RETURN_TREE (4) returns {5};

    How to get there?

    With respect,

    PsmakR

    And use BULK COLLECT or the COLLECT function to build the collection:

    create type emp_table as table of number(6);
    /
    
    DECLARE
     v_emp_list emp_table;
    BEGIN
     select cast(collect(employee_id) as emp_table)
     into v_emp_list
     from employees
     connect by prior employee_id = manager_id
     start with manager_id = :p_man_id
    
     -- or
     /*
     select employee_id
     bulk collect into v_emp_list
     from employees
     connect by prior employee_id = manager_id
     start with manager_id = :p_man_id
     */
    END;
    /
    
  • Define a map or ORDER method for the object type

    Hi gurus

    I created an object and then its type and then I use this object and type based on line, see below:

    Create the object

    CREATE OR REPLACE

    TYPE test_object

    IS

    OBJECT

    (

    next_appearance_dt DATE, - next_appearance_dt

    youth_adult VARCHAR2 (5) - youth_adult

    ) ;


    /

    Create the object Type

    CREATE or REPLACE TYPE t_docket_object IS TABLE OF THE test_object;

    /

    Create function Pipeline

    FUNCTION to CREATE or REPLACE f_report (p_dt date, p_c_cd VARCHAR2)
    return t_test_object pipeline
    IS
    BEGIN
    FOR J IN)
    Select distinct test_object)
    next_appearance_dt,--862,
    'YOUTH '.
    ) AS test_object
    Jen.next_appearance base
    WHERE 1 = 1
    AND (base.next_appearance_dt = p_dt)
    AND (base.circuit_point_cd = p_c_cd)
    - and cse.information_id = 322
    -ORDER 15 - alias_name
    )

    loop
    PIPE ROW (J.test_object);
    END loop;
    END;

    /

    Run function

    SELECT * FROM TABLE (F_REPORT (TO_DATE('25-sep-2015','dd-mon-yyyy'),'1 '))

    Error

    ORA-22950: cannot ORDER objects without map or ORDER method

    ORA-06512: at "F_REPORT", line 5

    22950 00000 - "cannot ORDER objects without map or ORDER method.

    * Cause: an object type must have a defined for map or ORDER method

    all comparisons other than equality and inequality comparisons.

    * Action: Define a map or ORDER method for the object type

    I know the reason of this error and the reason is that I use the clause separate in my pipeline service, but do not know how to get rid of this error...

    Confuse you the type of table with the object type. He forge

    Select test_object (next_appearance_dt) test_object

    Not:

    Select t_test_object (next_appearance_dt) test_object

    Then:

    SQL > CREATE OR REPLACE
    FUNCTION f_report (DATE p_dt 2,
    3 P_C_CD VARCHAR2
    4                   )
    5 t_test_object of RETURN
    6 IN PIPELINE
    7 EAST
    BEGIN 8
    9 FOR (IN) v_rec
    10 WITH () DID
    11. SELECT TO_DATE('01-jan-2015','dd-mon-yyyy') NEXT_APPEARANCE_DT
    the double 12
    13                                  )
    14 select test_object (next_appearance_dt) test_object
    15                          from  t
    16                      ) LOOP
    PIPE 17 ROW (v_rec.test_object);
    18 END OF LOOP;
    END 19;
    20.

    The function is created.

    SY.

  • Choose a view with nested object types

    I use 11.2 DB. I created 2 types of objects. The contact_t has been integrated into the student_t object and I created a view with the nested object.

    How do you choose the values of the object contact_t type in the view SQL? I want to see the values of the contact_t object in speerate areas (ie. contact_name, city, Department...)

    Thank you

    CREATE or REPLACE TYPE contact_t () AS OBJECT

    DCID NUMBER (10),

    Contact_Name VARCHAR2 (50).

    City VARCHAR2 (50).

    State VARCHAR2 (10),

    zip VARCHAR2 (10),

    e-mail VARCHAR2 (100))

    CREATE or REPLACE TYPE students_t () AS OBJECT

    DCID NUMBER (10),

    ID NUMBER (10),

    last_name VARCHAR2 (50).

    first name VARCHAR2 (50).

    middle_name VARCHAR2 (50).

    contact contact_t)


    VIEW to CREATE or REPLACE students_t students_view

    WITH the OBJECT IDENTIFIER (dcid) AS

    Select decided,

    ID,

    last_name,

    first name,

    middle_name,

    contact_t (dcid, contact_name, city, state, zip, email)

    FROM MyTable

    What exactly is the problem? Are you an error? An ORA-01730 by chance?

    Use the default STUDENTS_T constructor in the query from the view:

    VIEW to CREATE or REPLACE students_t students_view

    WITH the OBJECT IDENTIFIER (dcid) AS

    Select (students_t)

    DECIDED

    id

    last_name

    first name

    middle_name

    , contact_t (dcid, contact_name, city, state, zip, email)

    )

    FROM MyTable;

    Then, for example:

    SQL > select t.id

    2, t.contact.contact_name

    3, t.contact.city

    4 t students_view;

    ID CONTACT. CONTACT CONTACT_NAME. CITY

    ----------- -------------------------------------------------- --------------------------------------------------

    1 TEST                                               LA

  • How to make a list of question field with the data type DATE?

    I have a column with the DATE data type. Using forms 6i I want to generate a poplist field of list item with this column while the value of the items in the list of names of days like SATURDAY, SUNDAY, MONDAY. If we change the date to a char data type, it won't work properly, but now with the data type DATE behind him, it gives the following error message

    "FRM-32082: invalid value for given the type of element."
    List WEEKREST
    Article: WEEKREST
    Block: EMPRESTS
    Form: module 3
    FRM-30085: unable to adapt to the shape for the release. »


    Using forms 6i how a list item field type DATE data which may contain names of days?

    Set your date as a hidden field (not shown) column. Create your item list with the names of day of varchar2. Create the list item as a base table field that accepts the values of text in the names of the days. On this area, create a when-validate-item trigger that translated the text into an actual date that it then uses to set the value of the real object of the base table.

  • Problem with the DATA types, in a UNION

    Hello
    I m trying to disply a custom message when no data found using the structure below. Unfortunately I ve you have a problem with the data types I im trying to union
    I tried different types of data in the 2nd SELECTION tool but the rest of the problem. Help, please.

    SELECT HOSP_NAME 'HOSPITAL' DOC_SUR 'NAME', 'NAME' DOC_NAME, d.DOC_ID ID, diagnosis
    H., DOCTOR d, (SELECT d.DOC_ID, COUNT (d.DIAGN_ID) diagnosis
    OF PATIENT_DIAGNOSIS d
    GROUP BY d.DOC_ID)
    WHERE diagnosis > 1

    UNION ALL

    SELECT TO_CHAR ('test'), TO_CHAR ('test'), TO_CHAR ('test'), TO_CHAR ('test'), 0
    OF THE DOUBLE
    If NOT EXISTS (HOSP_NAME 'HOSPITAL' 'NAME' 'NAME' DOC_NAME DOC_SUR, d.DOC_ID ID, diagnosis
    OF ΝΟΣΟΚΟΜΕΙΟ h, ΙΑΤΡΟΣ d, (SELECT d.DOC_ID, COUNT (d.DIAGN_ID) diagnosis
    OF PATIENT_DIAGNOSIS d
    GROUP BY d.DOC_ID)
    WHERE diagnosis > 1);


    ORA-01790: expression must have same type of data, matching expression
    01790 00000 - "expression must have the same type of data, matching expression.

    DOC_SUR 'NAME' DOC_NAME 'NAME', ID d.DOC_ID, HOSP_NAME "HOSPITAL", diagnosis

    What is the data type for these columns

    To_char('test'), to_char ('test'), to_char ('test'), to_char ('test'), 0

    What you're doing here 'test' is already a character. Why do you use TO_CHAR?

  • [FAD] A few questions on the article of Timo "JDev: always test your application with the ApplicationModule Pooling disabled.

    Hallo Timo,

    I read your article JDev: always Test Your App with the regrouping of ApplicationModule turns off | JDev & amp; amp; ADF Goodies and I have some doubts.

    • I understand that you have disabled to AM pooling only to show the problem and the applications in production should always work with 'M bundling active. Right?
    • The substitution of activateState and passivateState functions must be performed when the AM is used to store data that is specific to the user. Right?
    • To store the data of the user in the AM, it is necessary to use the mechanisms of session? Or I might just add to the private variables AM (username, name, departmentName,...) to store the information of the user?
    • I see you used the Session instead of HTTPSession class to manage the session. What are the differences between these classes? Session the recommended class to use is?
    • Where can I find which are the main stages of the life of the session and functions to manipulate? 1-2 examples of creation, destruction, making the session which expires after e.g. 10 minutes of user'sinactivity... would be happy if possible.

    Thanks a lot a lot.

    Federico

    • I understand that you have disabled to AM pooling only to show the problem and the applications in production should always work with 'M bundling active. Right?

    Yes

    • The substitution of activateState and passivateState functions must be performed when the AM is used to store data that is specific to the user. Right?

    Given no, everything must be save in the activation/passivation. If you store something for use wide application and don't save during passivation, he went by activating the module application ID again.

    • To store the data of the user in the AM, it is necessary to use the mechanisms of session? Or I might just add to the private variables AM (username, name, departmentName,...) to store the information of the user?

    I like to keep the info in the plan to use session.

    • I see you used the Session instead of HTTPSession class to manage the session. What are the differences between these classes? Session the recommended class to use is?

    The session that you get from the module of the application is not a http session it's a server session. You cannot use any other class.

    • Where can I find which are the main stages of the life of the session and functions to manipulate? 1-2 examples of creation, destruction, making the session which expires after e.g. 10 minutes of user'sinactivity... would be happy if possible.

    The documentation is always a good starting point. The best description I know is from the book "Guide Oracle ADF developer real world ' by Jobinesh Purushothaman. If you google a bit you will find another description too. Don't know what you want to know about the creation and destruction of the sessions that you do yourself. To set the time-out setting for the http session, you can change the value of "session timeout" in the web xml file.

    Timo

  • After installing Acrobat or Reader on Windows 7 or Vista, icons of applications and file types change in Acrobat/Reader icon. Double click on a file or icon launches Acrobat or Reader. (The native application associated with the file type is not ope

    After installing Acrobat or Reader on Windows 7 or Vista, icons of applications and file types change in Acrobat/Reader icon. Double click on a file or icon launches Acrobat or Reader. (The native application associated with the file type is not open.)

    Hi peterb53490660,

    Try the steps of troubleshooting mentioned in this KB doc. https://helpx.Adobe.com/Acrobat/KB/application-file-icons-change-Acrobat.html

    Kind regards
    Nicos

  • Value set with the table type

    Hi all
    I use R12.1.3 EBS. I want to create a value set with the posting type "Table". But I must specify what application will be set and the table to use. I want to refer to an another diet/no apps. Is this possible? I have the link of database between this regime to receivables / via SQL Developer, I'm able to query or manipulate the data.

    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    PL/SQL Release 11.1.0.7.0 - Production
    "CORE     11.1.0.7.0     Production"
    TNS for Linux: Version 11.1.0.7.0 - Production
    NLSRTL Version 11.1.0.7.0 - Production
    Thanks in advance,
    Bahchevanov.

    Create a custom view in the schema of APPS that points to the table in the remote database, and you should be able to create a validated set of values from table based on the custom view. This will require you to create a link of database on the remote database (or a private database link in the APPS schema)

    HTH
    Srini

  • problem with the CLOB type

    Hello, I am a beginner, I have a problem with the CLOB type, please help me
    I want to write the input file is filename and string base64, then output decoded base64 content in dicrectory location (for example C:\),my code was executed but if entry with base64 long string, it displays error)
    ORA-29285: file write error
    ORA-06512: at "SYS.UTL_FILE", line 136
    ORA-06512: at "SYS.UTL_FILE", line 813
    ORA-06512: at "SYSTEM.WRITED", line 9
    ORA-06512: at line 1
    29285. 00000 -  "file write error"
    *Cause:    Failed to write to, flush, or close a file.
    *Action:   Verify that the file exists, that it is accessible, and that
               it is open in write or append mode.
    And this is my code
    create or replace directory dir_temp as 'C:\';
    /
    create or replace procedure writed(filename varchar2,code  clob)
    as
      f utl_file.file_type;
      v_lob          BLOB;  
    
    begin
      v_lob :=  UTL_ENCODE.BASE64_DECODE( UTL_RAW.CAST_TO_RAW(to_char(code)) ); 
      f := utl_file.fopen('DIR_TEMP', filename, 'w');
      utl_file.put_line(f,to_clob(utl_raw.cast_to_varchar2(v_lob)));  
      utl_file.fclose(f); 
    end;
    Thank you
    DBMS_XSLPROCESSOR.clob2file(
      cl => l_clob
    , flocation => 'XML_LOG'
    , fname => myfile_name
    );
    

    for example

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    type t_emps is table of emp%ROWTYPE;
      3    v_emps    t_emps;
      4    --
      5    v_clob    clob;
      6    v_newline varchar2(2) := chr(13)||chr(10);
      7  begin
      8    -- get the rows into a PL/SQL collection of records
      9    select *
     10    bulk collect into v_emps
     11    from emp;
     12    -- build up the CLOB
     13    v_clob := 'EMPNO,ENAME,JOB,MGR,HIREDATE,SAL,COMM,DEPTNO';
     14    for i in 1..v_emps.count
     15    loop
     16      v_clob := v_clob||v_newline||
     17                to_char(v_emps(i).empno,'fm9999')||','||
     18                v_emps(i).ename||','||
     19                v_emps(i).job||','||
     20                to_char(v_emps(i).mgr,'fm9999')||','||
     21                to_char(v_emps(i).hiredate,'YYYYMMDD')||','||
     22                to_char(v_emps(i).sal,'fm99999')||','||
     23                to_char(v_emps(i).comm,'fm99999')||','||
     24                to_char(v_emps(i).deptno,'fm99');
     25    end loop;
     26    -- write the CLOB to a file
     27    DBMS_XSLPROCESSOR.clob2file(cl => v_clob, flocation => 'TEST_DIR', fname => 'myfile.csv');
     28* end;
    SQL> / 
    
    PL/SQL procedure successfully completed.
    
  • ORA-39083: Type as procact_schema cannot be created with the object error:

    Hello

    on 11.2.0.4 on Win 2008

    Impdp is over, but with the error:

    ORA-39083: Object type PROCACT_SCHEMA failed to create with error:

    All tables are imported.

    If I create just the PROCACT_SCHEMA would it be sufficient?

    I can't DDL script for PROCACT_SCHEMA using dbms_metadata.get_ddl ('USER')?




    Thank you

    Hello

    Check this blog refrence:

    Error: ORA-39083, DBMS_CUBE_EXP PLS-00201 while impdp in Oracle DB Server v11.2.0.4 | DBA blog

    I hope this helps.

    Kind regards

  • How to return data using the object type?

    Hello all - I have an obligation to return the values object type.

    In the same way as

    list - Plan1, Subplan1, Fund1, 2 Fund Fund 3

    list - Plan2, Subplan2, Fund2

    list - plane3, Subplan3, not funds


    To achieve this I wrote below proc but its giving as response below which is does not correspond with my requirement. Someone has an idea how to write code to get the list of funds against each plan in each line?



    Output:

    PDB01. () T_T_CONTRACT

    PDB01. T_O_CONTRACT ('p1', 's1', PDB01. T_O_FUND ('p1', 's1', 'f1')),

    PDB01. T_O_CONTRACT ('p1', 's1', PDB01. T_O_FUND ('p1', 's1', 'f2')),

    PDB01. T_O_CONTRACT ('p1', 's1', PDB01. T_O_FUND ('p1', 's1', 'f3')),

    PDB01. T_O_CONTRACT ('p2', 's2', PDB01. T_O_FUND ('p2', 's2', 'f2')),

    PDB01. T_O_CONTRACT ('p3', 's3', PDB01. T_O_FUND (NULL, NULL, NULL))

    )




    DROP TYPE T_T_fund;

    create or replace

    TYPE T_O_fund

    AS OBJECT)

    argument plan_id Varchar2 (128).

    subplan_id Varchar2 (128).

    fund_id Varchar2 (128)

    )

    No final;

    /

    create or replace

    type T_T_FUND

    as the table of T_O_FUND;

    /

    type of projection T_T_CONTRACT;

    create or replace

    TYPE T_O_contract

    AS OBJECT)

    argument plan_id Varchar2 (128).

    SUBPLAN_ID varchar2 (128).

    ov_fund T_o_fund

    )

    no final;

    /

    create or replace

    type T_t_contract as the T_O_contract table;

    /

    -------------------------

    / * Remove T_T_FUND;

    DROP TYPE T_O_fund;

    type of projection T_T_CONTRACT;

    DROP TYPE T_O_contract; * /

    ----------------

    create or replace

    procedure test_cursor (o_c1 OUT sys_refcursor) is

    V_T_T_FUND T_T_FUND;

    v_T_t_contract T_t_contract;

    Start

    WITH (CONTRACTS AS

    SELECT "p1" PLAN_ID, "s1" SUBPLAN_ID FROM DUAL UNION ALL

    SELECT "p2" PLAN_ID, 's2' SUBPLAN_ID FROM DUAL UNION ALL

    SELECT "p3" PLAN_ID, 's3' SUBPLAN_ID FROM DUAL

    ),

    Fund)

    Select "p1" PLAN_ID, SUBPLAN_ID 's1', 'f1' FUND_ID of all the DOUBLE union

    Select "p1" PLAN_ID, SUBPLAN_ID 's1', 'f2' FUND_ID of all the DOUBLE union

    Select plan_id "p1", "s1" subplan_id argument, "f3" fund_id Union double all the

    Select the argument plan_id 'p2', 's2' subplan_id, 'f2' double fund_id

    )

    Select T_O_contract (c.PLAN_ID, c.SUBPLAN_ID, T_o_FUND (f.PLAN_ID, f.SUBPLAN_ID, f.FUND_ID))

    TO COLLECT FEES IN BULK

    in v_T_t_contract

    c CONTRACTS, FUND F

    where C.PLAN_ID = F.PLAN_ID

    and c.SUBPLAN_ID = f.SUBPLAN_ID (+);

    Open the O_C1 for

    SELECT 't' TYP, v_T_t_contract contract_LST

    FROM DUAL;

    end;

    /

    impression o_test

    You can declare the attribute OV_FUND as T_T_FUND data type:

    create or replace type t_o_contract as object (
      plan_id     varchar2(128)
    , subplan_id  varchar2(128)
    , ov_fund     t_t_fund
    );
    /
    

    You will be able to do this:

    with contracts as (
      select 'p1' plan_id, 's1' subplan_id from dual union all
      select 'p2' plan_id, 's2' subplan_id from dual union all
      select 'p3' plan_id, 's3' subplan_id from dual
    ),
    funds as (
      select 'p1' plan_id , 's1' subplan_id, 'f1' fund_id from dual union all
      select 'p1' plan_id , 's1' subplan_id, 'f2' fund_id from dual union all
      select 'p1' plan_id , 's1' subplan_id, 'f3' fund_id from dual union all
      select 'p2' plan_id , 's2' subplan_id, 'f2' fund_id from dual
    )
    select t_o_contract(
             c.plan_id
           , c.subplan_id
           , cast(
               multiset(
                 select t_o_fund(f.plan_id, f.subplan_id, f.fund_id)
                 from funds f
                 where f.plan_id = c.plan_id
                 and f.subplan_id = c.subplan_id
               )
               as t_t_fund
             )
           )
    from contracts c ;
    
  • The object Type VARRAY

    Hello

    I'm still very new to PL/SQL please bare with me if you can. I am trying to learn how to store the data of an object in a single varray of objects. My code below attempts to declare a type of object with instance attributes 3 and 3 methods of instance of getter and setter method.

    So, I want to create a varray type to store an array of types of objects 'employee '.

    Here I am trying to use a loop to retrieve the 10 first ename and empno, sal chronogram EMP table and store it in the variable array of 10 items.

    Finally, I tried to use another loop to produce the ename, empno and sal in the order opposite.

    My goal and my body of the object was created successfully without error.

    The problem starts when I start anonymous block that creates the varray is when I get an error at the end.

    At the end of my code is I get the error message. Can anyone suggest me what I am doing wrong, or what I can do to accomplish this task.

    SET SERVEROUTPUT ON

    -create object

    CREATE OR REPLACE TYPE used AS OBJECT)

    ename_obj VARCHAR2 (10),

    empno_obj number 4,

    sal_obj NUMBER (7.2).

    Getename RETURN of the FUNCTION MEMBER VARCHAR2.

    Getempno RETURN NUMBER of MEMBER FUNCTION

    FUNCTION RETURN NUMBER getsal MEMBER);

    /

    -create bodies of the object

    CREATE or REPLACE TYPE BODY used as

    FUNCTION MEMBER getename IS return VARCHAR2

    BEGIN

    RETURN ename_obj;

    END;

    FUNCTION MEMBER getempno IS return VARCHAR2

    BEGIN

    RETURN empno_obj;

    END;

    FUNCTION MEMBER getsal IS return VARCHAR2

    BEGIN

    RETURN sal_obj;

    END;

    END;

    /

    -create varray of object and start line 1 of the Error Message.

    1 > DECLARE

    2 > TYPE tvrEmploy IS the VARRAY (10) OF the employee;

    3 > vClient tvrEmploy;

    4 > iCounter integer: = 1;

    5 > CURSOR client_cursor IS

    6 > SELECT ename, sal

    7 > FROM emp

    8 > WHERE rownum < 11;

    9 > START

    10 > vClient: = tvrEmploy (null, null, null, null, null, null, null, null, null, null);

    11 > FOR i IN client_cursor LOOP

    12 > vClient (iCounter) .ename_obj: = i.ename;

    13 > vClient (iCounter) .empno_obj: = i.empno;

    14 > vClient (iCounter) .sal_obj: = i.sal;

    15 > iCounter: = iCounter + 1;

    16 > END of LOOP;

    17 > FOR I IN REVERSE 1.10 LOOP

    18 > dbms_output.put_line (to_char (I) |) » '|| vClient (I) .ename_obj | » '|| vClient (I) .empno_obj | » '||

    vClient (I) .sal_obj);

    19 > END of LOOP;

    20 > END;

    21 >.

    -"' '" Error message below -

    DECLARE

    *

    ERROR on line 1:

    ORA-06530: Reference to the composite uninitialized

    ORA-06512: at the level of line 12

    Thanks again for your time and patience.

    -Todd

    Hello

    The error occurs on line 12, the first time in the loop when you try to run:

    vClient (iCounter) .ename_obj: = i.ename;

    At that point, vClient (1) is not an Employee object. It has the value NULL.

    Try this:

    DECLARE
    TvrEmploy TYPE IS the VARRAY (10) OF the employee;
    vClient tvrEmploy;
    iCounter integer: = 1;

    CURSOR client_cursor IS
    SELECT ename, sal
    ,       empno                                                 -- ADDED
    FROM scott.emp
    WHERE rownum<>
    BEGIN
    vClient: = tvrEmploy (null, null, null, null, null, null, null, null, null, null);

    I'm IN client_cursor LOOP
    vClient (iCounter): employee = (i.ename, i.empno, i.sal);     --ALSO CHANGED
    iCounter: = iCounter + 1;
    END LOOP;

    FOR I IN REVERSE 1.10 LOOP
    dbms_output.put_line (to_char (I) |) » '|| vClient (I) .ename_obj | » '|| vClient (I) .empno_obj | » '||
    vClient (I) .sal_obj);
    END LOOP;
    END;
    /

  • DatabaseProcedure with the return type preceded of the schema name

    Salvation (Paco)

    I have a question on the DatabaseProcedure class. We use proxy Oracle users to our database connections.
    Everything is accessible via a role of database that are granted to the user. All of our database objects, tables, etc. are protected by this database role.
    When I want to call a function/procedure of database, I need to add the name of the schema as a prefix to the custom database object that uses us for parameters and return types.

    So far so good. I can also define a parameter prefixed by the name of schema via the DatabaseProcedure.registerArrayType...
    But when I try to set a function call that uses this parameter I get an error saying "the statement is not valid.
    The problem is the regular pattern of PROCEDURE_DEFINITION:
    private static final Pattern PROCEDURE_DEFINITION = Pattern.compile("\\s* (FUNCTION|PROCEDURE) \\s+ ([\\w.$]+) \\s* (?:\\((.*?)\\))? \\s* (?:RETURN\\s+(\\w+))? \\s* ;? \\s*", CASE_INSENSITIVE | COMMENTS | DOTALL);
    The return type cannot be prefixed by the name of schema.

    Any good suggestions or workarounds?

    I have actually change the duration of reflection model to make it work-, but I really don't like this solution over the long term.

    / Torben

    Published by: Zonic 2013-05-07 10:52

    Hi Torben,

    I think that I have a work around for the problem which might work for you. If you look at the source of DatabaseProcedure.registerArrayType you will find that it is actually called DatabaseProcedure.registerCustomParamType.

    public static void registerArrayType(String name)
    {
      registerCustomParamType(name, Types.ARRAY, Array.getORADataFactory(), name);
    }
    

    A solution you can replace calls to DatabaseProcedure.registerArrayType with calls to DatabaseProcedure.registerCustomParamType as follows.

    // Instead of DatabaseProcedure.registerArrayType("NAME.WITH.DOTS") call:
    DatabaseProcedure.registerCustomParamType("anyNameWithoutDots", Types.ARRAY, Array.getORADataFactory(), "NAME.WITH.DOTS"); // Don't forget to use uppercase here.
    
    DatabaseProcedure dp = DatabaseProcedure.define("procedure my.procedure(param1 in out anyNameWithoutDots)");
    
    DatabaseProcedure.ParamType type = dp.getParamDef(0).getType();
    System.out.println(type.getName() + " is " + type.getTypeName()); // ANYNAMEWITHOUTDOTS is NAME.WITH.DOTS
    

    In this way, that you don't have to use the 'illegal' name in the definition of DatabaseProcedure.

    Kind regards
    Paco van der Linden

Maybe you are looking for