Return the record type


Hello

I have a requirement of the company, where I need to return a record type (OUT parameter) for environment call based on the given input value.

Suppose that if the value is correct and corresponding record is found in the table then the return values for this key entry. If matching record is found, then return the exception to the calling environment.

To do this, I created an example of test table and populated records.

create table plch_test(dept_id number,dept_name varchar2(50),cost_centre number);
insert into plch_test values(10,'SALES',1010);
insert into plch_test values(20,'FINANCE',2010);
insert into plch_test values(30,'MKTG',3010);

 
SQL> select * from plch_test;
   DEPT_ID DEPT_NAME                                          COST_CENTRE
---------- -------------------------------------------------- -----------
        10 SALES                                                     1010
        20 FINANCE                                                   2010
        30 MKTG                                                      3010

 
 

I wrote a simple block and gave a valid key dept_id (10 in this case) to display costcentre for this dept_id and dept_name I said tow types of records, one for valid record and another exception


SQL> DECLARE 
  2  TYPE rec_dept IS RECORD(dept_name varchar2(50),cc number);
  3  l_rec_dept rec_dept;
  4  TYPE rec_exception IS RECORD(err_code number,error_message varchar2(300));
  5  l_rec_exception rec_exception;
  6  BEGIN
  7  SELECT dept_name,cost_centre
  8  INTO l_rec_dept
  9  FROM plch_test
 10  where dept_id=10;
 11  dbms_output.put_line('DEPT_NAME'||' '||l_rec_dept.dept_name||' '||'COSTCENTRE'||' '||l_rec_dept.cc);
 12  EXCEPTION WHEN NO_DATA_FOUND THEN
 13  l_rec_exception.err_code:=sqlcode;
 14  l_rec_exception.error_message:=sqlerrm;
 15  dbms_output.put_line(l_rec_exception.err_code||' '||l_rec_exception.error_message);
 16  END;
 17  .
SQL> /
DEPT_NAME SALES COSTCENTRE 1010
PL/SQL procedure successfully completed.
SQL> 

 

Now for invalid dept_id and expose the message by using exception record type I stated.

SQL> ed
Wrote file afiedt.buf
  1  DECLARE
  2  TYPE rec_dept IS RECORD(dept_name varchar2(50),cc number);
  3  l_rec_dept rec_dept;
  4  TYPE rec_exception IS RECORD(err_code number,error_message varchar2(300));
  5  l_rec_exception rec_exception;
  6  BEGIN
  7  SELECT dept_name,cost_centre
  8  INTO l_rec_dept
  9  FROM plch_test
 10  where dept_id=40; --Invalid --data is not present
 11  dbms_output.put_line('DEPT_NAME'||' '||l_rec_dept.dept_name||' '||'COSTCENTRE'||' '||l_rec_dept.cc);
 12  EXCEPTION WHEN NO_DATA_FOUND THEN
 13  l_rec_exception.err_code:=sqlcode;
 14  l_rec_exception.error_message:=sqlerrm;
 15  dbms_output.put_line(l_rec_exception.err_code||' '||l_rec_exception.error_message);
 16* END;
SQL> /
100 ORA-01403: no data found
PL/SQL procedure successfully completed.

Now as you can see I need to include this point in a procedure with an input parameter and output must be a record types which will return

rec_dept if it becomes a key input valid or an exception if she meets a key not valid.


CREATE PROCEDURE test_prc IS(p_in_dept_id IN plch_test.dept_id,p_output ??????
DECLARE 
TYPE rec_dept IS RECORD(dept_name varchar2(50),cc number);
l_rec_dept rec_dept;
TYPE rec_exception IS RECORD(err_code number,error_message varchar2(300));
l_rec_exception rec_exception;
BEGIN
BEGIN
SELECT dept_name,cost_centre
INTO l_rec_dept
FROM plch_test
where dept_id=p_ind_dept_id;
RETURN l_rec_dept;
EXCEPTION WHEN NO_DATA_FOUND THEN
l_rec_exception.err_code:=sqlcode;
l_rec_exception.error_message:=sqlerrm;
RETURN l_rec_exception;
END;
dbms_output.put_line('DEPT_NAME'||' '||l_rec_dept.dept_name||' '||'COSTCENTRE'||' '||l_rec_dept.cc);
END;

Hope that the explanation above help in imposes the requirement

Kind regards

Claudy kotekal

Return a record which can mean two things is complicated; I'm not an experienced myself pl/sql developer, but this looks like a craft.

The idea of exceptions under Sir Thomas of Kyte, is that any treatment must be stopped; You should RAISE an exception to the appellant so that he can figure out what to do with it.  What you are saying, this is an exception, but is not a little, cos it's okay, I'll just keep but I will go back to the appellant in any way, but the appellant shall include this registration type is - would it be a record representing a row of the table, or it might be an exception... yuck.

(a) is it really an exception

(b) what do you do with it? You he could log into a table, you could write to a file, you can display an error message on the screen

But really, it's weird to want to pass an exception as return value.

These are all considerations of design, not really anything to do with the pl/sql language in itself.

But hard, if you send a record type a successful being found, registration-based stick to it and don't use it to return a record; do not try to do double duty with her flipping something else.  Just save the message put in a table, or print it to the console, or what you want to do with; but as I said, the most important decision is, is this really an exception. And is based on the data model and the expectations of cleanliness of the data etc.

Think about how you call built-in functions. If you send garbage to a built-in function it does not return successfully, leaving you to figure out whether he succeeded or not by inspecting the return value; It goes kaboom, something bad happened.  That's what your function should do if something bad happens, that is to say, if you get an exception, it should probably go kaboom.

Tags: Database

Similar Questions

  • concatenate the fields of the record type

    Hello

    Is it possible to concatenate the fields of the record type?, example
    declare 
     TYPE customer_sales_rectype IS RECORD
          (campo1 char(3),
          campo2  char(3),
          campo3  char(3));
    
             
      TYPE ZZZ IS RECORD (kkk customer_sales_rectype);
          x customer_sales_rectype;
         
    begin
      x.campo1:='000';
      x.campo2:='aaa';
      x.campo3:='BBB';
    end;
    I have a table
    ID_REPORT NUMBER                                   
    ID_LINE     NUMBER                                  
    DT_FILE  DATE           Y                        
    DS_LINE     VARCHAR2(2048) Y       
    My charly had more than 50 columns and unavoidable to concatenate the columns, example:
    select column001 ,
           ';' PV1,
           COL2,
           COL3
           COL4,
         ';' PV2,....ETC
    FROM MY TABLES
    I think that movement query result in a variable of type record that I would can insert in the table in the column is DS_LINE some transformatcion.

    Is it possible without using COL1 | PV1. COL2. COL3 | COL4 | PV2... etc.


    Thanks in advance
    using 9.2.02

    It's pretty easy to write a function for this. Here's a 'coffee time ': implementation

    create or replace function multi_concat
        (p_args sys.dbms_debug_vc2coll)
        return clob
    as
        rv clob;
    begin
        dbms_lob.createtemporary(rv, TRUE);
        for i in p_args.first .. p_args.last
        loop
            dbms_lob.writeappend(rv, length(p_args(i)), p_args(i));
        end loop;
        return rv;
    end multi_concat;
    /
    

    And the proof of coffee is in the dip of the ring:

    SQL> select multi_concat ( sys.dbms_debug_vc2coll ( ('Red Fish', 'Blue Fish', 1, 'Fish',2,'Fish'))
      2* from dual
    
    MULTI_CONCAT(SYS.DBMS_DEBUG_VC2COLL('REDFISH','BLUEFISH',1,'FISH',2,'FISH'))
    --------------------------------------------------------------------------------
    Red FishBlue Fish1Fish2Fish
    
    SQL> 
    

    I add a member TO_STRING function to your type and use something like the above, implement.

    You can also use the data dictionary to generate a string that connects the attributes of your type with the concatenation operator.

    Cheers, APC

  • objects and the record type

    Hello experts.

    create type emp2_obj is object
    (
    objno number
    ,
    objname varchar2
    (20),
    objdept number
    );

    create type emp2_objarr is table of emp2_obj;

    and

    type emp2_rec is record
    (
    recno number
    ,
    recname varchar2
    (20),
    recdept number
    );

    create type emp2_recarr is table of emp2_rec ;

    Objects and types of records are created similar and have the same similar object.  Is it only advisable to use registration type if you use a collection in PL/SQL type... Please advice

    user13328581 wrote:

    the only reason why I ask is because he asked during an interview

    -Objects and the types of records are created similar and have the same similar object.  Is it only advisable to use registration type if you use a collection in PL/SQL type... Please advice

    Not at all.  You can use record types used with collection types outside.  They are a group concept.  If you want to group a set of values together (including fields), you can use a record.  It may be convenient.  You can send documents around proc and functions.

    Be aware that the record types are limited to procedures, functions, anonymous blocks and packages (i.e. PL/SQL), while the types of objects are stored in the dictionary of data as a separate Oracle objects (they can also have methods, the records may not).  Object types can be used in SQL, as said sol.beach types of records (outside of the intelligent pipeline situations) is for PL/SQL.

  • How to use the record type as a parameter IN PL/SQL procedure or package

    Hi people,

    I need help on the record as the OUT parameter type. I am able to get out a single line as a parameter, but not getting do not idea how to get a multi ranks as output parameter.

    I have the code that works very well for a single line. Please see CODE1.

    But when I try to get several lines, I'm failing to do. Please see the CODE2. I get the error of compilation as


    Error report:

    ORA-06550: line 11, column 35:

    PLS-00487: Invalid reference to the variable "P_NAME.

    ORA-06550: line 11, column 1:

    PL/SQL: Statement ignored

    06550 00000 - "line %s, column % s:\n%s".

    * Cause: Usually a PL/SQL compilation error.

    Any help or a sample execution of script would be really useful.

    Thanks in advance.

    YZ

    --------------------------CODE1------------------------------------------

    -------------------------Package Spec-------------------------------

    CREATE OR REPLACE

    PACKAGE xx_sample_pkg as

    --

    Xx_sample_table_rectype RECORD TYPE IS

    (p_name varchar2 (40))

    number of p_emp_id

    );

    PROCEDURE xx_sample_prc (xx_sample_rec1, OUT xx_sample_table_rectype);

    END xx_sample_pkg;

    ------------------------------Package Body------------------------

    create or replace

    PACKAGE xx_sample_pkg AS BODY

    --

    PROCEDURE xx_sample_prc (xx_sample_rec1 OUT xx_sample_table_rectype) IS

    BEGIN

    SELECT ename, empno

    IN xx_sample_rec1

    FROM scott.emp

    WHERE ename = 'SMITH ';.

    END xx_sample_prc;

    END xx_sample_pkg;

    -------------------------------------------Execute----------------------

    DECLARE

    l_rec_type xx_sample_pkg.xx_sample_table_rectype;

    BEGIN

    dbms_output.put_line ('xx_sample_prc appeal');

    xx_sample_pkg.xx_sample_prc (l_rec_type);

    dbms_output.put_line ('YZ' | l_rec_type.p_name |') '|| l_rec_type.p_emp_id);

    END;

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

    -------------------------CODE2-------------------------------------------

    -------------------------Package Spec-------------------------------

    CREATE OR REPLACE

    PACKAGE xx_sample_pkg as

    --

    Xx_sample_table_rectype RECORD TYPE IS

    (p_name varchar2 (40))

    number of p_emp_id

    );

    PROCEDURE xx_sample_prc (xx_sample_rec1, OUT xx_sample_table_rectype);

    END xx_sample_pkg;

    ------------------------------Package Body------------------------

    create or replace

    PACKAGE xx_sample_pkg AS BODY

    --

    PROCEDURE xx_sample_prc (xx_sample_rec1 OUT xx_sample_table_rectype) IS

    BEGIN

    SELECT ename, empno

    IN xx_sample_rec1

    FROM scott.emp;

    END xx_sample_prc;

    END xx_sample_pkg;

    -------------------------------------------Execute----------------------

    DECLARE

    l_rec_type xx_sample_pkg.xx_sample_table_rectype;

    BEGIN

    dbms_output.put_line ('xx_sample_prc appeal');

    xx_sample_pkg.xx_sample_prc (l_rec_type);

    for l_rec in 1.l_rec_type.p_name.count

    loop

    dbms_output.put_line ('YZ' | l_rec_type.p_name (l_rec) |) » '|| l_rec_type.p_emp_id (l_rec));

    end loop;

    end;

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

    bb8c573a-6ca3-4d7c-90ed-e55c2df67201 wrote:

    But now, my question would be why the record type could not be used? My understanding is missing some concept between use of type type array collection record vs. Please specify.

    Do not confuse the folder with the collection.

    SY.

  • Dynamic SQL with in bulk in the record type

    Oracle 10.2 g

    I received this Tom

    [http://asktom.oracle.com/pls/apex/f?p=100:11:0:NO:]

    I'm able to do this without dynamic SQL, but my requirement is to do it in dynamic SQL
     create table t1 ( x int, y int );
    
     insert into t1 select rownum, rownum+1 from all_users where rownum <= 5;
    
     create table t2 ( x int, y int, z int );
    
     declare
                type array is table of t1%rowtype;
                l_data array;
        begin
                select * bulk collect into l_data from t1;
      
                forall i in 1 .. l_data.count
                
                       execute immediate 'insert into (select x, y from t2) values :x' using l_data(i);
        end;
     
    Error at line 1
    ORA-06550: line 9, column 90:
    PLS-00457: expressions have to be of SQL types
    ORA-06550: line 9, column 20:
    PL/SQL: Statement ignored
    There is a work around in 11g, but can we do something in 10g?



    Thank you
    HESH.

    HESH wrote:

    but following does not.

    declare
    type array is table of t1%rowtype;
    l_data array;
    begin
    select * bulk collect into l_data from t1;
    
    forall i in 1 .. l_data.count
    
    execute immediate 'insert into (select x, y from t2) values :x' using l_data(i);
    end;
    

    I want just a dynamic SQL code for the insert with FORALL statement would adopt as well as collections.

    Doesn't make much sense.

    Extract you the data from the SQL engine in the table of the record type. If the output data that cursor SQL must be read in the SQL engine and copied into the memory of PL/SQL engine.

    Then, you send that VERY SAME DATA back to the SQL engine to be used by a SQL insert cursor.

    Where is the logic behind the extraction of data from SQL in a PL/SQL table structure and then push this same structure table on the SQL engine database? What is the purpose to send data on a detour of underperforming and non-scalale through the PL/SQL engine?

    You have any justification (technical or functional wise) to back up this absurd approach?

    Why this can be achieved using a single SQL cursor that does both the choice (extraction) and (in bulk) insertion - using the plain old INSERT... SELECT structure?

    And if the insert is variable, then what? Create a dynamic INSERT... SELECT cursor and execute it (using bind values). This simple... Right?

  • Error in passing in the RECORD type in the API

    Gurus,

    Get the following error when I try and change from one type of RECORD in an API. I am in passage correctly?

    Any help is appreciated.

    Thank you
    -Scott



    Here is my error:

    fnd_descr_flex_col_usage_pkg.load_row
    *
    ERROR at line 21:
    ORA-06550: line 21, column 4:
    PLS-00306: wrong number or types of arguments in the call to 'LOAD_ROW '.
    ORA-06550: line 21, column 4:
    PL/SQL: Statement ignored



    Here is my anon block:

    declare
    Who_type RECORD TYPE IS
    (
    created_by NUMBER,
    CREATION_DATE DATE,
    last_updated_by NUMBER,
    last_update_date DATE,
    last_update_login NUMBER
    );
    v_who_type who_type;
    date of v_sysdate;
    Start
    Select sysdate
    in v_sysdate
    Double;
    v_who_type.created_by: = 0;
    v_who_type. CREATION_DATE: = v_sysdate;
    v_who_type.last_updated_by: = 0;
    v_who_type.last_update_date: = v_sysdate;
    v_who_type.last_update_login: = 0;
    fnd_descr_flex_col_usage_pkg.load_row
    (x_application_short_name = > 'SPL',)
    x_descriptive_flexfield_name = > 'HR_LOCATIONS ',.
    x_descriptive_flex_context_cod = > '441',.
    x_application_column_name = > 'ATTRIBUTE5 ',.
    x_who = > v_who_type,
    x_end_user_column_name = > "District."
    x_column_seq_num = > 10,
    x_enabled_flag = > 'Y ',.
    x_required_flag = > 'n',.
    x_security_enabled_flag = > 'n',.
    x_display_flag = > 'Y ',.
    x_display_size = > 50,
    x_maximum_description_len = > 50,
    x_concatenation_description_le = > 25,
    x_flex_value_set_name = > 50 characters,
    x_range_code = > ",
    x_default_type = > ",
    x_default_value = > ",
    x_runtime_property_function = > ",
    x_srw_param = > ",
    x_form_left_prompt = > "District."
    x_form_above_prompt = > "District."
    x_description = > ");

    ...

    sreese wrote:
    Tubby,

    Im not asking for your help with this error. I want to define my own FILE type that mimics the call package so I can spend in my own variables.

    Pretty sure I've described previously, there was a specific question with the answer that you do not understand?

    >

    The problem with this type of recording is that it contains all the 'who' columns that the application requires. When it is called from a package within the schema, the package has no difficulty arising from these data. When you call the package from an anon block, I have to pull my own values.

    You did before declaring a LOCAL record type, then you need to reference to the PACKAGE of type folder, as I showed you... it makes you EF values even as you were in your first post.

    I want to define the RECORD type of the manner in which it has been set to 'fnd_flex_loader_apis.who_type', but using my own variable and passing in the parameter. Make sense?

    Thank you
    Scott

    Hope that helps.

  • Bulk collect into the record type

    Sorry for the stupid question - I do something really simple wrong here, but can not understand. I want to choose a few rows from a table in a cursor, then in bulk it collect in a folder. I'll possibly extended the record to include additional fields that I will select return of functions, but I can't get this simple test case to run...

    PLS-00497 is the main error.

    Thanks in advance.
    create table test (
    id number primary key,
    val varchar2(20),
    something_else varchar2(20));
    
    insert into test (id, val,something_else) values (1,'test1','else');
    insert into test (id, val,something_else) values (2,'test2','else');
    insert into test (id, val,something_else) values (3,'test3','else');
    insert into test (id, val,something_else) values (4,'test4','else');
    
    commit;
    
    SQL> declare
      2   cursor test_cur is
      3   (select id, val
      4   from test);
      5
      6   type test_rt is record (
      7     id   test.id%type,
      8     val      test.val%type);
      9
     10   test_rec test_rt;
     11
     12  begin
     13    open test_cur;
     14    loop
     15      fetch test_cur bulk collect into test_rec limit 10;
     16       null;
     17     exit when test_rec.count = 0;
     18    end loop;
     19    close test_cur;
     20  end;
     21  /
        fetch test_cur bulk collect into test_rec limit 10;
                                         *
    ERROR at line 15:
    ORA-06550: line 15, column 38:
    PLS-00497: cannot mix between single row and multi-row (BULK) in INTO list
    ORA-06550: line 17, column 21:
    PLS-00302: component 'COUNT' must be declared
    ORA-06550: line 17, column 2:
    PL/SQL: Statement ignored

    You must declare an array based on your registration type.

    DECLARE
       CURSOR test_cur
       IS
             SELECT
                id,
                val
             FROM
                test
       ;
    type test_rt
    IS
       record
       (
          id test.id%type,
          val test.val%type);
       type test_rec_arr is table of test_rt index by pls_integer;
       test_rec test_rec_arr;
    BEGIN
       OPEN test_cur;
       LOOP
          FETCH
             test_cur bulk collect
          INTO
             test_rec limit 10;
          NULL;
          EXIT
       WHEN test_rec.count = 0;
       END LOOP;
       CLOSE test_cur;
    END;
     31  /
    
    PL/SQL procedure successfully completed.
    
    Elapsed: 00:00:00.06
    ME_XE?
    

    Notice that the difference is...

       type test_rec_arr is table of test_rt index by pls_integer;
       test_rec test_rec_arr;
    
  • the associative arrays containing the record type, cannot be used first

    I am having trouble with the declaration of an associative array containing the Types of records and iteration using FIRST and NEXT functions.
    This problem of mine is only appear when I use that types of records, the FIRST and FOLLOWING operators work very well when you use the regular NUMBER.

    Trying to get the first element of the array, I get: ORA-06550: line 22, column 40: PLS 00382: expression is of the wrong type

    See the code snippet below. Anyone know if this can be done in PL/SQL?

    -----------------------------------------------------------------------------------------
    DECLARE


    -Set the record structure that will contain information on a post
    TYPE PostRec IS (RECORD
    post_type VARCHAR2 (4) - maybe DEB/CRED
    );

    lr_charge_back_post PostRec;

    TYPE post_table IS TABLE OF PostRec NOT NULL
    INDEX BY VARCHAR2 (4);

    assoc_posts post_table;

    BEGIN


    -lr_charge_back_post.post_type: = "asd";
    assoc_posts('1').post_type: = '1';

    lr_charge_back_post: = assoc_posts.first;

    END;
    /

    Returns the index, not the file FIRST:

    SQL> declare
      2  TYPE PostRec IS RECORD (
      3  post_type VARCHAR2(4) -- Can be DEB/CRED
      4  );
      5
      6  lr_charge_back_post  varchar2(20);
      7  TYPE post_table IS TABLE OF PostRec NOT NULL
      8  INDEX BY VARCHAR2(4);
      9
     10
     11  assoc_posts post_table;
     12
     13  BEGIN
     14
     15
     16  --lr_charge_back_post.post_type := 'asd';
     17  assoc_posts('1').post_type := '1';
     18
     19  lr_charge_back_post := assoc_posts.first;
     20  dbms_output.put_line('idx='||lr_charge_back_post);
     21  END;
     22  /
    idx=1
    
    PL/SQL procedure successfully completed.
    
    SQL> declare
      2  TYPE PostRec IS RECORD (
      3  post_type VARCHAR2(4) -- Can be DEB/CRED
      4  );
      5
      6  lr_charge_back_post  varchar2(20);
      7  TYPE post_table IS TABLE OF PostRec NOT NULL
      8  INDEX BY VARCHAR2(4);
      9
     10
     11  assoc_posts post_table;
     12
     13  BEGIN
     14
     15
     16  --lr_charge_back_post.post_type := 'asd';
     17  assoc_posts('idx').post_type := '1';
     18  lr_charge_back_post := assoc_posts.first;
     19  dbms_output.put_line('idx='||lr_charge_back_post);
     20  END;
     21  /
    idx=idx
    
    PL/SQL procedure successfully completed.
    

    Max
    http://oracleitalia.WordPress.com

  • Returns the data type of XMLTYPE 1111 rather than 2009

    I'm trying to retrieve the metadata of a stored procedure that has a parameter of type XMLTYPE oracle.

    I use the oracle jdbc version 2 drivers support SQLXML of JDBC 4.0. I see that the setting and the extraction of the SQLXML works very well, but I am facing the problem when I try to extract the metadata.

         ResultSet rs = dbMetaData.getProcedureColumns(conn.getCatalog(),                           null,                           "%",                           "%");         while(rs.next()) {         // get stored procedure metadata         String columnName          = rs.getString(4);         int    columnDataType      = rs.getInt(6);         String columnReturnTypeName = rs.getString(7);             }

    Here's the getint (6) SQL type from java.sql.Types. However, if the data type is XMLTYPE, it returns 1111 that is not defined. As far as I know, The JDBC for XMLTYPE type should be java.sql.Types.SQLXML which corresponds to 2009. So I thought it should be back in 2009.

    Can someone let me know if I'm doing something wrong or if there is another way to extract the metadata correctly under JDBC 4.0 (i.e. without explicitly using the XDB)

    Thanks in advance.

    Véronique

    Published by: user7897488 on July 27, 2011 04:21

    Hello. 1111 is oracle extension, oracle\jdbc\OracleTypes.java: public final static int ANOTHER = 1111

    You need to open an official driver bug for his changing the SQLXML JDBC 4.0 value.
    I would first check that the problem exists with the latest ojdbc6.jar...
    Joe

  • Limit the "Record Type" options in the section search for presentation of the action bar

    Is it possible to limit the options of 'Record Type' in the 'Search' section in the disposition of the action bar for users specific role.

    Thank you!

    Mahesh, if you uncheck the box to go to step 2 of the role that you would restrict access to these types of records in the section of the application and research in the action bar.

  • How to return the data type complex of a synchronous BPEL process

    Hi all
    I have created a synchronous BPEL process, so a partner customer link was automatically created in the project. Now the link partner of this client is to have input and output variable of type normal string where as my BPEL process finally returns a complex data type.
    In order to solve this problem, I took a processing activity and mapped the collection [variable returned by my BPEL process] to the chain of production of the customer but in this way I just get a single string to store the entire collection but I want that they separately.

    Can someone tell me, how to manage this scenario.

    Concerning
    Lokesh

    After creating the partner link and the invoke (to create the variables), change the element type of the response message to the complex type definition of your collection that appears in the XSD. You can do the same thing if you want to change the element type of the payload of the request message as well.

  • Insert the record type

    Hi all

    I created a table with two columns method. I am assigned two values to variable recordtype.
    When inserting the record in the table, a compiler error is to be there.
    Create table emp_info(empno number(5),ename varchar2(30));
    
    DECLARE
    
    l_rec emp_info%rowtype;
    
    BEGIN
    
    l_rec.empno := 101;
    l_rec.ename := 'KING';
    
    insert into emp_info(empno,ename)
    values(l_rec);
    
    commit;
    
    END;
    ERROR on line 11:
    ORA-06550: line 10, column 35:
    PL/SQL: ORA-00947: not enough values
    ORA-06550: line 10, column 1:
    PL/SQL: SQL statement ignored


    Can I insert with output Recordtype variables indicating the column names. Can someone help me?

    Do not list of columns. Do not put brackets in the record variable:

    SQL> DECLARE
      2      l_rec emp_info%rowtype;
      3  BEGIN
      4      l_rec.empno := 101;
      5      l_rec.ename := 'KING';
      6      insert
      7        into emp_info
      8        values l_rec;
      9       commit;
     10  END;
     11  /
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • The value assigned to the record type under

    Expensive under reference data base record type, now I want to joint value in payr_rec type, in this type of recrocrd have a party_id column, but how can one int value assign this field.

    TYPE group_rec_type IS RECORD)
    GroupName VARCHAR2 (255),
    group_type VARCHAR2 (30),
    created_by_module VARCHAR2 (150).
    -- Bug 2467872
    mission_statement VARCHAR2 (2000).
    application_id NUMBER,
    party_rec PARTY_REC_TYPE: = G_MISS_PARTY_REC
    );

    Please guide.

    Something like that...

    DECLARE
     TYPE REC1 IS RECORD (V_NAME VARCHAR2(50), age INTEGER);
     TYPE REC2 IS RECORD (V_PNAME VARCHAR2(50), V_PAGE INTEGER,V_REC REC1);
     DUMMY_VAR REC2;
     dummy_rec1 REC1;
    BEGIN
     DUMMY_REC1.V_NAME:='Banerjee';
     DUMMY_REC1.AGE:=100;
    
     DUMMY_VAR.V_PNAME:='Saubhik';
     DUMMY_VAR.V_PAGE:=90;
     DUMMY_VAR.V_REC:=DUMMY_REC1;
    
    END;
    
  • Is it possible to use the record type or a PL/SQL table in the Select statement

    Hi all

    My requirement is that.
    I want to write a query and write a function, function, I want to return multiple columns at the same time in a Select statement.
    I select the return values in the Select no statement in a PL/SQL block.
    Is it possible to use the PL/SQL Table or Variable of Type record, or any other method in the statement Select?

    Please help me understand the solution.


    Kind regards

    830960 wrote:
    do we like it?

    In general, Yes, if the function is a function table, you can do something like:

    select  t.col1,
            t.col2,
            f.col1,
            f.col2,
            f.col3
      from  table_name t,
               table(some_table_function(param1,...paramN)) f
    /
    

    SY.

  • Function returns the object type

    Hello
    This isn't a duplicate of another thread, I posted earlier with the procedure...
    Now I try the subprogramme with the service, as required by the client., so I opened the question in another thread
    CREATE OR REPLACE TYPE Type_Rt IS OBJECT
        (Rt_Type      VARCHAR2(2000),
         cdtRt       VARCHAR2(2000),
         lqdtRt    VARCHAR2(2000),
         Olk              VARCHAR2(2000),
         cdtwh       VARCHAR2(2000) )
     
    CREATE OR REPLACE TYPE Rt_Type_Var IS TABLE OF Type_Rt;
     
     
     
    CREATE OR REPLACE FUNCTION FUNC_RAT (
                                Cp_Id  VARCHAR2,
                                             St_Id    VARCHAR2,
                                             cdt_Rt   VARCHAR2,
                                             liq_Rt      VARCHAR2,
                                             Olk      VARCHAR2,
                                             cdt_Wh VARCHAR2)               
    RETRUN Rt_Type_Var IS
       v_typ_rat_List   Type_Rt ;
       var1_nri varchar2(100) := 'ST';
    BEGIN
       IF ( Cp_Id = 'NTE' AND St_Id = 'Y' ) THEN   
        --select distinct ne_rt_issue into var1_nri from rt_con where ltr_ener = cdt_rt;
             
         v_typ_rat_List := new Type_Rt ('STRT',var1_nri ,liq_Rt,'Stle' ,null);    
       END IF;      
         RETURN v_typ_rat_List;
    END;
    / 
    I get the following error:, I tried it but no luck on my side
    PLS-00382: expression is of wrong type
    After you create the function, I have to call this function as
    SELECT * FROM TABLE(FUNC_RAT ('NTE','Y','AB','C','Y',NULL))
    Could you please help me with this

    The same basic problem as in your previous thread. Confusion between creating an object from a collection/table of this object.

    Here's a basic example:

    SQL> create or replace type TScalar is object(
      2          id      integer,
      3          name    varchar2(10)
      4  );
      5  /
    
    Type created.
    
    SQL>
    SQL> create or replace type TArray is table of TScalar;
      2  /
    
    Type created.
    
    SQL>
    SQL> --// creating a scalar
    SQL> select TScalar( 1, 'John' ) as OBJ from dual;
    
    OBJ(ID, NAME)
    --------------------
    TSCALAR(1, 'John')
    
    SQL>
    SQL> --// creating an array/collection
    SQL> select
      2          TArray(
      3                  TScalar( 1, 'John' ),
      4                  TScalar( 2, 'Tom' )
      5          )                               as ARRAY
      6  from       dual;
    
    ARRAY(ID, NAME)
    --------------------------------------------------
    TARRAY(TSCALAR(1, 'John'), TSCALAR(2, 'Tom'))
    
    SQL> 
    

    So in your function, you will need to place objects in the collection.

    return(
        Rt_Type_Var(                      --// instantiate the collection
               Type_Rt ('STRT',var1_nri ,liq_Rt,'Stle' ,null)  --// place an object into the collection
        )
    );
    

    And use appropriate type names and the object. Poorly chosen and non standard naming conventions just add to the confusion.

Maybe you are looking for

  • Live photo showing 2 different files in photos app on mac!

    Hello I recently imported photos from my iphone to my Mac using photos for OSX app. But after graduating successfully imported it shows me two different elements i.e. photo itself & a short video. So for my 300 live photos it's show me 300 photos and

  • iCloud photo

    Hello I want to delete all my pictures from my phone and put them on my laptop. But the only thing my laptop sees the last 30 photos taken. I can't find where it went wrong! I hope you can help me. Bye, Anne

  • Neck of iTunes?

    What is it and how does it work on a Apple Watch?

  • Restore OSX 10.6.4

    short story back. I recently acquired a mid 2010 Mac Pro "eight Core" 2.4 Mac Pro 5.1 - A1289-2314-2 The previous owner wiped the hard drive and installed Win 7 Professional (why I have no idea). But I try to restore to mac OSX and bought a 10.6.3 Sn

  • WNDR3400v3 connects 5G and ethernet but not not using 2.4 G

    I have a WNDR3400v3 Wireless Dual Band router N600 linking is no longer in the band of 2.4 G, if security is enabled. The band of 5G and all ethernet ports work fine. As I have 2 other 2.4 access point G in our hotel, I put an access point to channel