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

Tags: Database

Similar Questions

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

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

  • 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

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

  • Initialize the record with constants type

    Hi all

    I need to initialize the record type that has 3 fields with constants.

    Please find the code example:

    DECLARE

    P_rec RECORD TYPE IS

    (

    ID1 VARCHAR2 (50).

    CLID VARCHAR2 (50).

    P_ID VARCHAR2 (50)

    );

    TYPE p_rec_tab IS TABLE OF THE p_rec;

    v_p_rec_tab p_rec_tab

    : = p_rec_tab ((«PA1», '1', «A»),)

    ('PA2', '2', 'B').

    ('PA3', ' 3 ", 'C').

    (WOULD BE "PA4', ' 4 ','),

    ('PA5', '5', 'E')) ;

    number of v_count;

    BEGIN

    v_count: = 0;

    BECAUSE me IN v_p_rec_tab. FIRST...

    v_p_rec_tab. LAST

    LOOP

    v_count: = v_count + 1;

    dbms_output.put_line (' a record number: ' | v_count);

    Dbms_output.put_line (' v_p_rec_tab.id1:' | v_p_rec_tab.id1 (i));

    Dbms_output.put_line (' v_p_rec_tab.clid:' | v_p_rec_tab.clid (i));

    Dbms_output.put_line (' v_p_rec_tab.p_id:' | v_p_rec_tab.p_id (i));

    END LOOP;

    END;

    Exception, I get:

    ORA-06550: line 12, column 24:

    PLS-00306: wrong number or types of arguments in the call to 'P_REC_TAB '.

    ORA-06550: line 11, column 18:

    PL/SQL: Ignored Element

    ORA-06550: line 22, column 13:

    PLS-00320: the declaration of the type of the expression is incomplete or incorrect

    ORA-06550: line 22, column 4:

    PL/SQL: Statement ignored

    Try the below

    SET SERVEROUTPUT ON

    DECLARE

    P_rec RECORD TYPE IS

    (

    ID1 VARCHAR2 (50).

    CLID VARCHAR2 (50).

    P_ID VARCHAR2 (50)

    );

    TYPE p_rec_tab IS TABLE OF THE p_rec;

    v_p_rec_tab p_rec_tab;

    number of v_count;

    BEGIN

    v_count: = 0;

    SELECT * COLLECT in BULK IN the v_p_rec_tab OF

    (SELECT 'PA1', ' 1', 'A' FROM dual UNION ALL)

    SELECT 'PA2', '2', 'B' FROM dual UNION ALL

    SELECT 'PA3', '3', 'C' FROM dual UNION ALL

    SELECT 'PA4', '4', would be "OF double UNION ALL

    SELECT 'PA5', '5', 'E' OF THE double);

    BECAUSE me IN v_p_rec_tab. FIRST... v_p_rec_tab. LAST

    LOOP

    v_count: = v_count + 1;

    dbms_output.put_line (' a record number: ' | v_count);

    Dbms_output.put_line (' v_p_rec_tab.id1:' | v_p_rec_tab (i) .id1);

    Dbms_output.put_line (' v_p_rec_tab.clid:' | v_p_rec_tab (i) .clid);

    Dbms_output.put_line (' v_p_rec_tab.p_id:' | v_p_rec_tab (i) .p_id);

    END LOOP;

    END;

    ----- OR --------

    SET SERVEROUTPUT ON

    DECLARE

    P_rec RECORD TYPE IS

    (

    ID1 VARCHAR2 (50).

    CLID VARCHAR2 (50).

    P_ID VARCHAR2 (50)

    );

    TYPE p_rec_tab IS TABLE OF THE p_rec;

    v_p_rec_tab p_rec_tab: = p_rec_tab();

    number of v_count;

    BEGIN

    v_count: = 0;

    v_p_rec_tab. EXTEND (5);

    v_p_rec_tab (1) .id1: = 'PA1 ';

    v_p_rec_tab (1) .clid: = '1';

    v_p_rec_tab (1) .p_id: = 'A ';

    v_p_rec_tab (2) .id1: = 'PA2;

    v_p_rec_tab (2) .clid: = '2';

    v_p_rec_tab (2) .p_id: = 'B ';.

    v_p_rec_tab (3) .id1: = 'PA3 ';

    v_p_rec_tab (3) .clid: = '3';

    v_p_rec_tab (3) .p_id: = 'C ';

    v_p_rec_tab (4) .id1: = 'PA4.

    v_p_rec_tab (4) .clid: = '4';

    v_p_rec_tab (4) .p_id: = ';

    v_p_rec_tab (5) .id1: = 'PA5.

    v_p_rec_tab (5) .clid: = '5';

    v_p_rec_tab (5) .p_id: = 'E ';

    BECAUSE me IN v_p_rec_tab. FIRST... v_p_rec_tab. LAST

    LOOP

    v_count: = v_count + 1;

    dbms_output.put_line (' a record number: ' | v_count);

    Dbms_output.put_line (' v_p_rec_tab.id1:' | v_p_rec_tab (i) .id1);

    Dbms_output.put_line (' v_p_rec_tab.clid:' | v_p_rec_tab (i) .clid);

    Dbms_output.put_line (' v_p_rec_tab.p_id:' | v_p_rec_tab (i) .p_id);

    END LOOP;

    END;

  • By the way the record as a parameter type to function

    Hi all

    I tried the below the example query for the record type as IN parameter works and I confused when calling the function.

    Please find the code below

    create or replace package pkg_rec is

    type t_rec record is (ename, sal emp.sal%type emp.ename%type);

    end;

    create or replace function get_emp_sal (emprec pkg_rec.t_rec)

    number is back

    v_empno emp.empno%type;

    Start

    Select empno in v_empno

    WCP

    where ename = emprec.ename and sal = emprec.sal;

    Return v_empno;

    end;

    -Block to call the function

    declare

    v_rec pkg_rec.t_rec;

    v_empno emp.empno%type;

    Start

    v_rec. Ename: = 'SCOTT ';

    v_rec. SAL: = 3000;

    v_empno: = get_emp_det (v_rec); -Get the error "Expression is of the wrong type."

    DBMS_OUTPUT. Put_line (' values ' | v_empno);

    end;

    You can please me to pass the parameter to function; referring

    Thank you very much.

    Is it typo?

    Your function is called get_emp_sal, but you call get_emp_det.

    Concerning

    Marcus

  • A field validation can point to a different record type fields?

    Validation of field based on another field of registration Type

    I am trying to generate a validation in a custom object that summarizes the fields under the record type account.

    The names of the fields of OBI (the location and the name of the table field):
    "- Take into account the custom settings. S_INT_13 + ""-account of custom settings '. " S_INT_14 + ""-account of custom settings '. " S_INT_11

    My questions: peut a field validation, point to a different record type fields? My thought was that if OBI can look in all of the types of records that all CRM must be able, including field validations.

    Thank you

    David

    Hello!

    I'm afraid that's not possible at the moment. You will have to wait for version 16, I think that having such opportunities.
    The R16 will allow you to create a workflow through different types of records (for example, to create a task on the account related to the service request when a new service request is created). I hope that there will be equal opportunities with the validation rules...

    Hope this will help, do not hesitate to ask for more.

    Max

Maybe you are looking for

  • Satellite A660: Upgrade of the possible keyboard backlight?

    Hi guys,. I was thinking to replace my computer laptop keboard (satellite A660-18) with a keyboard backlight. Do you think it will be posible?I found on the internet for about £30-40, and it declares compatible with the Satellite A660. Thank you.

  • optiontips.in

    Hi gmail and stoped working game store is also no connection, but the other aps work well, model number xperia arc lt18i and android 2.3.4

  • Cannot turn system icons on or off, excluding the clock icon.

    Hello The title pretty much everything said. I can turn only the clock system power icon. Everything is grayed out. Now, when I go to the task bar, click Customize and access the power, the network, volume, and center of the action, they are all chec

  • Traffic LLC,(2)

    I have install a PIX 501 in a net that has a SNA Server. The external interface of the PIX is connected in e0 interface of the router. Is it possible the LLC,(2) packages pass for firewall and I continue to protect IP traffic? If not, I thought to co

  • Field of password missing on the first EHF home screen in Windows 7 Professional

    My first homescreen under Windows 7 professional small account and name but picture shows NO password field. Only after hitting enter or mouse left click password field contains a second Green with the larger picture of the account and the name. How