table col name get the details of the table column and inserting of values depending on the data type of the column

Hello

I am train to write a procedure where I would spend the table as a parameter name and then the code would determine it is column names, and then he would insert records in each column depending on the data type. could someone help me with this.

Thank you

SM

Hello

Perhaps you need to dummy data just for the table.

Here is my exercise

create or replace
procedure generate_rows(p_table_name varchar2, p_count number)
is
  --
  function insert_statement(p_table_name varchar2) return clob
  is
    l_columns clob;
    l_expressions clob;
    l_sql clob default
      'insert into p_table_name (l_columns) select l_expressions from dual connect by level <= :p_count';
  begin
    select
      -- l_columns
      listagg(lower(column_name), ',') within group (order by column_id),
      -- l_expressions
      listagg(
        case
        when data_type = 'DATE'
          then  'sysdate'
        when data_type like 'TIMESTAMP%'
          then  'systimestamp'
        when data_type = 'NUMBER'
          then  replace('dbms_random.value(1,max)',
                  'max', nvl(data_precision - data_scale, data_length)
                )
        when data_type = 'VARCHAR2'
          then  replace(q'|dbms_random.string('a',data_length)|',
                  'data_length', data_length
                )
        else
                'NULL'
        end, ',') within group (order by column_id)
    into
      l_columns,
      l_expressions
    from user_tab_columns
    where table_name = upper(p_table_name);
    --
    l_sql := replace(replace(replace(l_sql,
      'p_table_name', p_table_name),
      'l_columns', l_columns),
      'l_expressions', l_expressions);
    -- debug
    dbms_output.put_line(l_sql);
    --
    return l_sql;
  end;
begin
  execute immediate insert_statement(p_table_name) using p_count;
end;
/

-- test
create table mytable(
  id number(4,0),
  txt varchar2(10),
  tstz timestamp with time zone,
  dt date,
  xml clob
)
;
set serveroutput on
exec generate_rows('mytable', 10);
select id, txt from mytable
;
drop procedure generate_rows
;
drop table mytable purge
;

Procedure GENERATE_ROWS compiled
Table MYTABLE created.
PL/SQL procedure successfully completed.

insert into mytable (id,txt,tstz,dt,xml) select dbms_random.value(1,4),dbms_random.string('a',10),systimestamp,sysdate,NULL from dual connect by level <= :p_count
        ID TXT
---------- ----------
         3 WnSbyiZRkC
         2 UddzkhktLf
         1 zwfWigHxUp
         2 VlUMPHHotN
         3 adGCKDeokj
         3 CKAHGfuHAY
         2 pqsHrVeHwF
         3 FypZMVshxs
         3 WtbsJPHMDC
         3 TlxYoKbuWp

10 rows selected

Procedure GENERATE_ROWS dropped.
Table MYTABLE dropped.

and here is the vision of Tom Kyte for the same https://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:2151576678914

Edit: to improve my code, it must use p_count as bind as Tom.

Tags: Database

Similar Questions

  • Changing Z10 blackBerry device name gets the error message

    Hi, I'm not sure if this is the right place for newspaper bug?  I don't see any bug report feature on z10 device similar to the older versions of the operating system, I have to raise this issue here.

    I went in my device settings - 'About' to change the name of devcie for a description more usability.  The default when registering on Rogers was 'BLACKBERRY - 54 A 8' for my device.

    I tried to change 'Mike z10' and after an attempt to save, I get the following error "device name not valid - have chosen you an invalid name.  A devcie name must be alphanumeric and may contain '-'and'.', but not as the characters of the first or the last and '.' can only be used as part of a complete domain name. "

    I don't think I'm violates all the above statement, however, it doesn't let me save?  I think this could be a bug?

    Mike

    It worked.  Thank you!

    May be a suggestion to the State in the error message that the name must not include space because it does not currently.

  • How to insert the value of a LONG data type?

    Hi all

    Developers what to change the type of data in the PRODUCTS table.

    PRODUCT
    ======
    ID number (10) not null,
    NAME varchar2 (50) not null,
    DESCR varchar2 (250) not null


    They want the DESCR to change datataype at LENGTH

    So I got back it up first:

    create the table product_bak in select * from product;
    remove the product;
    change the product table change (descr, null);
    Edit the product table change (long descr);
    Insert into select product * from product_bak;

    ORA - 997 - illegal use of LONG data type


    How can I recover my data?


    Thank you very much.

    Use TO_LOB to convert long on the CLOB type, then use TO_CHAR to convert CLOB VARCHAR2.

  • I am installng Photoshop CS6 after uninstalling it because of problems.  I have inserted the disc, download serial number and and get a screen with a brass lock and red one declaring "implemented without modifications. Type your password to allow this. "I

    How to reset a password to make changes in photoshop, when I don't know what password am I missing? @

    It is most likely your operating system, asking a password to prove that you have permission to install

  • How get the sum of differences in time

    I have the query to get the taken (duration) of time to perform each activity below


    Select (select ep.name PE env_mapping where ep.id = p.bsa_env_id) environment,
    (Select trunc ((Max (ps.actual_end) - Min (ps.actual_start)) * 24 * 60) of ps Highlevel_activity where ps.activity_ID = p.id and ps.out_of_window_flag =' no. "") Actual_duration,
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Apps Patching"and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = ' NO') Apps_Patching,.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, Highlevel_activity ps where de.task_type = ' Patching DB/MT ' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = ' NO') DB_MT_Patching,.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Shut Down' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = ' NO') Shut_Down,.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Start Up' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = ' NO') Start_Up,.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Vérification' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = 'NO') audit.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Patching meadow' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = ' NO') Pre_Patching,.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Patching Post' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = ' NO') Post_Patching,.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Others' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = 'NO') others

    activity p where

    I get the output as below

    EnV1 27 April 13 167 54 29 29 15 0 0 67 0
    EnV2 may 3 13 10 20 05 05 0 0 50 0 33


    My requirement is to get the amount for each column which I get on top of the query. How can I change the query above to get as the result below


    EnV1 27 April 13 167 54 29 29 15 0 0 67 0
    EnV2 may 3 13 10 20 05 05 0 0 50 0 33
    177 74 34 34 15 50 67 33 total

    Please help

    Thank you
    Archana

    Hello

    Agowda wrote:
    I have the query to get the taken (duration) of time to perform each activity below

    Select (select ep.name PE env_mapping where ep.id = p.bsa_env_id) environment,
    (Select trunc ((Max (ps.actual_end) - Min (ps.actual_start)) * 24 * 60) of ps Highlevel_activity where ps.activity_ID = p.id and ps.out_of_window_flag =' no. "") Actual_duration,
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Apps Patching"and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = ' NO') Apps_Patching,.


    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, Highlevel_activity ps where de.task_type = ' Patching DB/MT ' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = ' NO') DB_MT_Patching,.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Shut Down' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = ' NO') Shut_Down,.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Start Up' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = ' NO') Start_Up,.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Vérification' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = 'NO') audit.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Patching meadow' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = ' NO') Pre_Patching,.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Patching Post' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = ' NO') Post_Patching,.
    (select nvl (trunc ((max (de.actual_end) - min (de.actual_start)) * 24 * 60), '0') Detail_activity time_taken, ps Highlevel_activity where de.task_type = 'Others' and ps.activity_id = p.id and.) Highlevel_activity_id = ps.id and ps. OUT_OF_WINDOW_FLAG = 'NO') others

    activity p where

    If you make 9 of subqueries to get 9 different columns. It is very inefficient, and it is also difficult to maintain. If you need to change the conditions in subqueries, you will need to do the exact same change at 9 different locations.
    It would be much more effective if you just add de.task_type to the GROUP BY clause and then rotates the results. He could not run 9 times faster, but it probably run 5 times faster.
    See the FAQ forum {message identifier: = 9360005} to find out how.

    I get the output as below

    EnV1 27 April 13 167 54 29 29 15 0 0 67 0
    EnV2 may 3 13 10 20 05 05 0 0 50 0 33

    My requirement is to get the amount for each column which I get on top of the query. How can I change the query above to get as the result below

    EnV1 27 April 13 167 54 29 29 15 0 0 67 0
    EnV2 may 3 13 10 20 05 05 0 0 50 0 33
    177 74 34 34 15 50 67 33 total

    It's a GROUPING DEFINED work, no ACCUMULATION.

    Since you post CREATE TABLE and INSERT statemennts for your sample data, I will use the hr.departments table to show the difference.
    When you GROUP BY N > 1 the expressions, ROLLUP gives you N + 1 levels of totals and subtotals. For example:

    SELECT       department_id
    ,       job_id
    ,       SUM (salary)     AS total_sal
    FROM       hr.employees
    GROUP BY  ROLLUP (department_id, job_id)
    ORDER BY  department_id, job_id
    ;
    

    The above query GROUPs BY s expressions (department_id job_id) so ROLLUP produces 3 sorts of totals:
    (1) total department_id and job_id (e.g. 13000 for department_id = 20 and job_id = "Fatyty" below)
    (2) total Department, including all of the work (e.g. 6000 = 19000 13000 + for department_id = 20) and
    (3) total general for the entire result (e.g. 691416)

    DEPARTMENT_ID JOB_ID      TOTAL_SAL
    ------------- ---------- ----------
               10 AD_ASST          4400
               10                  4400
               20 MK_MAN          13000
               20 MK_REP           6000
               20                 19000
               30 PU_CLERK        13900
               30 PU_MAN          11000
               30                 24900
               40 HR_REP           6500
               40                  6500
               50 SH_CLERK        64300
               50 ST_CLERK        55700
               50 ST_MAN          36400
               50                156400
               60 IT_PROG         28800
               60                 28800
               70 PR_REP          10000
               70                 10000
               80 SA_MAN          61000
               80 SA_REP         243500
               80                304500
               90 AD_PRES         24000
               90 AD_VP           34000
               90                 58000
              100 FI_ACCOUNT      39600
              100 FI_MGR          12008
              100                 51608
              110 AC_ACCOUNT       8300
              110 AC_MGR          12008
              110                 20308
                  SA_REP           7000
                                   7000
                                 691416
    

    You don't want all that: you just want what corresponds in total for each department_id and job_id and total general, without any level of iintermediate. Here's how you can achieve these results using GROUPING SETS instead of ROLLUP:

    SELECT       department_id
    ,       job_id
    ,       SUM (salary)     AS total_sal
    FROM       hr.employees
    GROUP BY  GROUPING SETS ( (department_id, job_id)
                   , ()
                   )
    ORDER BY  department_id, job_id
    ;
    
    DEPARTMENT_ID JOB_ID      TOTAL_SAL
    ------------- ---------- ----------
               10 AD_ASST          4400
               20 MK_MAN          13000
               20 MK_REP           6000
               30 PU_CLERK        13900
               30 PU_MAN          11000
               40 HR_REP           6500
               50 SH_CLERK        64300
               50 ST_CLERK        55700
               50 ST_MAN          36400
               60 IT_PROG         28800
               70 PR_REP          10000
               80 SA_MAN          61000
               80 SA_REP         243500
               90 AD_PRES         24000
               90 AD_VP           34000
              100 FI_ACCOUNT      39600
              100 FI_MGR          12008
              110 AC_ACCOUNT       8300
              110 AC_MGR          12008
                  SA_REP           7000
                                 691416
    

    I hope that answers your question.
    If this isn't the case, post CREATE TABLE and INSERT statements for some examples of data and the results desired from these data.
    Simplify the problem. For example, instead of 9 different task_types, post sample data and results for 3 task_types. Simply mention that you actually 9, and we will find a solution that can be easily adapted for 9.
    Always say what version of Oracle you are using (for example, 11.2.0.2.0).
    See the FAQ forum {message identifier: = 9360002}

    Published by: Frank Kulash on May 27, 2013 10:47

  • Select values from the db1 table and insert into the DB2 table

    Hello

    I have three databases oracle running in three different machines. their ip address is different. among the DB can access databases. (means am able to select values and insert values into tables individually.)

    I need to extract data from the DB1 table (ip say DB1 is 10.10.10.10 and the user is DB1user and the table is DB1user_table) and insert the values into DB2 table (say ip DB2 is 11.11.11.11 and the user is DB2user and table DB2user_table) of DB3 that is to have access to the two IPs DB.

    How do I do this

    Edited by: Aemunathan on February 10, 2010 23:12

    Depending on the amount of data must be moved between DB1 and DB2, and the frequency at which this should happen, you might consider the SQL * COPY more control. I think it's very useful for one-off tasks little, so I can live within its limits of the data type. More http://download.oracle.com/docs/cd/E11882_01/server.112/e10823/apb.htm#i641251.

    Change some parameter of sqlplus session are almost mandatory in order to get decent transfer rates. Tuning ARRAYSIZE and COPYCOMMIT can make a huge difference in flow. LONG change may be necessary, too, depending on your data. The documentation offers these notes on use:

    To activate the copy of data between Oracle and databases non-Oracle, NUMBER of columns is replaced by DECIMAL columns in the destination table. Therefore, if you are copying between Oracle databases, a NUMBER column with no precision will become a DECIMAL column (38). When copying between Oracle databases, you must use SQL commands (CREATE TABLE AS and INSERTION), or you must make sure that your columns have a specified precision.

    SQL * the VALUE LONGER variable limits the length of the LONG column you are copying. If all LONG columns contain data exceeds the value of LONG, COPY truncates the data.

    SQL * Plus performs a validation at the end of each successful COPY. If you set the SQL * variable more COPYCOMMIT DEFINED to a value positive n, SQL * Plus performs a validation after copying all lots n of records. The SQL * Plus ARRAYSIZE variable SET determines the size of a batch.

    Some operating environments require that the service names be placed between double quotes.

    From a SQL * Plus term on DB3, can resemble the command to move all content from my_table in DB1 to the same table in DB2

    COPY from user1/pass1@DB1 to user2/pass2@DB2 -
    INSERT INTO my_table -
    USING select * from my_table
    

    Note the SQL code * more line-continuation character ' - '. It is used to escape the newline character in a SQL * Plus command if you do not have to type all on one line. I use it all the time with this command, but I can't locate the documentation on that right now. Maybe someone else can put their finger on it.

    There are other ways to accomplish what the command copy and it is not without its quirks and limitations, but I find that there is usefulness in an Oracle Toolbox.

  • ROWTYPE to get the best query?

    Hello

    I have two identical paintings:

    PHOTOS_TEMP AND IMAGES_TEST
    (ID PK number , 
    content blob,
    filename varchar2 (200),
    mimetype varchar2 (200),
    filesize varchar2 (200),
    res_id FK number,
    watermarked varchar2 (1))
    I have 1 CODE, I want to make it more effective perhaps using % ROWTYPE,
    So, I tried 2 CODE, but it didn't work. He said, 'too many values... '. CONTENT must be declared... »

    Can you plesae tune Code 1?

    H1. CODE 1 works fine
    DECLARE
    type source_col is table of blob index by pls_integer ;
    V_source source_col;
     
     
    type id_col is table of number index by pls_integer ;
    V_id id_col;
     
     
    type char_col is table of IMAGES_TEST.FILENAME%TYPE index by pls_integer ; 
    V_filename char_col;
    V_mimetype char_col;
     
    begin 
     
     
    select content,filename,mimetype,id bulk collect into
     V_source,v_filename,v_mimetype,v_id from photos_temp
    where  temp = :P700_TEMP_IMAGE   for update  ;
     
     
     
     
    for i in V_source.first .. V_source.last 
    loop
    ORDSYS.ORDImage.process(V_source(i), 'fixedScale=800 500');
    end loop;
     
    forall i in V_source.first .. V_source.last 
    insert into IMAGES_test
     (res_id ,CONTENT,filename,mimetype,filesize,watermarked) 
    values 
    (:P700_res_ID ,V_source(i),V_filename(i),V_mimetype(i),
    dbms_lob.getlength(V_source(i)), 'Y');
    COMMIT;
     
     
    EXCEPTION
       WHEN OTHERS THEN
       RAISE;
    END;
    H1. CODE 2 is supposed to be more efficient, but does not?
    DECLARE
     
    
    type new_row is table of IMAGES_TEST%rowtype index by pls_integer ; 
    v_row new_row;
     
    begin 
     
    
     -- This may collect more than one row
    select * bulk collect into
     v_row from photos_temp
    where  temp = :P700_TEMP_IMAGE   for update  ;
    
     
     
    for i in v_row.id.first .. v_row.id.last 
    loop
    ORDSYS.ORDImage.process(v_row.content(i), 'fixedScale=800 500');
    end loop;
     
    forall i in v_row.id.first .. v_row.id.last 
    insert into IMAGES_test
     (res_id ,CONTENT,filename,mimetype,filesize,watermarked) 
    values 
    (:P700_res_ID ,v_row.contnet(i),v_row.filename(i),v_row.mimetype(i),
    dbms_lob.getlength(v_row.content(i)), 'Y');
     
    COMMIT;
     
     
    
    EXCEPTION
       WHEN OTHERS THEN
       RAISE;
    END;
    Best regards
    Fateh

    Published by: Fateh on November 26, 2012 05:22

    Hello

    In your CODE 1

    ...
    select content,filename,mimetype,id bulk collect into
     V_source,v_filename,v_mimetype,v_id from photos_temp
    where  temp = :P700_TEMP_IMAGE   for update  ;
    
    -- temp is not a collumn name nor a variable name
    ...
    

    So I think that it does not work.

    In code 2, you must use the index '(i)' on the table variable, not the attribute. So:
    v_row.contnet (i) - THIS IS WRONG!
    v_row (i) .contnet - it's OK
    Also:
    v_row.ID. First - THIS IS WRONG!
    v_row. First - it's OK

    Here's a working example:

    insert into photos_temp (id ,filename) values ( 1,'peter');
    insert into photos_temp (id ,filename) values ( 2,'Fateh');
    commit;
    
    DECLARE
    type new_row is table of IMAGES_TEST%rowtype index by pls_integer ;
    v_row new_row;
    
    begin
      select * bulk collect into
       v_row from photos_temp
      --where  temp = :P700_TEMP_IMAGE
      for update  ;
    
      --for i in v_row.id.first .. v_row.id.last
      for i in v_row.first .. v_row.last
      loop
      DBMS_OUTPUT.PUT_LINE('Id: ' || v_row(i).id || ' filename: ' || v_row(i).filename);
      end loop;
    
    end;
    
    Result:
    Id: 1 filename: peter
    Id: 2 filename: Fateh
    

    And in your case to encode simplified 2:

    DECLARE
    type new_row is table of IMAGES_TEST%rowtype index by pls_integer ;
    v_row new_row;
    
    begin
      select * bulk collect into
       v_row from photos_temp
      --where  temp = :P700_TEMP_IMAGE
      for update  ;
    
      --forall i in v_row.id.first .. v_row.id.last
      forall i in v_row.first .. v_row.last
      insert into IMAGES_test
      (id ,filename)
      values
      (v_row(i).id, v_row(i).filename);
    
    end;
    /
    select
      id
      ,filename
    from
      images_test;
    
    Result:
    ID FILENAME
    -- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
     1 peter
     2 Fateh                                                                                                                                                                                                    
    

    That it works:
    Oracle Database 11 g Enterprise Edition Release 11.2.0.1.0 - 64 bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    "CORE 11.2.0.1.0 Production."
    AMT for 64-bit Windows: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production

    I think in oracle 9, you should use separate table variables and not a variable array of a scalar type.

    Kind regards

    Peter

  • Read data from table of $ E and insert in the staging table

    Hi all

    I'm new on ODI. I need your help to understand how to read data from a table ' E$ "and insert in an intermediate table.

    Scenario:

    The name of two columns, in a flat file, the employee and the employee id must be loaded into a data EMPstore +. A check constraint is added so that the data with the employee names in capital letters only to load in the data store. Check the command is set to the static movement . Right-click on the data store, select control , then check. The lines that have violated the check constraint are kept in E$ _EMP+ table.

    Problem:

    Problem is I want to read the data in the table E$ _EMP+ and transform in capital letters in the name of the employee and move the corrected data of E$ _EMP+ EMP+. Please advise me on how to automatically manage the 'soft' exceptions in ODI.

    Thank you

    If I understand, you want to change the columns in the tables of $ E and then load into the target.

    Now, if you notice how ODI recycles the error, there is an incremental update to the target using the E table $ after he filled the I$ table.

    I think you can do the same thing by creating an interface using the table of $ E as source and implement the business logic in this interface to fill the target.

  • How to get the total number of lines workbook Table Page-Details

    Hi all

    I built a workbook Page-detail Table. In addition, my section of the page is 'user of assets '. Then, when I click the users button, it shows me, credit notes different from the user that I was selected. The problem is that I want to show a percentage by user.

    For example:
    -------------------

    The query returns me assets 40 for all users.

    But for example I click the first user who has only 10 credit notes.

    I want to show at the end of the page: "this user is:" 25% (because I calculate 10 * 100/40). "."

    How can I do this? Because I found that I can show the number of lines that are in the screen, but not the total of the lines referring to my request.

    I use Oracle Desktop, but I have no problem using Oracle Discoverer Plus.

    I really appreciate your help.

    Best regards!
    Mariano. -.

    You can do it directly in the front as you wish but you can manipulate the spreadsheet to do something like.
    By creating a calculation that will contain the data you need you can then present in the page point right next to the user name.
    If you change the user in the page element, it will present the % that you wanted.

    do that create a new calculation, called "is the percentage of this user:
    To_char (COUNT (credit memos) OVER (PARTITION BY User) * 100/COUNT(credit memos) OVER (), '990D99'). « % »

    Place the calculation in the page element.

    There is a small restriction since if you just change the user it will work fine, but if you pick the design value, then you will get a mess.

    Beside that, you can use the 'text area' of the discoverer and put for example here: (exactly the name of the calc) "& is the percentage of this user.

    Well, it's not perfect, but maybe it can be used...

  • How can I get a name of table 1, column A, if column B is a negative number and insert the names of table 2?

    How can I get a name of table 1, column A, if column B is a negative number and insert the names of table 2?

    What is the formula?

    You can do this with a column of "index" in table 1, as this assistance:

    The formula in C2, filled to the bottom:

    IF (B =<>

    That increments a counter each time that it finds a negative number in column B.

    In the second table, you can retrieve a list of negative values in this way:

    The formula in A2, filled to the bottom:

    = INDEX (array 1::A, CORRESPONDENCE (LINE (−1, Table 1::C), 0))

    It takes the line number, the formula is activated, subtracts 1 to the header line and look up the result in the column of table 1 C.  If it finds a match, it feeds the line number to the INDEX page with retrieves the value of the column of table 1A.

    To hide the red triangles of signage wrap the IFERROR formula, like this:

    = SIERREUR (INDEX (table 1::A, CORRESPONDENCE (LINE (−1, Table 1::C), 0)),"")

    Of course, you can also simply filter on column B without the need to set up a column from another table or index.

    SG

  • To get the name of the table the column

    Hi I have an Html5 app, and I get the dataset from the database and bind the data based on the column name. but the answer of the oracle db column names as attr_1, attr_2 and so on. Here is the code and the result after execution.

    create or replace PACKAGE SAYAM
    IS
           CURSOR cur
           IS
                  SELECT CAST(0 AS NUMBER(5, 0)) "COMPID" ,
                         CAST(0 AS NUMBER(4, 0)) "FINYEARID" ,
                         EMPLOYEEID,
                         CAST(0 AS NUMBER(5, 0))"MENUID" ,
                         CAST('' AS NVARCHAR2(10))"CALLBYPANEL",
                         EmployeeName
                  FROM  EmployeeInfo;
                 
    Type cur_tbl
    IS
           TABLE OF cur%rowtype;
          
    END SAYAM;
    
    

    DECLARE
           v_GlobalParam Xmltype:=Xmltype(
           '<QueryParam> 
    <CompID>1</CompID> 
    <FinYearID>1</FinYearID> 
    <MenuID>0</MenuID> 
    <EmployeeID>-1</EmployeeID> 
    <CallByPanel>APPWEB</CallByPanel>
    <EmployeeName>Ranjit</EmployeeName>
    </QueryParam>'
           );
           tableglobal SAYAM.cur_tbl;
           rc sys_refcursor;
    BEGIN
           SELECT XT.CompID,
                  XT.FinYearID,
                  XT.MenuID,
                  XT.EmployeeID,
                  XT.CallByPanel,
                  XT.EmployeName bulk collect
           INTO   tableglobal
           FROM   XMLTABLE('/QueryParam' PASSING v_GlobalParam COLUMNS
                  CompID NUMBER(5) PATH 'CompID' ,
                  FinYearID NUMBER(4) PATH 'FinYearID' ,
                  MenuID NUMBER(5) PATH 'MenuID' ,
                  EmployeeID NUMBER(5) PATH 'EmployeeID' ,
                  CallByPanel VARCHAR2(10) PATH 'CallByPanel',
                  EmployeeName Varchar2(200) Path 'EmployeeName' ) XT;
           OPEN rc FOR SELECT * FROM TABLE(tableglobal);
           SYS.DBMS_SQL.RETURN_RESULT(rc);
    END;
    
    
    

    Now, I get the below result-

    Capture.PNG

    but the goal that is required is as below with the valid column name

    Capture.PNG

    Please let me know if there is any action to get the column names.

    Thanks in advance.

    Apologies - I have managed to reproduce the original problem in 12.1.0.2.

    The problem with ATTR column names is that you use a local collection declared in a package.

    You need a SQL type.

    But does not change my position when it comes to a sensible direction to go.

    SQL> l
      1  create or replace type sayam_obj as object
      2  (compid      number(5,0)
      3  ,finyearid    number(4,0)
      4  ,employeeid  number
      5  ,menuid      number(5,0)
      6  ,callbypanel  nvarchar2(10)
      7* ,employeename varchar2(100));
    SQL> /
    
    Type created.
    
    SQL> create or replace type sayam_tbl as table of sayam_obj;
      2  /
    
    Type created.
    
    SQL> get test3.sql
      1    DECLARE
      2        v_GlobalParam Xmltype:=Xmltype(
      3        '
      4    1
      5    1
      6    0
      7    -1
      8    APPWEB
      9    Ranjit
    10    '
    11        );
    12        tableglobal sayam_tbl := sayam_tbl();
    13        rc sys_refcursor;
    14    BEGIN
    15        SELECT sayam_obj(XT.CompID,
    16              XT.FinYearID,
    17              XT.MenuID,
    18              XT.EmployeeID,
    19              XT.CallByPanel,
    20              XT.EmployeeName) bulk collect
    21        INTO  tableglobal
    22        FROM  XMLTABLE('/QueryParam' PASSING v_GlobalParam COLUMNS
    23              CompID NUMBER(5) PATH 'CompID' ,
    24              FinYearID NUMBER(4) PATH 'FinYearID' ,
    25              MenuID NUMBER(5) PATH 'MenuID' ,
    26              EmployeeID NUMBER(5) PATH 'EmployeeID' ,
    27              CallByPanel VARCHAR2(10) PATH 'CallByPanel',
    28              EmployeeName Varchar2(200) Path 'EmployeeName' ) XT;
    29        OPEN rc FOR SELECT * FROM TABLE(tableglobal);
    30        SYS.DBMS_SQL.RETURN_RESULT(rc);
    31*    END;
    SQL> @test3.sql
    
    PL/SQL procedure successfully completed.
    
    ResultSet #1
    
        COMPID  FINYEARID EMPLOYEEID    MENUID CALLBYPANE
    ---------- ---------- ---------- ---------- ----------
    EMPLOYEENAME
    --------------------------------------------------------------------------------
        1        1          0    -1 APPWEB
    Ranjit
    
  • Get the only table name in model executing the revese engineer but columns do not come

    Get the only table name in model executing the revese engineer but columns do not come. I used the standard procedure.  Please let me know why I am not getting column in my model.

    I have attached the screen shot for the same thing.

    This is a table or a synonym? In the case of synonym or try to add the property as it appears below thread.

    Reverse engineering a synonym in ODI 11 G.

    Or maybe go with personal setbacks.

  • How to get the diagram ER or master child tables details

    Hi team,

    I would like to get the details of the child Master Table Details (ER Diagram). I use the PLSQL developer.

    Could you please suggest how to get this tool or by using the query.

    Thank you

    Vincent

    Hi mohamed,.

    Please use TOAD. You ask to go to the link below: -.

    Toad Data Modeling - Diagram ER to create and generate the Script DDL/SQL - videos - Toad Data Modeling - Toad World

    Thank you

    Jihane Narain Sylca

  • Starting from two data tables, how do you get the values in two columns using values in a column (values get col. If col. A is not null values and get the pass. B if col. A is null)?

    Two tables provided, how you retrieve the values in two columns using values in a column (the pass get values. If col. A is not null values and get the pass. B if col. A is null)?

    Guessing

    Select nvl (x.col_a, y.col_b) the_column

    from table_1 x,.

    table_2 y

    where x.pk = y.pk

    Concerning

    Etbin

  • How can I get the name of the package where a table is used

    Hello... Hello...

    How can I know the name of the package or procedures where a particular table is used?

    is there a such sql query, I can get the names?

    It should work. Not tested.

    SELECT *
      FROM USER_DEPENDENCIES
     WHERE     TYPE LIKE 'PACKAGE%'
           AND REFERENCED_TYPE = 'TABLE'
           AND REFERENCED_NAME = 'YOUR_TABLE_NAME'  --Replace with the table name you are looking for
    

    G.

    Edited by: g. on February 23, 2011 12:42 AM

Maybe you are looking for