Pivoting multiple coulmn values into multiple columns dynamically

Hi,
i have found some topics related to 'pivot' in this forum. but my situation is a lit bit different.
I have a table like the below
create
table #temp
(id
int, code
varchar(8),
routing varchar(50))
insert
into #temp(id,code
,routing
values(1,    
'code1',     
'route1')
,(1,'code11','route11')
,(2,  
'code22',    
'route22')
,(2,  
'code222',   
'route222')
,(2,  
'code2333',  
'route2333')
,(2,  
'code2',     
'route2')
,(3,  
'code3',     
'route3'),
(4,   
'code4',     
'route4'),
(4,   
'code44',    
'route44')
ID
CODE
ROUTE
1
code1
route1
1
code11
route11
2
code22
route22
2
code222
route222
2
code2333
route2333
2
code2
route2
3
code3
route3
4
code4
route4
4
code44
route44
And I need to display the table below format including column names. And code/routing columns can repeat not more than 10 times.
id
code
routing
code
routing
code
routing
code
routing
1
code1
route1
code11
route11
2
code2
route2
code22
route22
code222
route222
code2333
route2333
3
code3
route3
4
code4
route4
code44
route44
I am using sql server 2012.
i have benefited alot from this forum. a big thank you to the forum.
I would appreciate  your help.

Refer below solution with PIVOT. You can extend by using Dynamic Pivot.
--create table #temp (id int, code varchar(8), routing varchar(50))
--insert into #temp (id,code ,routing ) values(1,'code1','route1')
--,(1,'code11','route11'),(2,'code22','route22'),(2,'code222','route222'),(2,'code2333','route2333')
--,(2,'code2', 'route2'),(3,'code3', 'route3'),(4,'code4','route4'),(4,'code44','route44')
;with cte1 as (
select *,row_number() over (partition by id order by code) rn
from #temp
),cte2 as (
select *, case
when id=id then 'code_' + cast(rn as varchar) end codeCol, case
when id=id then 'routing_' + cast(rn as varchar) end routingCol
from cte1
),cte3 as (
select id,code_1,routing_1,code_2,routing_2,code_3,routing_3, code_4,routing_4 from cte2
pivot(max(code) for codeCol in (code_1,code_2,code_3,code_4)) pvt
pivot(max(routing) for routingCol in (routing_1,routing_2,routing_3,routing_4) ) pvt1
select id,
max(code_1) code_1,max(routing_1) routing_1,
max(code_2) code_2,max(routing_2) routing_2,
max(code_3) code_3,max(routing_3) routing_3,
max(code_4) code_4,max(routing_4) routing_4
from cte3
group by id
For dynamic pivot technique refer below query sample,
DECLARE
@cols nvarchar(max),
@stmt nvarchar(max)
SELECT @cols = isnull(@cols + ', ', '') + '[' + T.[NAME] + ']' FROM (SELECT distinct [NAME] FROM PIVOTTEST) as T
SELECT @stmt = '
SELECT *
FROM PIVOTTEST as T
PIVOT
max(T.VALUE)
for T.[NAME] in (' + @cols + ')
) as P'
exec sp_executesql @stmt = @stmt
select * from PIVOTTEST
Regards, RSingh

Similar Messages

  • Concatenate multiple row values into single column value

    Hello,
    Can anyone please refresh my memory on how to concatenate multiple row values into a single column value.
    In the following query, I will get multiple denial reasons per application and I would rather return all denial reasons on one line.
    SELECT a.application_id, a.membership_number,
    r.reason_text AS denial_reason,
    a.appl_receipt_date AS application_receipt_date,
    a.plan_request_1 AS application_plan_code,
    a.adjudication_date AS application_denial_date
    FROM application a, PLAN p, application_reason ar, reason r
    WHERE a.plan_request_1 = p.plan_cd
    AND a.application_id = ar.application_id
    AND ar.reason_id = r.reason_id
    AND a.adjudication_cd = 'D'
    AND a.appl_receipt_date BETWEEN '01-jan-2006' AND '31-dec-2006'
    AND p.plan_type_id = 12 and a.application_id = :appId
    ORDER BY application_id
    Any help is greatly appreciated.
    Thanks,
    -Christine

    found the following
    SELECT deptno,
           LTRIM(MAX(SYS_CONNECT_BY_PATH(ename,','))
           KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
    FROM   (SELECT deptno,
                   ename,
                   ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) AS curr,
                   ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) -1 AS prev
            FROM   emp)
    GROUP BY deptno
    CONNECT BY prev = PRIOR curr AND deptno = PRIOR deptno
    START WITH curr = 1;
        DEPTNO EMPLOYEES
            10 CLARK,KING,MILLER
            20 ADAMS,FORD,JONES,SCOTT,SMITH
            30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
    3 rows selected.at http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php

  • To display comma separted value into multiple column

    Hi,
    I want to display value into multiple column like below
    data is like this
    col1
    res_menaHome:MenaHome
    res_menaHomeEmp:MenaHome Employee
    res_MDSpecialSer:MD Special Services
    res_Smart:Smart
    now i want to display like
    col1 col2
    res_menaHome MenaHome
    res_menaHomeEmp MenaHome Employee
    res_MDSpecialSer MD Special Services
    res_Smart Smart
    Thanks in advance.

    You mean like this?
    with q as (select 'res_menaHome:MenaHome' myString from dual)
    select substr(myString, 1, instr(myString, ':') - 1) col1,
    substr(myString, instr(myString, ':') + 1) col2
    from q
    COL1,COL2
    res_menaHome,MenaHome

  • How to insert parameter value into multiple columns and rows

    Hi All,
    I have one procedure insert_tab and I am passing
    100~101~102:103~104~105:106~107~108 as a parameter to that procedure. I wanted to insert each numeric value into one column. The output of the table should contain
    Table:
    Col1 Col2 Col3
    100 101 102
    103 104 105
    106 107 108
    Awaiting for your reply..

    That's not more clear for me...
    Anyway, if you really want a procedure for that, try :
    SQL> create table tblstr (col1 number,col2 number,col3 number);
    Table created.
    SQL>
    SQL> create or replace procedure insert_fct (p_string IN varchar2)
      2  as
      3  v_string     varchar2(4000):=p_string||':';
      4  v_substring  varchar2(4000);
      5 
      6  begin
      7      while instr(v_string,':') > 0 loop
      8            v_substring := substr(v_string,1,instr(v_string,':')-1)||'~';
      9            insert into tblstr(col1,col2,col3)
    10            values (substr(v_substring,1,instr(v_substring,'~',1,1)-1),
    11                    substr(v_substring,instr(v_substring,'~',1,1)+1,instr(v_substring,'~',1,2)-instr(v_substring,'~',1,1)-1),
    12                    substr(v_substring,instr(v_substring,'~',1,2)+1,instr(v_substring,'~',1,3)-instr(v_substring,'~',1,2)-1));
    13            v_string:=substr(v_string,instr(v_string,':')+1);
    14      end loop;
    15  end;
    16  /
    Procedure created.
    SQL>
    SQL> show err
    No errors.
    SQL>
    SQL> select * from tblstr;
    no rows selected
    SQL> exec insert_fct('100~101~102:103~104~105:106~107~108')
    PL/SQL procedure successfully completed.
    SQL> select * from tblstr;
          COL1       COL2       COL3
           100        101        102
           103        104        105
           106        107        108
    SQL> exec insert_fct('109~~')
    PL/SQL procedure successfully completed.
    SQL> exec insert_fct('~110~')
    PL/SQL procedure successfully completed.
    SQL> exec insert_fct('~~111')
    PL/SQL procedure successfully completed.
    SQL> select * from tblstr;
          COL1       COL2       COL3
           100        101        102
           103        104        105
           106        107        108
           109
                      110
                                 111
    6 rows selected.
    SQL> Nicolas.

  • Please - immediate help needed parsing csv values into multiple rows

    Hello, we have a very immediate need to be able to parse out a field of comma separated values into individual rows. The following is an example written in SQL Server syntax which does not work in Oracle.
    The tricky part is that each ROUTES can be a different length, and each CSV can have a different number of routes in it.
    Here is an example of the table ("Quotes") of CSV values I want to normalize:
    TPNUMBER ROUTES
    1001 1, 56W, 18
    1002 2, 16, 186, 28
    Here is an example of what I need it to look like:
    TPNUMBER ROUTES
    1001 1
    1001 56W
    1001 18
    1002 2
    1002 16
    1002 186
    1002 28
    Here is the "Tally" table for the query below:
    ID
    1
    2
    3
    4
    5
    6
    7
    And finally, here is the query which parses CSV values into multiple rows but which does not work in Oralce:
    SELECT TPNUMBER,
    NullIf(SubString(',' + ROUTES + ',' , ID , CharIndex(',' , ',' + ROUTES + ',' , ID) - ID) , '') AS ONEROUTE
    FROM Tally, Quotes
    WHERE ID <= Len(',' + ROUTES + ',') AND SubString(',' + Phrase + ',' , ID - 1, 1) = ','
    AND CharIndex(',' , ',' + ROUTES + ',' , ID) - ID > 0
    It may be necessary to use a cursor to loop through the CSV table and process each row (a loop within another loop...) but this is beyond my comprehesion of PL/SQL.
    Many thanks in advance for your advice/help.
    apk

    Not sure what you are trying to do with the last step, but this should work for the first part. I assume you would use sqlldr but I just did inserts instead. You might need more than 5 "routes" in the csv. You could put some reasonable max on that number of columns:
    SQL>create table t_csv
    2 (TPNUMBER varchar2(20),
    3 ROUTE_1 VARCHAR2(5),
    4 ROUTE_2 VARCHAR2(5),
    5 ROUTE_3 VARCHAR2(5),
    6 ROUTE_4 VARCHAR2(5),
    7 ROUTE_5 VARCHAR2(5),
    8 ROUTE_6 VARCHAR2(5) );
    Table created.
    SQL>INSERT INTO t_csv (TPNUMBER,ROUTE_1,ROUTE_2) values( '1001 1', '56W', '18' );
    1 row created.
    SQL>INSERT INTO t_csv (TPNUMBER,ROUTE_1,ROUTE_2,ROUTE_3) values( '1002 2', '16', '186', '28');
    1 row created.
    SQL>create table t_quotes(
    2 tpnumber NUMBER,
    3 routes VARCHAR2(5));
    Table created.
    SQL>DECLARE
    2 L_tpnumber NUMBER;
    3 L_route VARCHAR2(5);
    4 begin
    5 for rec in (select * from t_csv) loop
    6 L_tpnumber := SUBSTR(rec.tpnumber,1,INSTR(rec.tpnumber,' ')-1);
    7 L_route := SUBSTR(rec.tpnumber,INSTR(rec.tpnumber,' ')+1);
    8 insert into t_quotes values( L_tpnumber, l_route );
    9 if rec.route_1 is not null then
    10 insert into t_quotes values( L_tpnumber, rec.route_1 );
    11 end if;
    12 if rec.route_2 is not null then
    13 insert into t_quotes values( L_tpnumber, rec.route_2 );
    14 end if;
    15 if rec.route_3 is not null then
    16 insert into t_quotes values( L_tpnumber, rec.route_3 );
    17 end if;
    18 if rec.route_4 is not null then
    19 insert into t_quotes values( L_tpnumber, rec.route_4 );
    20 end if;
    21 if rec.route_5 is not null then
    22 insert into t_quotes values( L_tpnumber, rec.route_5 );
    23 end if;
    24 end loop;
    25 end;
    26 /
    PL/SQL procedure successfully completed.
    SQL> select tpnumber, routes from t_quotes;
    TPNUMBER ROUTE
    1001 1
    1001 56W
    1001 18
    1002 2
    1002 16
    1002 186
    1002 28
    7 rows selected.

  • How to insert an upper value into a column?

    Hi!,
    I need to insert an upper value into a column.
    The data is on a flat file and it could be lowercase or uppercase?
    Do I have to create a trigger to solve this problem?
    How could the trigger be?
    Thanks,
    Alex

    If you are using SQL*Loader to load the data from flat file into the db table, then you can achieve inserting the UPPER Case of column value in your sqlloader ctl file itself as in below example
    LOAD DATA
    INFILE *
    APPEND INTO TABLE XXX
    ( field1 position(1:7) char "UPPER(:field1)",
    field2 position(8:15) char "UPPER(:field2)"
    BEGINDATA
    Phil Locke
    Jason Durbin
    So in this case the Names Phil Locke and Jason Durbin will be inserted as PHIL LOCKE and JASON DURBIN into the target table.
    Regards,
    Murali Mohan

  • How to copy one column BLOB value into another column of another database.

    How to copy one column BLOB value into another column of another database.
    BLOB value contains word document.
    I thought of copy the BLOB value into a text file and then update the new column value by the same text in textfile. Will this work?
    Is there any other better way to do this?

    You're welcome
    BLOB fields contains binary data. I don't think you can do this
    Also if I view the BLOB as text. Can I copy it and insert into the new database.
    I think your options are as I said. Datapump or CTAS
    Best Regards

  • Multiple Checkbox Values Into One Field

    Hopefully someone can help me with this issue I'm having.
    I'm trying to save the values of multiple selected checkboxes into one field separated by commas through ADDT's Insert Transaction code. I can do this easily with DW's standard insert record wizard by using the PHP implode() function but I haven't been able to figure it out with ADDT's code.
    <form>
    <input type="checkbox" value="1" name="program[]" /> Program One
    <input type="checkbox" value="2" name="program[]" /> Program Two
    <input type="checkbox" value="3" name="program[]" /> Program Three
    <input type="checkbox" value="4" name="program[]" /> Program Four
    </form>
    THIS IS ADDT'S CODING
    $ins_quoteManager->addColumn("programs", "STRING_TYPE",  "POST", "programs");
    THIS WORKS VIA DREAMWEAVER'S INSERT RECORD WIZARD
    Original: GetSQLValueString($_POST['programs'], "text"),
    Modified: GetSQLValueString(implode(',',$_POST['programs']), "text"),
    Anyone know how to modify the ADDT code with the implode function to get this to work?

    Have you tried ADDT´s "comma-separated checkboxes" form control, which will also store the values into a field of your choice (and of course retrieve them from there on update record - pages) ? The only possible drawback might be, that the checkboxes can´t be defined statically, means that the array of value/label - pairs will be retrieved from another table by establishing an additional recordset.
    Cheers,
    Günter

  • Inserting values into multiple tables in one jsf page with single commit op

    hi all,
    i have two tables ,
    one is parent table and other is child record.
    record details:
    table1:(parent table)
    emplid (primary key)
    empl_name
    table 2:(child table)
    empl id ( Foreign key)
    empl_name ( Foreign key)
    contact_no (primary key)
    my senario is , i need insert values into both parent and child table in one save option.
    and both the tables will be in one jsf page.
    is this possible to do?
    thanks all,
    regards,
    M vijayalakshmi

    hi,
    i feel my question is not clear.
    let me explain my question clearly.
    1. i have two records
    *1. emp_names*
    attributes of this table is 1.emplid
    2.emp_name.
    emplid is a primary key.
    2. emp_contact
    attributes of this table is 1.emplid
    2. contact_no
    In this table emplid is forigen key from emp_name table
    contact_no is primary key.
    and my senerio is,
    for one emplid there are many contact no.
    in database diagram i have created these two entities. and from that i have generated two views objects.
    now in jsf page ,
    i shd have all fields from both the records.
    wn ever i click on add button , i shd be able to insert one complete row of data to both the tables.
    means,
    emplid
    empl_name
    contact_no.
    and if i click on commit button data shd be insert in both the tables.
    so how to achive this?
    am very beginner to the jdeveloper tool.
    regards,
    m vijayalakshmi.

  • Sql loader - mutiple values into one column

    Hi,
    Is it possible to load multiple fields into one column. Eg, my table structure has two columns COL1, COL2 and my data file is comma delimted with 3 fields A,B,C.
    How could i use sql loader to achieve (without the use of temp tables)
    COL1 = A
    COL2 = BC
    Thanks

    I don't understand why you can't modify the input fille.
    But anyway, i have 2 ways to help you
    1. Make new inputfile online using pipe and awk(or something your are familiar with) and use it as new input file.
    This is a traditional and powerful method in Unix environment.
    For instance:
    oracle> $ mknod pipe.dat p
    oracle> cat input.dat | awk '{print ...}' > pipe.dat &
    oracle> sqlldr ctl=.. data=pipe.dat
    Using this method, you don't need to modify original input file physically, but by some magical trick you can modify it on the fly.
    2. Use before trigger
    For instance:
    create table load(a int, b int, c int, d int);
    create or replace trigger load_trigger
    before insert on load
    for each row
    begin
    :new.d := :new.b + :new.c;
    :new.b := null;
    :new.c := null;
    end;
    load data
    infile *
    append
    into table load
    fields terminated by "," optionally enclosed by '"'
    (a, b, c)
    begindata
    1, 1, 1
    2, 2, 2
    3, 3, 3
    4, 4, 4
    sqlldr userid=... ctl=load.ctl
    SQL> select * from load;
    A B C D
    1 2
    2 4
    3 6
    4 8
    You won't like the existence of unnecessary columns(B, C) but don't have choice. ^^;
    I think there is another simple way provided by SQL*Loader. But i've never tried it myself. Read following doc and try it yourself:
    http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch06.htm#1008153

  • Parsing colon(:) delimited values into separate columns

    Hello folks
    I have source data where the columns contain data in text format separated by colons. Now I want the data pulled from each column separated by colons into individual columns in my target table.
    For example
    1. My source table looks like this.
    create table src
    (id number,
    field1 varchar2(50),
    field2 varchar2(50),
    field3 varchar2(50));
    insert into src values (1,'M:1:N:2','Mon:1:Tue:2::3','Jan:1:Feb:2:Mar::Apr:4');
    insert into src values (2,':1:N:2',':1:Tue:2::3','Jan:1::2:::Apr:4');
    insert into src values (3,':::2','Mon:::2::3','Jan');
    2. Target table contains individual column.
    create table tgt
    (id number,
    field1 varchar2(50),
    field2 varchar2(50),
    field3 varchar2(50),
    field4 varchar2(50),
    field5 varchar2(50),
    field6 varchar2(50),
    field7 varchar2(50),
    field8 varchar2(50),
    field9 varchar2(50),
    field10 varchar2(50),
    field11 varchar2(50),
    field12 varchar2(50),
    field13 varchar2(50),
    field14 varchar2(50),
    field15 varchar2(50),
    field16 varchar2(50),
    field17 varchar2(50),
    field18 varchar2(50));
    3. If you run the below inserts, you will come to know how my target should be populated.
    insert into tgt values (1,'M','1','N','2','Mon','1','Tue','2',NULL,'3','Jan','1','Feb','2','Mar',NULL,'Apr','4');
    insert into tgt values (2,NULL,'1','N','2',NULL,'1','Tue','2',NULL,'3','Jan','1',NULL,'2',NULL,NULL,'Apr','4');
    insert into tgt values (3,NULL,NULL,NULL,'2','Mon',NULL,NULL,'2',NULL,'3','Jan',NULL,NULL,NULL,NULL,NULL,NULL,NULL);Although the total number columns to be populated in tgt from each source column is fixed but as you can see they are all dynamic when it comes to population of field in source. I have covered three different types of data set in source. Also, in future we can get a new id like 4 with different columns populated but going into the same target table, so I am in need of something which can upgraded without any major code change for future as well.
    Any help in this regard would be much appreciated. Many Thanks.

    Like this?
    Your table
    SQL> select * from src;
            ID FIELD1                         FIELD2                         FIELD3
             1 M:1:N:2                        Mon:1:Tue:2::3                 Jan:1:Feb:2:Mar::Apr:4
             2 :1:N:2                         :1:Tue:2::3                    Jan:1::2:::Apr:4
             3 :::2                           Mon:::2::3                     Jan
             4                                Mon:::2::3                     Jan:1:Feb:2:Mar::Apr:4
    Modified query
    select id
         , substr(new_field, instr(new_field, ':', 1, 1) + 1, instr(new_field, ':', 1, 2) - instr(new_field, ':', 1, 1) - 1) field_1
         , substr(new_field, instr(new_field, ':', 1, 2) + 1, instr(new_field, ':', 1, 3) - instr(new_field, ':', 1, 2) - 1) field_2
         , substr(new_field, instr(new_field, ':', 1, 3) + 1, instr(new_field, ':', 1, 4) - instr(new_field, ':', 1, 3) - 1) field_3
         , substr(new_field, instr(new_field, ':', 1, 4) + 1, instr(new_field, ':', 1, 5) - instr(new_field, ':', 1, 4) - 1) field_4
         , substr(new_field, instr(new_field, ':', 1, 5) + 1, instr(new_field, ':', 1, 6) - instr(new_field, ':', 1, 5) - 1) field_5
         , substr(new_field, instr(new_field, ':', 1, 6) + 1, instr(new_field, ':', 1, 7) - instr(new_field, ':', 1, 6) - 1) field_6
         , substr(new_field, instr(new_field, ':', 1, 7) + 1, instr(new_field, ':', 1, 8) - instr(new_field, ':', 1, 7) - 1) field_7
         , substr(new_field, instr(new_field, ':', 1, 8) + 1, instr(new_field, ':', 1, 9) - instr(new_field, ':', 1, 8) - 1) field_8
         , substr(new_field, instr(new_field, ':', 1, 9) + 1, instr(new_field, ':', 1,10) - instr(new_field, ':', 1, 9) - 1) field_9
         , substr(new_field, instr(new_field, ':', 1,10) + 1, instr(new_field, ':', 1,11) - instr(new_field, ':', 1,10) - 1) field_10
         , substr(new_field, instr(new_field, ':', 1,11) + 1, instr(new_field, ':', 1,12) - instr(new_field, ':', 1,11) - 1) field_11
         , substr(new_field, instr(new_field, ':', 1,12) + 1, instr(new_field, ':', 1,13) - instr(new_field, ':', 1,12) - 1) field_12
         , substr(new_field, instr(new_field, ':', 1,13) + 1, instr(new_field, ':', 1,14) - instr(new_field, ':', 1,13) - 1) field_13
         , substr(new_field, instr(new_field, ':', 1,14) + 1, instr(new_field, ':', 1,15) - instr(new_field, ':', 1,14) - 1) field_14
         , substr(new_field, instr(new_field, ':', 1,15) + 1, instr(new_field, ':', 1,16) - instr(new_field, ':', 1,15) - 1) field_15
         , substr(new_field, instr(new_field, ':', 1,16) + 1, instr(new_field, ':', 1,17) - instr(new_field, ':', 1,16) - 1) field_16
         , substr(new_field, instr(new_field, ':', 1,17) + 1, instr(new_field, ':', 1,18) - instr(new_field, ':', 1,17) - 1) field_17
         , substr(new_field, instr(new_field, ':', 1,18) + 1, instr(new_field, ':', 1,19) - instr(new_field, ':', 1,18) - 1) field_18
      from (
              select id
                   , decode(field1, null, '', ':') || field1 ||
                     decode(field2, null, '', ':') || field2 ||
                     decode(field3, null, '', ':') || field3 || ':' new_field
                from src
    ID FIELD_1    FIELD_2    FIELD_3    FIELD_4    FIELD_5    FIELD_6    FIELD_7    FIELD_8    FIELD_9    FIELD_10   FIELD_11   FIELD_12   FIELD_13   FIELD_14   FIELD_15   FIELD_16   FIELD_17   FIELD_18
    1 M          1          N          2          Mon        1          Tue        2                     3          Jan        1          Feb        2          Mar                   Apr        4         
    2            1          N          2                     1          Tue        2                     3          Jan        1                     2                                Apr        4         
    3                                  2          Mon                              2                     3          Jan                                                                                    
    4 Mon                              2                     3          Jan        1          Feb        2          Mar                   Apr        4                                                     

  • Insert value into a column based on value of another column

    Hi,
    I am trying to insert a value into a record based on a column in
    the record, using a trigger. The complication arises because
    the new value is selected from the same table. For example:
    SELECT COL1, COL2, COL3, COL4 from TABLE1
    I want to set COL2 and COL3 based on the value of COL4. And to
    get the value of COL2 and COL3, I will go back to TABLE1 and set
    the condition to TABLE1.COL1 = :NEW.COL4
    I cannot seem to execute the trigger as I get the message "ORA-
    04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
    see it" everytime.
    Is this the correct way to achieve what I wanted? Or is there
    another way?
    Appreciate your feedback. Thank you in advance.

    Hi,
    I am trying to insert a value into a record based on a column in
    the record, using a trigger. The complication arises because
    the new value is selected from the same table. For example:
    SELECT COL1, COL2, COL3, COL4 from TABLE1
    I want to set COL2 and COL3 based on the value of COL4. And to
    get the value of COL2 and COL3, I will go back to TABLE1 and set
    the condition to TABLE1.COL1 = :NEW.COL4
    I cannot seem to execute the trigger as I get the message "ORA-
    04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
    see it" everytime.
    Is this the correct way to achieve what I wanted? Or is there
    another way?
    Appreciate your feedback. Thank you in advance. I'm not sure what you mean when you insert a value into a
    record, but if you are setting a value in a column of the same
    record using a trigger, then it's easy.
    :new.COL2 := ....:new.COL4...
    :new.COL3 := ....:new.COL4...
    The trigger must be 'INSERT or UPDATE' and 'FOR EACH RECORD'.
    If you are setting a different record in the same table, the
    solution is much more difficult.

  • Multiple XMP Metadata into Multiple PDF

    Hi, recently I've been trying to change the xmp metadata of multiple pdf, I already tried using Bridge and some other 3rd Party Programs but the issue is that all of those solutions just change the same information into multiple files, and what I want is to change different information into multiple files...
    is there a way to load the info from a *.csv or a *.xmp
    to be more precise I'm trying to change the Title Metadata of a tons of PDF but every file has a different Title... how can I do it massively?

    You may want to repost this in the XMP SDK forum:  http://forums.adobe.com/community/design_development/xmp_sdk

  • Convert multiple page pdf into multiple page jpeg

    This question was posed several years ago but not answered completely.
    I have a 7MB three page PDF document ( a scan ) that I'd like to reduce in size so that I might attach it to an email it easily.
    I've tried to "reduce file size" in Preview app's PDF export settings but that renders the document unreadable and useless.
    I've tried to Preview export to jpeg but only one page at a time gets exported. This is not acceptable. I want a single three page document.
    Otherwise I have to wait 10 minutes for the pdf to attach to my email and God only knows what the recipient thinks when they see "7MB attached document".
    BTW I've also tried adding the pdfs to a Word document but that introduced a mismatched document sizing anomaly. WHAT THE HECK!!!! Why can't this be easier???

    Anybody know if it's possible to convert a multiple page PDF into ONE TIFF file in Acrobat Pro?
    No.

  • How to fetch Junk values and its columns dynamically

    Hello,
    Can anyone help me in writing a procedure/dynamic SQL to fetch the column where the junk values appears and its value. Eg: If emp table contains ID and Name columns, and ID column contains junk values, the result should be the Id column and the junk value/s. It should be dynamic because next time if the other column contains junk values(like $,%...), the query should display the other column too..
    Thanks in advance..

    Can anyone help me in writing a procedure/dynamic SQL to fetch the column where the junk values appears and its value. Eg: If emp table contains ID and Name columns, and ID column contains junk values, the result should be the Id column and the junk value/s. It should be dynamic because next time if the other column contains junk values(like $,%...), the query should display the other column too..1. define "junk" values.
    2. usually it does not matter what values are in ID, because it is used internally by application, to maintain uniqueness or relations, not having any semantical meaning. End users usually should not see IDs, such IDs are generated automatically. There is no need to cleanse them from "junk" values.
    3. If you made a typo, and you are looking for "junk" values in Name column, it is a different story. You can use TRANSLATE to search such values, as already advised, translating all "junk" characters to one "junk" character and searching for the latter.
    select id, name from T where translate(name,'?@#$%^<>','~~~~~~~~~') like '%~%';
    Edited by: Mark Malakanov (user11181920) on Jan 4, 2013 11:40 AM

Maybe you are looking for

  • Safari 5.1.7 Tab - How to close them with 1 click?

    I have just installed Safari 5.1.7. What happened to the X in the tabs to close them? I have looked in preferences, can't see any obvious way of restoring the missing "click on the X to close" option. I now have to right click & select close from a d

  • IPOD WONT COMMUNICATE WITH ITUNES!!!!

    I just got my ipod nano today I thought it would be the best thing ever. But, when I use iTunes, my ipod doesnt show up and it gives me an alert telling me that it wont communticate and to re-install. I re-installed at least 12 times. Is my iPod brok

  • How can I prevent shows/movies from auto-downloading?

    Hello, I'm looking for a way to keep my iTunes purchases from using up several hundred gigabytes of hard drive space, and I'm really confused about how to go about doing that. Let me give an example of the problem: After I purchase a movie, I'll let

  • How can we display photo of particular person on webdynpro abap view

    hello gurus,                  i am very new to webdynpro abap.i have one requirement.could any one can suggest me to overcome my requirement. in my requirement i have one view.in that view i need to display one photo image which ever saved on my desk

  • Need Desired Output

    HELLO EVERYONE, PLZ HELP ME WITH THE BELOW QUERY. THE BELOW CONDTION SHOULD BE APPLIED FOR THE DATA CASE COUNT (MAX(ADATE) )                WHEN 1 THEN '15'                WHEN 2 THEN '30'                WHEN 3 THEN '60'                WHEN 4 THEN '1