Rows into matrix

Lets say I have a table defined as
create table factors
( datasource varchar(20),
v1 varchar2(10) ,
v2 varchar2(10) ,
value integer
The value column holds co-variance data. In other words the number of distinct values in v1 and v2 for given datasource is always the same. Lets say the distinct values of v1 and v2 are f1 ... f10. The number of rows would be ( 10* 9) / 2 ) + 10 = 55
I want to return a 10 x 10 matrix with all possible values filled in. What is the best way to do this with only one scan of data? Preferably done in PLSQL. It's pretty trivial in perl but I need to to hook this to some tool the can just run sql stmt or execute a stored proc.
Thanks!

That's why I was trying to write something a little more generic.
The problems you are going to face are:
a) What determines the order of the v1, v2 values in the matrix?. You'll see in my code, as far as I got, that I had to explicitly define the distinct v1/v2 values in order to get them out in the order you had specified. If the v1/v2 values can be different, how can a program or SQL know what order they should be in?
b) As you'll see in my example, I was dealing with 4 distinct v1/v2 values explicitly. If the requirement is to have anything from 2 upwards of these values then you're getting into the realms of dynamically creating your output. This is most likely going to be done in PL/SQL, however if you are specifically requiring the output to come out as queried rows and columns (i.e. to use in some other SQL) then you are going to struggle to get this dynamically for varying columns without writing multiple pipeline functions for the different number of columns (the number of rows doesn't matter so much as SQL's very flexible in that respect) or by having the output always producing the maximum possible columns with nulls in those that aren't used. I think there may be some possible means by using Objects (see How to pipeline a function with a dynamic number of columns? for an example of dynamically pipelining multiple columns), but that's outside the scope of my time to investigate for you)
Edit...
Ok here goes something dynamic (up to 4 distinct v1/v2 values, but easily expandable):-
SQL> CREATE TABLE t AS SELECT 'US' as pid, 'value' as v1, 'value' as v2, 1123 as val from dual union all
  2        select 'US', 'value', 'banks', 0.10 from dual union all
  3        select 'US', 'value', 'internet', 0.02 from dual union all
  4        select 'US', 'value', 'biotech', 0.055 from dual union all
  5        select 'US', 'banks', 'banks', 456 from dual union all
  6        select 'US', 'banks', 'internet', 2.33 from dual union all
  7        select 'US', 'banks', 'biotech', 4.33 from dual union all
  8        select 'US', 'internet', 'internet', 1.1111 from dual union all
  9        select 'US', 'internet', 'biotech', 0.9099 from dual union all
10        select 'US', 'biotech', 'biotech', 7.7777 from dual union all
11        select 'UK', 'value', 'value', 1 from dual union all
12        select 'UK', 'value', 'internet', 2 from dual union all
13        select 'UK', 'value', 'agents', 3 from dual union all
14        select 'UK', 'internet', 'internet', 4 from dual union all
15        select 'UK', 'internet', 'agents', 5 from dual union all
16        select 'UK', 'agents', 'agents', 6 from dual
17  /
Table created.
SQL>
SQL> create type matrix_rec as object (lbl varchar2(10)
  2                                   ,val1 varchar2(10)
  3                                   ,val2 varchar2(10)
  4                                   ,val3 varchar2(10)
  5                                   ,val4 varchar2(10))
  6  /
Type created.
SQL>
SQL> create type matrix_row as table of matrix_rec
  2  /
Type created.
SQL>
SQL> create or replace function show_matrix(p_id IN VARCHAR2) RETURN matrix_row PIPELINED IS
  2    CURSOR val(y IN VARCHAR2,x IN VARCHAR2) IS
  3      SELECT DISTINCT val
  4      FROM t
  5                             WHERE pid = p_id
  6      AND   ((v1 = y AND v2 = x) OR (v1 = x AND v2 = y));
  7
  8    v   SYS_REFCURSOR;
  9    x   SYS_REFCURSOR;
10    y   SYS_REFCURSOR;
11    o   matrix_rec := matrix_rec(null, null, null, null, null);
12    l   VARCHAR2(10);
13    r   NUMBER;
14    ly  VARCHAR2(10);
15    lx  VARCHAR2(10);
16    xyv NUMBER;
17  begin
18    -- put out a heading
19    o.lbl := p_id;
20    OPEN v FOR 'SELECT rownum rn, v1 FROM (SELECT DISTINCT v1 FROM t WHERE pid = :p_id ORDER BY v1)' USING p_id;
21    LOOP
22      FETCH v INTO r, l;
23      EXIT WHEN v%NOTFOUND;
24      CASE r
25        WHEN 1 THEN o.val1 := l;
26        WHEN 2 THEN o.val2 := l;
27        WHEN 3 THEN o.val3 := l;
28        WHEN 4 THEN o.val4 := l;
29      ELSE NULL;
30      END CASE;
31    END LOOP;
32    CLOSE v;
33    PIPE ROW (o);
34
35    -- now output the rows of data
36    OPEN y FOR 'SELECT DISTINCT v1 FROM t WHERE pid = :p_id ORDER BY v1' USING p_id;
37    LOOP
38      FETCH y INTO ly;
39      EXIT WHEN y%NOTFOUND;
40      OPEN x FOR 'SELECT rownum rn, v1 FROM (SELECT DISTINCT v1 FROM t WHERE pid = :p_id ORDER BY v1)' USING p_id;
41      LOOP
42        FETCH x INTO r, lx;
43        EXIT WHEN x%NOTFOUND;
44        SELECT DISTINCT val
45        INTO xyv
46        FROM t
47                             WHERE pid = p_id
48        AND   ((v1 = ly AND v2 = lx) OR (v1 = lx AND v2 = ly));
49        o.lbl := ly;
50        CASE r
51                   WHEN 1 THEN o.val1 := xyv;
52                   WHEN 2 THEN o.val2 := xyv;
53                   WHEN 3 THEN o.val3 := xyv;
54                   WHEN 4 THEN o.val4 := xyv;
55                 ELSE NULL;
56                 END CASE;
57      END LOOP;
58      CLOSE x;
59      PIPE ROW (o);
60    END LOOP;
61    CLOSE y;
62  end;
63  /
Function created.
SQL> select * from table(show_matrix('US'));
LBL        VAL1       VAL2       VAL3       VAL4
US         banks      biotech    internet   value
banks      456        4.33       2.33       .1
biotech    4.33       7.7777     .9099      .055
internet   2.33       .9099      1.1111     .02
value      .1         .055       .02        1123
SQL> select * from table(show_matrix('UK'));
LBL        VAL1       VAL2       VAL3       VAL4
UK         agents     internet   value
agents     6          5          3
internet   5          4          2
value      3          2          1
SQL>Message was edited by:
blushadow

Similar Messages

  • Add new row in Matrix in SBO 2004

    Hi All,
    I created a form by using screen painter and loaded data into matrix by using datasource.That is working fine. But when i add new row in that matrix, it copies  all data from the  last row in that matrix. How will i clear the row to add new values in the row?
    Please help me.
    Thanks in advance
    Denis

    Hello Denis,
    OK, I see the problem.
    This is because your datasource are on the last row, so whenever you add a new row to the matrix, the last record in your datasource will be added. My suggestion is to modify datasource instead of matix itself, and then use oMatrix.LoadfromDatasource to load all the data back to matrix.
    Hope this helps,
    Nick

  • How To Concatenate Column Values from Multiple Rows into a Single Column?

    How do I create a SQL query that will concatenate column values from multiple rows into a single column?
    Last First Code
    Lesand Danny 1
    Lesand Danny 2
    Lesand Danny 3
    Benedi Eric 7
    Benedi Eric 14
    Result should look like:
    Last First Codes
    Lesand Danny 1,2,3
    Benedi Eric 7,14
    Thanks,
    David Johnson

    Starting with Oracle 9i
    select last, first, substr(max(sys_connect_by_path(code,',')),2) codes
    from
    (select last, first, code, row_number() over(partition by last, first order by code) rn
    from a)
    connect by last = prior last and first = prior first and prior rn = rn -1
    start with rn = 1
    group by last, first
    LAST       FIRST      CODES                                                                                                                                                                                                  
    Lesand         Danny          1,2,3
    Benedi         Eric           7,14Regards
    Dmytro

  • How do I stop FireFox from converting css3 transforms such as scale, or rotate, into matrix transforms?

    Go to pilatch.com/cards and click any of the cards in the arc. Now do the same in Chrome, or Safari, or IE 9. I have un-min-catted all my JavaScript, so you can see what's going on more easily.
    CSS3 transforms in version 16 of FireFox are being converted into matrix transforms.
    It pretty much horks my rotate and scale animations.
    For instance, if you set the style attribute of an element to something like, style="transform:scale(0.75)", FireFox immediately converts that element's transform property, such as <element>.style.transform to "matrix(...)".
    I know how to do the linear algebra to convert rotate and scale via jQuery cssHooks into matrix transformations, and I've even written code to detect this "feature" of a browser, (that it forces a transform into matrix), and return a different hook that writes a matrix transform instead of a rotate transform, or scale, all in the past two days, on my development site.
    However, it's proving to be increasingly challenging to make this new feature compatible with jQuery's animations. Going further, I may have to hack jQuery just to make this work for FireFox, or drop FireFox animation support altogether unless some FireFox developers make their new implementation backwards compatible.
    I know that transforms normally get converted into matrices behind the scenes in the rendering engine. Leave your matrix there. Don't overwrite what the user has put in for a transform!
    I also know that I should be using CSS3 animations, but, dangit, I started this project before those had widespread support. I can't rewrite all my animations because I want to support FireFox. That's not really an option. I'll direct my users to Chrome instead. I have more features in development that use these types of animation, and I'm in too deep to turn back.
    Thanks for your consideration. Please contact me as you learn more about this.
    -Beefzilla

    The URL in question is [http://pilatch.com/cards pilatch.com/cards]

  • Need help with turning multiple rows into a single row

    Hello.
    I've come across a situation that is somewhat beyond my knowledge base. I could use a little help with figuring this out.
    My situation:
    I am attempting to do some reporting from a JIRA database. What I am doing is getting the dates and times for specific step points of a ticket. This is resulting in many rows per ticket. What I need to do is return one row per ticket with a calculation of time between each step. But one issue is that if a ticket is re-opened, I want to ignore all data beyond the first close date. Also, not all tickets are in a closed state. I am attaching code and a sample list of the results. If I am not quite clear, please ask for information and I will attempt to provide more. The database is 10.2.0.4
    select jiraissue.id, pkey, reporter, summary
    ,changegroup.created change_dt
    ,dbms_lob.substr(changeitem.newstring,15,1) change_type
    ,row_number() OVER ( PARTITION BY jiraissue.id ORDER BY changegroup.created ASC ) AS order_row
    from jiraissue
    ,changeitem, changegroup
    ,(select * from customfieldvalue where customfield = 10591 and stringvalue = 'Support') phaseinfo
    where jiraissue.project = 10110
    and jiraissue.issuetype = 51
    and dbms_lob.substr(changeitem.newstring,15,1) in ('Blocked','Closed','Testing','Open')
    and phaseinfo.issue = jiraissue.id
    and changeitem.groupid = changegroup.id
    and changegroup.issueid = jiraissue.id
    order by jiraissue.id,change_dt
    Results:
    1     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2008-07-16 9:30:38 AM     Open     1
    2     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2008-07-16 11:37:02 AM     Testing     2
    3     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2010-06-08 9:14:52 AM     Closed     3
    4     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2010-09-02 11:29:37 AM     Open     4
    5     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2010-09-02 11:29:42 AM     Open     5
    6     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2010-09-02 11:29:50 AM     Testing     6
    7     21191     QCS-91     Error running the Earliest-deadlines flight interface request/response message     2010-09-02 11:29:53 AM     Closed     7
    8     23234     QCS-208     System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role      2008-10-03 10:26:21 AM     Open     1
    9     23234     QCS-208     System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role      2008-11-17 9:39:39 AM     Testing     2
    10     23234     QCS-208     System Baseline - OK button does not show up in the Defer Faults page for the System Engineer role      2011-02-02 6:18:02 AM     Closed     3
    11     23977     QCS-311     Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks     2008-09-29 2:44:54 PM     Open     1
    12     23977     QCS-311     Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks     2010-05-29 4:47:37 PM     Blocked     2
    13     23977     QCS-311     Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks     2011-02-02 6:14:57 AM     Open     3
    14     23977     QCS-311     Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks     2011-02-02 6:15:32 AM     Testing     4
    15     23977     QCS-311     Tally Sheet - Reason Not Done fails to provide reason for unassigned tasks     2011-02-02 6:15:47 AM     Closed     5

    Hi,
    Welcome to the forum!
    StblJmpr wrote:
    ... I am attempting to do some reporting from a JIRA database. What is a JIRA database?
    I am attaching code and a sample list of the results. If I am not quite clear, please ask for information and I will attempt to provide more. Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and the results you want from that data.
    Simplify the problem as much as possible. For example, if the part you don't know how to do only involves 2 tables, then jsut post a question involving those 2 tables. So you might just post this much data:
    CREATE TABLE     changegroup
    (      issueid          NUMBER
    ,      created          DATE
    ,      id          NUMBER
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2008-07-16 09:30:38 AM', 'YYYY-MM-DD HH:MI:SS AM'),  10);
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2008-07-16 11:37:02 AM', 'YYYY-MM-DD HH:MI:SS AM'),  20);
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2010-06-08 09:14:52 AM', 'YYYY-MM-DD HH:MI:SS AM'),  90);
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2010-09-02 11:29:37 AM', 'YYYY-MM-DD HH:MI:SS AM'),  10);
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2010-09-02 11:29:42 AM', 'YYYY-MM-DD HH:MI:SS AM'),  10);
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2010-09-02 11:29:50 AM', 'YYYY-MM-DD HH:MI:SS AM'),  20);
    INSERT INTO changegroup (issueid, created, id) VALUES (21191,  TO_DATE ('2010-09-02 11:29:53 AM', 'YYYY-MM-DD HH:MI:SS AM'),  90);
    INSERT INTO changegroup (issueid, created, id) VALUES (23234,  TO_DATE ('2008-10-03 10:26:21 AM', 'YYYY-MM-DD HH:MI:SS AM'),  10);
    INSERT INTO changegroup (issueid, created, id) VALUES (23234,  TO_DATE ('2008-11-17 09:39:39 AM', 'YYYY-MM-DD HH:MI:SS AM'),  20);
    INSERT INTO changegroup (issueid, created, id) VALUES (23234,  TO_DATE ('2011-02-02 06:18:02 AM', 'YYYY-MM-DD HH:MI:SS AM'),  90);
    INSERT INTO changegroup (issueid, created, id) VALUES (23977,  TO_DATE ('2008-09-29 02:44:54 PM', 'YYYY-MM-DD HH:MI:SS AM'),  10);
    INSERT INTO changegroup (issueid, created, id) VALUES (23977,  TO_DATE ('2010-05-29 04:47:37 PM', 'YYYY-MM-DD HH:MI:SS AM'),  30);
    INSERT INTO changegroup (issueid, created, id) VALUES (23977,  TO_DATE ('2011-02-02 06:14:57 AM', 'YYYY-MM-DD HH:MI:SS AM'),  10);
    INSERT INTO changegroup (issueid, created, id) VALUES (23977,  TO_DATE ('2011-02-02 06:15:32 AM', 'YYYY-MM-DD HH:MI:SS AM'),  20);
    INSERT INTO changegroup (issueid, created, id) VALUES (23977,  TO_DATE ('2011-02-02 06:15:47 AM', 'YYYY-MM-DD HH:MI:SS AM'),  90);
    CREATE TABLE     changeitem
    (      groupid          NUMBER
    ,      newstring     VARCHAR2 (10)
    INSERT INTO changeitem (groupid, newstring) VALUES (10, 'Open');
    INSERT INTO changeitem (groupid, newstring) VALUES (20, 'Testing');
    INSERT INTO changeitem (groupid, newstring) VALUES (30, 'Blocked');
    INSERT INTO changeitem (groupid, newstring) VALUES (90, 'Closed');Then post the results you want to get from that data, like this:
    ISSUEID HISTORY
      21191 Open (0) >> Testing (692) >> Closed
      23234 Open (45) >> Testing (807) >> Closed
      23977 Open (607) >> Blocked (249) >> Open (0) >> Testing (0) >> ClosedExplain how you get those results from that data. For example:
    "The output contains one row per issueid. The HISTORY coloumn shows the different states that the issue went through, in order by created, starting with the earliest one and continuing up until the first 'Closed' state, if there is one. Take the first row, issueid=21191, for example. It started as 'Open' on July 16, 2008, then, on the same day (that is, 0 days later) changed to 'Testing', and then, on June 8, 2010, (692 days later), it became 'Closed'. That same issue opened again later, on September 2, 2010, but I don't want to see any activity after the first 'Closed'."
    The database is 10.2.0.4That's very important. Always post your version, like you did.
    Here's one way to get those results from that data:
    WITH     got_order_row     AS
         SELECT     cg.issueid
         ,     LEAD (cg.created) OVER ( PARTITION BY  cg.issueid
                                          ORDER BY      cg.created
                  - cg.created            AS days_in_stage
         ,       ROW_NUMBER ()     OVER ( PARTITION BY  cg.issueid
                                          ORDER BY      cg.created
                               )    AS order_row
         ,     ci.newstring                     AS change_type
         FROM    changegroup     cg
         JOIN     changeitem     ci  ON   cg.id     = ci.groupid
         WHERE     ci.newstring     IN ( 'Blocked'
                           , 'Closed'
                           , 'Testing'
                           , 'Open'
    --     AND     ...          -- any other filtering goes here
    SELECT       issueid
    ,       SUBSTR ( SYS_CONNECT_BY_PATH ( change_type || CASE
                                                             WHEN  CONNECT_BY_ISLEAF = 0
                                           THEN  ' ('
                                              || ROUND (days_in_stage)
                                              || ')'
                                                         END
                                    , ' >> '
               , 5
               )     AS history
    FROM       got_order_row
    WHERE       CONNECT_BY_ISLEAF     = 1
    START WITH     order_row          = 1
    CONNECT BY     order_row          = PRIOR order_row + 1
         AND     issueid               = PRIOR issueid
         AND     PRIOR change_type     != 'Closed'
    ORDER BY  issueid
    ;Combining data from several rows into one big delimited VARCHAR2 column on one row is call String Aggregation .
    I hope this answers your question, but I guessed at so many things, I won't be surprised if it doesn't. If that's the case, point out where this is wrong, post what the results should be in those places, and explain how you get those results. Post new data, if necessary.

  • Error inserting a row into a table with identity column using cfgrid on change

    I got an error on trying to insert a row into a table with identity column using cfgrid on change see below
    also i would like to use cfstoreproc instead of cfquery but which argument i need to pass and how to use it usually i use stored procedure
    update table (xxx,xxx,xxx)
    values (uu,uuu,uu)
         My component
    <!--- Edit a Media Type  --->
        <cffunction name="cfn_MediaType_Update" access="remote">
            <cfargument name="gridaction" type="string" required="yes">
            <cfargument name="gridrow" type="struct" required="yes">
            <cfargument name="gridchanged" type="struct" required="yes">
            <!--- Local variables --->
            <cfset var colname="">
            <cfset var value="">
            <!--- Process gridaction --->
            <cfswitch expression="#ARGUMENTS.gridaction#">
                <!--- Process updates --->
                <cfcase value="U">
                    <!--- Get column name and value --->
                    <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                    <cfset value=ARGUMENTS.gridchanged[colname]>
                    <!--- Perform actual update --->
                    <cfquery datasource="#application.dsn#">
                    UPDATE SP.MediaType
                    SET #colname# = '#value#'
                    WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
                    </cfquery>
                </cfcase>
                <!--- Process deletes --->
                <cfcase value="D">
                    <!--- Perform actual delete --->
                    <cfquery datasource="#application.dsn#">
                    update SP.MediaType
                    set Deleted=1
                    WHERE MediaTypeID = #ARGUMENTS.gridrow.MediaTypeID#
                    </cfquery>
                </cfcase>
                <cfcase value="I">
                    <!--- Get column name and value --->
                    <cfset colname=StructKeyList(ARGUMENTS.gridchanged)>
                    <cfset value=ARGUMENTS.gridchanged[colname]>
                    <!--- Perform actual update --->
                   <cfquery datasource="#application.dsn#">
                    insert into  SP.MediaType (#colname#)
                    Values ('#value#')              
                    </cfquery>
                </cfcase>
            </cfswitch>
        </cffunction>
    my table
    mediatype:
    mediatypeid primary key,identity
    mediatypename
    my code is
    <cfform method="post" name="GridExampleForm">
            <cfgrid format="html" name="grid_Tables2" pagesize="3"  selectmode="edit" width="800px" 
            delete="yes"
            insert="yes"
                  bind="cfc:sp3.testing.MediaType.cfn_MediaType_All
                                                                ({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
                  onchange="cfc:sp3.testing.MediaType.cfn_MediaType_Update({cfgridaction},
                                                {cfgridrow},
                                                {cfgridchanged})">
                <cfgridcolumn name="MediaTypeID" header="ID"  display="no"/>
                <cfgridcolumn name="MediaTypeName" header="Media Type" />
            </cfgrid>
    </cfform>
    on insert I get the following error message ajax logging error message
    http: Error invoking xxxxxxx/MediaType.cfc : Element '' is undefined in a CFML structure referenced as part of an expression.
    {"gridaction":"I","gridrow":{"MEDIATYPEID":"","MEDIATYPENAME":"uuuuuu","CFGRIDROWINDEX":4} ,"gridchanged":{}}
    Thanks

    Is this with the Travel database or another database?
    If it's another database then make sure your columns
    allow nulls. To check this in the Server Navigator, expand
    your DataSource down to the column.
    Select the column and view the Is Nullable property
    in the Property Sheet
    If still no luck, check out a tutorial, like Performing Inserts, ...
    http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/index.jsp
    John

  • Need to insert rows into 100 tables at a time

    hi there,
    below is our script for creation of 100 tables...
    we need a plsql script, to insert rows into 100 tables at a single time...
    please help us...vey urgent...
    DECLARE
    counter NUMBER;
    sql_string VARCHAR2(2000);
    BEGIN FOR counter IN 1..100 LOOP sql_string := 'CREATE TABLE emp_table'||counter||'
    (id integer primary key, col_a VARCHAR2(42),col_b date,col_c number,col_d varchar2(20),col_e varchar2(20),
    col_f varchar2(20),col_g varchar2(20),col_h date,col_i varchar2(20),col_j varchar2(20),col_k date)';
    EXECUTE IMMEDIATE sql_string;
    END LOOP;
    END;
    /

    hi,
    below is our procedure and the error we are getting...
    Name Null? Type
    ID VARCHAR2(10)
    COL_A VARCHAR2(10)
    COL_B VARCHAR2(10)
    COL_C VARCHAR2(10)
    COL_D VARCHAR2(10)
    COL_E VARCHAR2(10)
    COL_F VARCHAR2(10)
    COL_G VARCHAR2(10)
    COL_H VARCHAR2(10)
    COL_J DATE
    DECLARE
    counter NUMBER;
    sql_string VARCHAR2(4000);
    BEGIN FOR counter IN 1..100 LOOP sql_string := 'CREATE TABLE emp_a'||counter||'
    (id varchar2(10), col_a varchar2(10), col_b varchar2(10), col_c varchar2(10), col_d varchar2(10), col_e varchar2(10),
    col_f varchar2(10), col_g varchar2(10), col_h varchar2(10), col_j date)';
    EXECUTE IMMEDIATE sql_string;
    END LOOP;
    END;
    DECLARE
    counter NUMBER;
    sql_string VARCHAR2 (2000);
    BEGIN
    FOR OuterCounter IN 1 .. 100 LOOP --- table prefix in which it is to be inserted
    FOR InnerCounter IN 1 .. 100 LOOP --- records to be inserted
    sql_string := 'INSERT INTO emp_a' || Outercounter || ' (id, col_a, col_b, col_c, col_d, col_e, col_f, col_g, col_h, col_j)
    VALUES ('
    || InnerCounter || ', to_char( ''col_a''' || innercounter || '),'
    || InnerCounter || ', to_char( ''col_d''' || innercounter || '),'
    || ', to_char( ''col_e''' || innercounter || '),'
    || ', to_char( ''col_f''' || innercounter || '),'
    || ', to_char( ''col_g''' || innercounter || '),'
    || ', to_char( ''col_h''' || innercounter || '),'
    || ', to_char( ''col_j''' || innercounter || '), SYSDATE)';
    EXECUTE IMMEDIATE sql_string;
    END LOOP;
    END LOOP;
    END;
    DECLARE
    ERROR at line 1:
    ORA-00907: missing right parenthesis
    ORA-06512: at line 17
    please check the procedure and write the correct one...

  • Get Multiple Rows into internal Table using Webdynpro Alv Display ..

    Hi guys ,
    I need to find out the logic for getting all the selected rows into the internal table.
    When i display the ALV Output on webdypro screen .
    USer Selects multiple rows for further processing ..
    Ineed to get all the rows selected by user into an internal table .
    Please let me know how to achive this ...
    Thanks in advance for quick reply
    Regards
    Saurabh Goel

    Hi,
    You need to use the method GET_SELECTED of IF_WD_CONTEXT_NODE to get the rows selected. Also ccheck for the paramters of that method, this retruns the element set.
    This meets your requirement.
    Regards,
    Lekha.

  • Inserting rows into a data block

    Hi, how do i insert 'n' rows into a data block and after that commit the changes into the data base.
    Thanks for any help.

    You can use something like this:
    Go_Block('my_block');
    first_record;
    LOOP
    .... insert values to the items
    next_record;
    END LOOP;
    - for commiting changes
    Do_Key('Commit_Form');
    I hope this will help you.
    Helena

  • Inserting Multiple Rows into Database Table using JDBC Adapter - Efficiency

    I need to insert multiple rows into a database table using the JDBC adapter (receiver).
    I understand the traditional way of repeating the statement multiple times, each having its <access> element. However, I am just wondering whether this might be performance-inefficient, as it might insert records one by one.
    Is there a way to ensure that the records are inserted into the table as a block, rather than record-by-record?

    Hi Bhavesh/Kanwaljit,
    If we have multiple ACCESS tags then what happens is that the connection to the database is made only once. But the data is inserted row by row.
    Why i am saying this?
    If we add the following in JDBC Adapter..logSQLStatement = true. Then incase of multiple inserts we can see that there are multiple
    <i>Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','1000')
    Insert into tablename(EMP_NAME,EMP_ID) VALUES('J','2000')</i>
    Doesnt this mean that rows are inserted one by one?
    Correct me if i am wrong.
    This does not mean that the transaction is not guaranted. Either all the rows will be inserted or rolled back.
    Regards,
    Sumit

  • Help in inserting rows into a table

    I have a table called acct_fact,
    I need to insert rows in the table using a script but the problem is there's a column called seq_nbr which has random seq nbr of 14character length like 'ZWX98MGD9MVAD6J','ZWX98MG67RVAD6J' etc.,
    While inserting rows I need to generate such seq_nbr for those columns and insert rows into the table, can I use any such mechanism in my insert query to insert such random nbr's while inserting rows into a table.
    If so please suggest me

    Hi Peter,
    Thankyou for the quick reply:)
    can you suggest me how to implement it here in my script snippet:
    while read var_acct_nbr
    do
    echo "update acct_attr set acct_attr_exp_dt ='$ExpDate' where Acct_Attr_Value_Text='15' and acct_attr_exp_dt is null and person_id='LDCarrBillAgrm' and acct_nbr='$var_acct_nbr' ;" >> ./$DirectoryName/SQLQuery_$TimeStamp.sql
    echo "insert into acct_fact values ('$var_acct_nbr','$ExpDate','$ExpTime','*seq_nbr*','N','ProjTereza','Remoção de acordo d; data de expiração: $ExpDate',null,'1','LDE',null);" >> ./$DirectoryName/SQLQuery_$TimeStamp.sql
    done < ./$DirectoryName/ExpireAccts_$TimeStamp.LOG
    the script takes each acct_nbr nbr form a input file and fires an insert statement.
    The one in bold is the column where such sequence need to be inserted.can you help me in implementing the way you suggested in my script i.e., insert statement
    Thanks in Advance:)
    Edited by: rkrish on Jun 27, 2012 3:04 AM

  • How do i insert a row into Numbers

    I'm new to numbers - how do i insert a row into a spreadsheet please?  The spreadshet started life in excel and was imported and saved as numbers.  I did try the help option but didn't seem to get the answer.

    right click on the row tab then select the "Add Row Above" or "Add Row Below"

  • List aggregate two rows into one

    query :
    select kod_negeri.NAMA kod_negeri_nama,
    hakmilik.id_hakmilik,
    MOHON.PENYERAH_NAMA,
    MOHON.PENYERAH_ALAMAT1, MOHON.PENYERAH_ALAMAT2, MOHON.PENYERAH_ALAMAT3,
    MOHON.PENYERAH_ALAMAT4, MOHON.PENYERAH_POSKOD, MOHON.PENYERAH_KOD_NEGERI,
    MOHON.PENYERAH_NO_RUJ, MOHON.ID_MOHON, HAKMILIK.KOD_HAKMILIK, HAKMILIK.NO_HAKMILIK,
    KOD_LOT.NAMA, HAKMILIK.NO_LOT, KOD_BPM.NAMA, KOD_DAERAH.NAMA,
      LELONG.TMPT, LELONG.DIMASUK, PGUNA.NAMA,
      PIHAK.ALAMAT1, pihak.NAMA ven,
    PIHAK.ALAMAT2, PIHAK.ALAMAT3, PIHAK.ALAMAT4, PIHAK.POSKOD,
    mohon.id_mohon ,
    pguna.NAMA pguna_nama,
    pguna.JAWATAN,
    kod_daerah.NAMA kod_daerah_nama,
    to_char(enkuiri.TRH_enkuiri,'DD')||' '|| to_char(enkuiri.TRH_enkuiri,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (enkuiri.TRH_enkuiri, 'YYYY') trh_enkuiri,
    to_char(lelong.TRH_lelong,'DD')||' '|| to_char(lelong.trh_lelong,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (lelong.TRH_lelong, 'YYYY') trh_le,
    to_char(lelong.trh_lelong, 'Day') day,
    to_char(lelong.TRH_lelong,'HH12:MI ')  hour,
    DECODE(SUBSTR(to_char(lelong.TRH_lelong,'HH12:MI AM'),-2,2),'AM','Petang','pagi')  noon,
    enkuiri.cara_lelong,
    lelong.TMPT,
    lelong.HARGA_RIZAB,
    enkuiri.harga_rizab,
    initcap(pihak.NAMA) pihak_nama,
    initcap(lelong.EJA_RIZAB) er,
    'RM'||enkuiri.TUNGGAK_AMAUN,
    lelong.DEPOSIT,
    convert_number_words(lelong.DEPOSIT) as converted_form,
    to_char(lelong.TRH_AKHIR_BYR,'DD')||' '|| to_char(lelong.TRH_AKHIR_BYR,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (lelong.TRH_AKHIR_BYR, 'YYYY') TRH_AKHIR_BYR,
    to_char(sysdate,'DD') ||' '|| to_char(sysdate,'MONTH','nls_date_language=malay') ||' '||to_char(sysdate,'yyyy') sysd,
    kod_bpm.NAMA kod_bpm_nama,
    kod_lot.NAMA kod_lot_nama,
    hakmilik.NO_LOT,
    hakmilik.KOD_HAKMILIK,
    hakmilik.NO_HAKMILIK
    from
    mohon ,
    mohon_hakmilik ,
    lelong ,
    pguna ,
    pihak ,
    kod_daerah ,
    enkuiri ,
    kod_bpm ,
    hakmilik ,
    kod_lot ,
    kod_negeri,
    mohon_fasa ,
    kod_hakmilik
    WHERE mohon.id_mohon = mohon_hakmilik.id_mohon and
    mohon_hakmilik.id_hakmilik = hakmilik.id_hakmilik and
    hakmilik.kod_hakmilik = kod_hakmilik.kod(+) and
    hakmilik.kod_lot  = kod_lot.kod(+) and
    hakmilik.kod_bpm = kod_bpm.kod(+) and
    hakmilik.kod_daerah = kod_daerah.kod(+) and
    mohon.id_mohon = enkuiri.id_mohon and 
    lelong.id_pihak = pihak.id_pihak and
    lelong.id_mh = mohon_hakmilik.id_mh and
    pihak.kod_negeri = kod_negeri.kod(+) and
    mohon.id_mohon = mohon_fasa.id_mohon and
    mohon_fasa.id_aliran ='semakan' and
    mohon_fasa.id_pguna = pguna.id_pguna and
    mohon.id_mohon = :p_id_mohon
    and enkuiri.KOD_STS='AK'
    and mohon.id_mohon ='0405AUC2010007436'KOD_NEGERI_NAMA,ID_HAKMILIK,PENYERAH_NAMA,PENYERAH_ALAMAT1,PENYERAH_ALAMAT2,PENYERAH_ALAMAT3,PENYERAH_ALAMAT4,PENYERAH_POSKOD,PENYERAH_KOD_NEGERI,PENYERAH_NO_RUJ,ID_MOHON,KOD_HAKMILIK,NO_HAKMILIK,NAMA,NO_LOT,NAMA_1,NAMA_2,TMPT,DIMASUK,NAMA_3,ALAMAT1,VEN,ALAMAT2,ALAMAT3,ALAMAT4,POSKOD,ID_MOHON_1,PGUNA_NAMA,JAWATAN,KOD_DAERAH_NAMA,TRH_ENKUIRI,TRH_LE,DAY,HOUR,NOON,CARA_LELONG,TMPT_1,HARGA_RIZAB,HARGA_RIZAB_1,PIHAK_NAMA,ER,'RM'||ENKUIRI.TUNGGAK_AMAUN,DEPOSIT,CONVERTED_FORM,TRH_AKHIR_BYR,SYSD,KOD_BPM_NAMA,KOD_LOT_NAMA,NO_LOT_1,KOD_HAKMILIK_1,NO_HAKMILIK_1
    Johor,050503PM00000151,HAMZAH DAUD DAROS & SITI NOR,NO 12 1ST FLOOR & 2ND FLOOR,JLN SRI RAHANG,TMN SRI RAHANG,SEREMBAN,58000,05,12345,0405AUC2010007436,PM,151,Lot,6309,Mukim Lenggeng,Seremban,PTG MELAKA,pptlelong1,Puan Nur Faizati,ASDFSAF,AHMAD,DSFDS,FDSFSDF,DSFSDF,12345,0405AUC2010007436,Puan Nur Faizati,Penolong Pegawai Tanah Lelong (PTD),Seremban,08 DISEMBER 2010,27 JANUARI 2011,Thursday ,02:00 ,pagi,A,PTG MELAKA,,,Ahmad,,RM234,,,24 MEI 2011,10 FEBRUARI 2011,Mukim Lenggeng,Lot,6309,PM,151
    ,050540HSD00022923,HAMZAH DAUD DAROS & SITI NOR,NO 12 1ST FLOOR & 2ND FLOOR,JLN SRI RAHANG,TMN SRI RAHANG,SEREMBAN,58000,05,12345,0405AUC2010007436,HSD,22923,Lot,0009838,Mukim Jimah,Seremban,PTG MELAKA,pptlelong1,Puan Nur Faizati,no2,Ali Bin Abudillah,jalan 3,taman permata,lorong mentari,32333,0405AUC2010007436,Puan Nur Faizati,Penolong Pegawai Tanah Lelong (PTD),Seremban,08 DISEMBER 2010,27 JANUARI 2011,Thursday ,02:00 ,pagi,A,PTG MELAKA,,,Ali Bin Abudillah,,RM234,,,24 MEI 2011,10 FEBRUARI 2011,Mukim Jimah,Lot,0009838,HSD,22923
    KOD_NEGERI_NAMA,ID_HAKMILIK,PENYERAH_NAMA,PENYERAH_ALAMAT1,PENYERAH_ALAMAT2,PENYERAH_ALAMAT3,PENYERAH_ALAMAT4,PENYERAH_POSKOD,PENYERAH_KOD_NEGERI,PENYERAH_NO_RUJ,ID_MOHON,KOD_HAKMILIK,NO_HAKMILIK,NAMA,NO_LOT,NAMA_1,NAMA_2,TMPT,DIMASUK,NAMA_3,ALAMAT1,VEN,ALAMAT2,ALAMAT3,ALAMAT4,POSKOD,ID_MOHON_1,PGUNA_NAMA,JAWATAN,KOD_DAERAH_NAMA,TRH_ENKUIRI,TRH_LE,DAY,HOUR,NOON,CARA_LELONG,TMPT_1,HARGA_RIZAB,HARGA_RIZAB_1,PIHAK_NAMA,ER,'RM'||ENKUIRI.TUNGGAK_AMAUN,DEPOSIT,CONVERTED_FORM,TRH_AKHIR_BYR,SYSD,KOD_BPM_NAMA,KOD_LOT_NAMA,NO_LOT_1,KOD_HAKMILIK_1,NO_HAKMILIK_1
    Johor,050503PM00000151,HAMZAH DAUD DAROS & SITI NOR,NO 12 1ST FLOOR & 2ND FLOOR,JLN SRI RAHANG,TMN SRI RAHANG,SEREMBAN,58000,05,12345,0405AUC2010007436,PM and HSD,151 and 22923,Lot,6309,Mukim Lenggeng,Seremban,PTG MELAKA,pptlelong1,Puan Nur Faizati,ASDFSAF,AHMAD,DSFDS,FDSFSDF,DSFSDF,12345,0405AUC2010007436,Puan Nur Faizati,Penolong Pegawai Tanah Lelong (PTD),Seremban,08 DISEMBER 2010,27 JANUARI 2011,Thursday ,02:00 ,pagi,A,PTG MELAKA,,,Ahmad,,RM234,,,24 MEI 2011,10 FEBRUARI 2011,Mukim Lenggeng,Lot,6309,PM,151
    that means i need to list aggregate the two rows into one how to make the changes for the above query in order to do so .
    Edited by: user9093689 on Feb 9, 2011 10:03 PM

    user9093689 wrote:
    now need to bother abt this that line converts date into malay language
    to_char(enkuiri.TRH_enkuiri,'DD')||' '|| to_char(enkuiri.TRH_enkuiri,'MONTH','nls_date_language=malay') ||' '||TO_CHAR (enkuiri.TRH_enkuiri, 'YYYY') trh_enkuiri,iam retriving two rows of output, wat i need is to display one row and the second row values which are not similar should be added to the first row
    for example for column
    kod_hakmilik two rows values are
    PM
    HSD
    but they should be display as
    PM and HSD
    finally my aim is to retrieve only one row as output.
    i dont how exactly the term listaggr . how ever it may be whether using groupby or any other but the output should be as aboveWhat version of Oracle are you on?
    Look up the LISTAGG() function in the documentation for your version (assuming it is there) and see if it can do what you want

  • Deleting row in matrix.

    Hello.
    I have weird problem.
    If I add some rows to matrix, and then delete rows the method with:
    m_pMatrix->GetRowCount();
    return the number of rows without delete.
    For example:
    If i have matrix with 5 rows, and I delete 2 rows, method with GetRowCount show me 5
    What is wrong ?
    I solved this problem with adding new variable, but why does it work wrong ?
    Sorry for my english.
    Regards
    Kamil Wydra

    Hello.
    Thank You for Your response.
    I try that and it works.
    Thanks again.
    Regards
    Kamil Wydra

  • Self-coping row in matrix

    Hey All
    I hava problem with AddRow to Matrix because after add row to Matrix, added row is copy of previous
    I use this code:
    Matryca.AddRow(1, -1)
    Matryca.Columns.Item(1).Cells.Item(i + 1).Click SAPbouiCOM.BoCellClickType.ct_Regular)
    Thanks very much for answers
    regards
    Krzysztof Sala

    Thanks
    it run
    I use:
    i = pVal.Row()
    DBDS1.InsertRecord(i)
    Matryca.LoadFromDataSource()
    Matryca.Columns.Item(1).Cells.Item(i + 1).Click SAPbouiCOM.BoCellClickType.ct_Regular)
    regards
    Krzysztof Sala

Maybe you are looking for

  • Can multiple threads write to the database?

    I am a little confused from the statement in the documentation: "Berkeley DB Data Store does not support locking, and hence does not guarantee correct behavior if more than one thread of control is updating the database at a time." 1. Can multiple th

  • Why can't I send older RAW files from iPhoto to Adobe Camera RAW?

    I have a 20" Intel iMac (OS  X 10.5.8) and use iPhoto '09 (Version 8.1.2) for storing and organizing the digital images produced by my Nikon D200 and D700 cameras. When I wish to edit a photo I right click on the image and select Edit in External Edi

  • File save as pages

    Trying to File save as in pages, i dont want copy and I dont want template any help , very frustrating the new version of pages lost the file save as choice.

  • Transaction Context Is Lost in General Ledger

    Hi, I got 'Transaction Context is Lost' in General Ledger 'Accounting Setup Manager' while creating new Ledger, in R12. I tried restarting machine, but same problem. How to fix problem? See Attached SHT - http://www.mediafire.com/?fusvfp6q7cv6rdz

  • Show/Hide Multi State Object

    I can show a multistate object by having a blank state and then going to state 2, but how can I hide this?