Writing multiple rows in one line, mysql statement. No strings are saved

Hi, I dont know how to make multiple rows inputs into the table in one sentence. Ive got an error: "java.sql.SQLException: Statement parameter 2 not set" provided by code below. It works fine for one Date row (saves in the db corectly) however when I use for two different date types two single statements it will write databes two times putting 2x Null in the every other row. I dont want that, I need it to be written in one connection and statement.
try{
     String userName = "user";
          String password = "pass";
          String url = "jdbc:mysql://dbadress/dbname";
          Class.forName ("com.mysql.jdbc.Driver").newInstance();
          Connection con = DriverManager.getConnection (url, userName, password);
          Statement  st1=con.createStatement();
       Date BirthDate = wdContext.currentPeopleElement().getBirthDate();  //People - context node, BirthDate - context attribute
       Date FillDate = wdContext.currentContextElement().getFillDate();
       String sql1 = "INSERT INTO table1 (BirthDate1,FillDate1) VALUES (?,?)"; //BirthDate1,FillDate1 - rows in the "table1" table
       PreparedStatement stmt1 = con.prepareStatement(sql1);
       stmt1.setDate(1, BirthDate);
       stmt1.setDate(1, FillDate);
       stmt1.executeUpdate();
       stmt1.close();
     catch(Exception e) {
     wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
I would like to know how to fix it.
Other issue is that code below:
try{
     String userName = "user";
          String password = "pass";
          String url = "jdbc:mysql://dbadress/dbname";
          Class.forName ("com.mysql.jdbc.Driver").newInstance();
          Connection con = DriverManager.getConnection (url, userName, password);
          Statement  st1=con.createStatement();
       Date BirthDate = wdContext.currentPeopleElement().getBirthDate();  //People - context node, BirthDate - context attribute
       String sql1 = "INSERT INTO table1 (BirthDate1) VALUES (?)"; //BirthDate1 row in the "table1" table
       PreparedStatement stmt1 = con.prepareStatement(sql1);
       stmt1.setDate(1, BirthDate);
          stmt1.executeUpdate();
       stmt1.close();
     catch(Exception e) {
     wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
works perfectly fine. It does write date in the database as shown on the monitor hoever it doesnt work if we change Date type with String. Of course context nodes are String type as well. Code below will write "Null" value in the db. Dont know why. Of course I write some string down in the input field and save after, just like do it with Date type which works fine. Please advice.
try{
     String userName = "user";
          String password = "pass";
          String url = "jdbc:mysql://dbadress/dbname";
          Class.forName ("com.mysql.jdbc.Driver").newInstance();
          Connection con = DriverManager.getConnection (url, userName, password);
        Statement  st2=con.createStatement();
     String signature = wdContext.currentContextElement().getsignature(); //signature - context
     String sql2 = "INSERT INTO table1 (signature1) VALUES (?)"; //signature1 - name of row in the table1
     PreparedStatement stmt2 = con.prepareStatement(sql2);
     stmt2.setString(1, signature);
     stmt2.executeUpdate();
     stmt2.close();
     catch(Exception e) {
     wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
Regards, Blamer.

Hi,
Fix for your first issue
I dont know how to make multiple rows inputs into the table in one sentence. Ive got an error: "java.sql.SQLException: Statement parameter 2 not set" provided by code below. It works fine for one Date row (saves in the db corectly) however when I use for two different date types two single statements it will write databes two times putting 2x Null in the every other row. I dont want that, I need it to be written in one connection and statement.
try{
     String userName = "user";
          String password = "pass";
          String url = "jdbc:mysql://dbadress/dbname";
          Class.forName ("com.mysql.jdbc.Driver").newInstance();
          Connection con = DriverManager.getConnection (url, userName, password);
          Statement  st1=con.createStatement();
       Date BirthDate = wdContext.currentPeopleElement().getBirthDate();  //People - context node, BirthDate - context attribute
       Date FillDate = wdContext.currentContextElement().getFillDate();
       String sql1 = "INSERT INTO table1 (BirthDate1,FillDate1) VALUES (?,?)"; //BirthDate1,FillDate1 - rows in the "table1" table
       PreparedStatement stmt1 = con.prepareStatement(sql1);
       stmt1.setDate(1, BirthDate);
       stmt1.setDate(1, FillDate);
       stmt1.executeUpdate();
       stmt1.close();
     catch(Exception e) {
     wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
I would like to know how to fix it.
Change the line  stmt1.setDate(1, FillDate); to stmt1.setDate(2, FillDate);
As a workarond for your following issue
works perfectly fine. It does write date in the database as shown on the monitor hoever it doesnt work if we change Date type with String. Of course context nodes are String type as well. Code below will write "Null" value in the db. Dont know why. Of course I write some string down in the input field and save after, just like do it with Date type which works fine. Please advice.
try{
     String userName = "user";
          String password = "pass";
          String url = "jdbc:mysql://dbadress/dbname";
          Class.forName ("com.mysql.jdbc.Driver").newInstance();
          Connection con = DriverManager.getConnection (url, userName, password);
        Statement  st2=con.createStatement();
     String signature = wdContext.currentContextElement().getsignature(); //signature - context
     String sql2 = "INSERT INTO table1 (signature1) VALUES (?)"; //signature1 - name of row in the table1
     PreparedStatement stmt2 = con.prepareStatement(sql2);
     stmt2.setString(1, signature);
     stmt2.executeUpdate();
     stmt2.close();
     catch(Exception e) {
     wdComponentAPI.getMessageManager() .reportWarning( e.toString() ); }
Try as follows
PreparedStatement stmt2 = con.prepareStatement(sql2);
     stmt2.setString(1, (signature == null ? "Value missing" : signature));
     stmt2.executeUpdate();
     stmt2.close();
If the context attribute is null it will enter the text "Value Missing",
Regards
Ayyapparaj

Similar Messages

  • Writing all the rows in one line but cannot write more than 32767 character

    Dear All,
    i am trying to write the column of a table to a file with the '||' seperators. i want to write all the rows in one line of the file.
    for E.g
    Column1 Column2
    A B
    C D
    in the file the output needs to be gone like
    A||B||C||D
    but after 32767 character it gives a write error. could please someone let me know what is wrong with my function below or how can i write more than 32767 character in one one.
    CREATE OR REPLACE FUNCTION CORP_IB_DUMP_FILE (
    P_QUERY IN VARCHAR2,
    P_SEPARATOR IN VARCHAR2 DEFAULT '',
    P_DIR IN VARCHAR2,
    P_FILENAME IN VARCHAR2
    RETURN NUMBER AUTHID CURRENT_USER
    IS
    L_OUTPUT UTL_FILE.FILE_TYPE;
    L_THECURSOR INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
    L_THECURSOR2 INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
    L_COLUMNVALUE VARCHAR2 (4000);
    L_STATUS INTEGER;
    L_COLCNT NUMBER DEFAULT 0;
    L_SEPARATOR VARCHAR2 (10) DEFAULT '';
    L_CNT NUMBER DEFAULT 0;
    BEGIN
    L_OUTPUT := UTL_FILE.FOPEN (P_DIR, P_FILENAME, 'w', 32767);
    DBMS_SQL.PARSE (L_THECURSOR, P_QUERY, DBMS_SQL.NATIVE);
    FOR I IN 1 .. 255
    LOOP
    BEGIN
    DBMS_SQL.DEFINE_COLUMN (L_THECURSOR, I, L_COLUMNVALUE, 4000);
    L_COLCNT := I;
    EXCEPTION
    WHEN OTHERS
    THEN
    IF (SQLCODE = -1007)
    THEN
    EXIT;
    ELSE
    RAISE;
    END IF;
    END;
    END LOOP;
    DBMS_SQL.DEFINE_COLUMN (L_THECURSOR, 1, L_COLUMNVALUE, 4000);
    L_STATUS := DBMS_SQL.EXECUTE (L_THECURSOR);
    LOOP
    EXIT WHEN (DBMS_SQL.FETCH_ROWS (L_THECURSOR) <= 0);
    L_SEPARATOR := '';
    FOR I IN 1 .. L_COLCNT
    LOOP
    DBMS_SQL.COLUMN_VALUE (L_THECURSOR, I, L_COLUMNVALUE);
    UTL_FILE.PUT (L_OUTPUT, L_SEPARATOR || L_COLUMNVALUE);
    L_SEPARATOR := P_SEPARATOR;
    UTL_FILE.FFLUSH (L_OUTPUT);
    END LOOP;
    UTL_FILE.FFLUSH (L_OUTPUT);
    L_CNT := L_CNT + 1;
    END LOOP;
    DBMS_SQL.CLOSE_CURSOR (L_THECURSOR);
    UTL_FILE.FCLOSE (L_OUTPUT);
    RETURN L_CNT;
    END CORP_IB_DUMP_FILE;
    /

    user577300 wrote:
    Dear All,
    i am trying to write the column of a table to a file with the '||' seperators. i want to write all the rows in one line of the file.
    for E.g
    Column1 Column2
    A B
    C D
    in the file the output needs to be gone like
    A||B||C||D
    but after 32767 character it gives a write error. could please someone let me know what is wrong with my function below or how can i write more than 32767 character in one one.
    CREATE OR REPLACE FUNCTION CORP_IB_DUMP_FILE (
    P_QUERY IN VARCHAR2,
    P_SEPARATOR IN VARCHAR2 DEFAULT '',
    P_DIR IN VARCHAR2,
    P_FILENAME IN VARCHAR2
    RETURN NUMBER AUTHID CURRENT_USER
    IS
    L_OUTPUT UTL_FILE.FILE_TYPE;
    L_THECURSOR INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
    L_THECURSOR2 INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
    L_COLUMNVALUE VARCHAR2 (4000);
    L_STATUS INTEGER;
    L_COLCNT NUMBER DEFAULT 0;
    L_SEPARATOR VARCHAR2 (10) DEFAULT '';
    L_CNT NUMBER DEFAULT 0;
    BEGIN
    L_OUTPUT := UTL_FILE.FOPEN (P_DIR, P_FILENAME, 'w', 32767);
    DBMS_SQL.PARSE (L_THECURSOR, P_QUERY, DBMS_SQL.NATIVE);
    FOR I IN 1 .. 255
    LOOP
    BEGIN
    DBMS_SQL.DEFINE_COLUMN (L_THECURSOR, I, L_COLUMNVALUE, 4000);
    L_COLCNT := I;
    EXCEPTION
    WHEN OTHERS
    THEN
    IF (SQLCODE = -1007)
    THEN
    EXIT;
    ELSE
    RAISE;
    END IF;
    END;
    END LOOP;
    DBMS_SQL.DEFINE_COLUMN (L_THECURSOR, 1, L_COLUMNVALUE, 4000);
    L_STATUS := DBMS_SQL.EXECUTE (L_THECURSOR);
    LOOP
    EXIT WHEN (DBMS_SQL.FETCH_ROWS (L_THECURSOR) <= 0);
    L_SEPARATOR := '';
    FOR I IN 1 .. L_COLCNT
    LOOP
    DBMS_SQL.COLUMN_VALUE (L_THECURSOR, I, L_COLUMNVALUE);
    UTL_FILE.PUT (L_OUTPUT, L_SEPARATOR || L_COLUMNVALUE);
    L_SEPARATOR := P_SEPARATOR;
    UTL_FILE.FFLUSH (L_OUTPUT);
    END LOOP;
    UTL_FILE.FFLUSH (L_OUTPUT);
    L_CNT := L_CNT + 1;
    END LOOP;
    DBMS_SQL.CLOSE_CURSOR (L_THECURSOR);
    UTL_FILE.FCLOSE (L_OUTPUT);
    RETURN L_CNT;
    END CORP_IB_DUMP_FILE;
    /Check your logic very carefully. You are using UTL_FILE.PUT() which should not automatically put end-of-line characters i n your file but you are reassigning l_seperator with p_seprator after the first time.
    What value are you pasising in as p_seperator?
    UTL_FILE.PUT() should allow you to write a string of bytes without newlines as long as its arguments are less than 32K, and you can control when the newlines get written. If your arguments are > 32K can you split them up without writing the newlines until you need to do so? Try something like (untested)
    --         UTL_FILE.PUT (L_OUTPUT, L_SEPARATOR || L_COLUMNVALUE);
               UTL_FILE.PUT (L_OUTPUT, substr(L_SEPARATOR || L_COLUMNVALUE,1,32767));
               UTL_FILE.PUT (L_OUTPUT, substr(L_SEPARATOR || L_COLUMNVALUE),32767*2-1,32767));Edited by: riedelme on Sep 10, 2012 6:11 AM

  • Inserting multiple rows using a single Insert statement without using dual

    Hi all,
    i am trying to insert multiple rows using a single insert statement like the below one.
    The below one works fine..
    But is there any other change that can be done in the below one without using dual...
    insert all
    into ps_hd_samp (num1,num2) values (1,1)
    into ps_hd_samp (num1,num2) values (2,2)
    into ps_hd_samp (num1,num2) values (3,3)
    select 1 from dual;

    NiranjanSe wrote:
    Hi all,
    i am trying to insert multiple rows using a single insert statement like the below one.
    The below one works fine..
    But is there any other change that can be done in the below one without using dual...
    insert all
    into ps_hd_samp (num1,num2) values (1,1)
    into ps_hd_samp (num1,num2) values (2,2)
    into ps_hd_samp (num1,num2) values (3,3)
    select 1 from dual;
    SQL> create table ps_hd_samp (num1 number,num2 number);
    Table created.
    SQL> insert all
      2  into ps_hd_samp (num1,num2) values (1,1)
      3  into ps_hd_samp (num1,num2) values (2,2)
      4  into ps_hd_samp (num1,num2) values (3,3)
      5  select count(*)
      6  from ps_hd_samp;
    3 rows created.
    SQL> select * from ps_hd_samp;
          NUM1       NUM2
             1          1
             2          2
             3          3

  • Select or deselect multiple rows with one single selection  event

    Does anyone know how to create a JTable which can select or deselect multiple rows with one single selection event in JTable. Fore example, if the table has
    row1
    row2
    row3
    row4
    row5
    row6
    What I need is when user select row1 or row2, both row1 and row2 should be set to be selected. Then if user press CTRL and click one of row3 or row4, both of them should be selected including the previouse selected row1 and row2.
    For deselection, if row1 and row2 are selected, when users deselect one of row1 or row2, both of them should be deselected.
    Hopefully someone can give me a hint.

    Here is a partial solution using a JList. Only one line gets highlighted when the user makes a selection in the list. But, two lines are returned. There is a blank line between every two lines.
         private void addLineToList() {
              String a = f_one.getText();
              String b = f_two.getText();
              if (a.length() == 0) {
                   Utils.showInformationMessage("Item field is empty.");
                   f_one.requestFocusInWindow();
                   return;
              if (b.length() == 0) {
                   Utils.showInformationMessage("Match field is empty.");
                   f_two.requestFocusInWindow();
                   return;
              model.addElement("item: " + a);
              model.addElement("match: " + b);
              model.addElement(" ");
              int size = model.getSize();
              pairList.setSelectedIndex(size - 3);
              f_one.setText("");
              f_two.setText("");
              f_one.requestFocusInWindow();
         private void editList() {
              if (pairList.getSelectedValue().toString().equalsIgnoreCase(" ")) {
                   Toolkit.getDefaultToolkit().beep();
                   f_one.requestFocusInWindow();
                   return;
              if (!f_one.getText().equals("")) {
                   int result = JOptionPane.showConfirmDialog(this,
                   "The Item field contains text. Replace the text?",
                   "Flash Card Activity", JOptionPane.YES_NO_OPTION,
                   OptionPane.INFORMATION_MESSAGE);
                   if (result == JOptionPane.NO_OPTION) return;
              if (!f_two.getText().equals("")) {
                   int result = JOptionPane.showConfirmDialog(this,
                   "The Match field contains text. Replace the text?",
                   "Flash Card Activity", JOptionPane.YES_NO_OPTION,
                   JOptionPane.INFORMATION_MESSAGE);
                   if (result == JOptionPane.NO_OPTION) return;
              String item = "";
              String match = "";
              int index = pairList.getSelectedIndex();
              String choice = model.getElementAt(index).toString();
              if (choice.startsWith("item")) {
                   item = choice;
                   match = model.getElementAt(index + 1).toString();
                   model.remove(index);
                   model.remove(index);
                   model.remove(index);
              else {
                   item = model.getElementAt(index - 1).toString();
                   match = choice;
                   model.remove(index + 1);
                   model.remove(index);
                   model.remove(index - 1);
              int size = model.getSize();
              if (size > 2) {
                   pairList.setSelectedIndex(size - 2);
              f_one.setText(item.substring(6));
              f_two.setText(match.substring(7));
              f_one.requestFocusInWindow();
         }

  • Passing Multiple rows from one external webpart list to another

    Hi Folks,
                    I have almost spent 1 week looking into this without any success. I have an external list "List A"  (in a webpart) with one of the columns as "State".
    Another external list "List B"  (in a webpart ) has state and user as columns. In some case I want to pass 1 state and in another I want to pass multiple state.  Passing one state from List A to List B works fine. But Multiple state does
    not work because the webpart list has the property "Send First row to connected web parts when page loads".  If I disable this option then the web part does not pass anything. Is there a way to pass multiple rows from one Webpart
    external list to other?

    http://www.sharepointanalysthq.com/2010/07/bcs-external-list-limitations/
    No Lookups
    Unfortunatly the only thing that you can do a look up on in an external list is on the ID column, anything else and you are out of luck.
    http://social.technet.microsoft.com/Forums/en-US/615771a0-ba78-4e38-9e2d-ded0204173ba/external-list-referenced-as-sharepoint-lookup?forum=sharepointgeneralprevious
    Try below webpart. it should help
    http://www.sparqube.com/SharePoint-Lookup-Column/
    If this helped you resolve your issue, please mark it Answered

  • I wanted to display the multiple rows in one row but column should be diff

    Hi
    Could any body help me regarding this query how to write to get the multiple rows in one row.
    eg.
    i have one table tab1(eno number,ename varchar2,uid1 varchar2,uid2 varchar2,uid3 varchar4)
    but when i am runing the query I am getting multiple record against one eno number because of uid1,uid2,uid3
    suppose value of table is
    eno ename uid1 uid2 uid3
    1 a u1
    1 a u2
    1 a u3
    when i am quering it is coming same as above but I want in one row
    eno ename uid1 uid2 uid3
    1 a u1 u2 u3
    can any onle help me how to write the query for this requirement.
    thanks
    saif

    which is hard coded in my code? Here another approach, but fail for c as there is no information for the value of a column: does 1 in u1 means col 1, etc.
    /* Formatted on 2012/05/29 16:29 (Formatter Plus v4.8.8) */
    WITH t AS
         (SELECT 1 col1, 'a' col2, 'u1' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'a' col2, 'u2' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'a' col2, 'u3' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'b' col2, 'u1' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'b' col2, 'u3' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'b' col2, 'u2' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'c' col2, 'u1' col3
            FROM DUAL
          UNION ALL
          SELECT 1 col1, 'c' col2, 'u3' col3
            FROM DUAL)
    SELECT   xx.col1, xx.col2, MAX (DECODE (xx.rn, 1, col3)) AS uid1, MAX (DECODE (xx.rn, 2, col3)) AS uid2,
             MAX (DECODE (xx.rn, 3, col3)) AS uid3
        FROM (SELECT t.col1, t.col2, t.col3, ROW_NUMBER () OVER (PARTITION BY col1, col2 ORDER BY col3) rn
                FROM t) xx
    GROUP BY col1, col2;output:
    COL1     COL2     UID1     UID2     UID3
    1     a     u1     u2     u3
    1     b     u1     u2     u3
    1     c     u1     u3
    Edited by: ʃʃp on May 29, 2012 2:30 AM

  • Generating multiple rows from one physical row

    I was wondering if anyone has done or knows how to generate multiple rows for one physical row. In my query "SELECT Cust_No, Amount from Balances" if the amount is > 99,999.99 I want 2 rows returned, one with an amount of 90,000.00 and the other with an amount of 9,999.99. I'm thinking I need to use a view or function to return a result set but I'm not sure how.
    Thanks in advance,
    Allen Davis
    [email protected]

    James,
    Well your right in that you need a function, but also 3 views to accomplish that. I just wrote up the sql below and tested it. Basically you want the first view to return all records less than your cap of 99,999, thoes that exceed that will always return as 90,000 (see example on record PK 774177177). The second view returns money that remains AFTER the cap (in your case 9,999). The second view though also has to excude the ones less than the CAP.
    DATA and TABLE layout
    1) Table is called T1, columns are PK : primary key value, and N2 : some number column holding the MONEY amount
    2) data is below fromtable called t1 (10 records) ...
    select pk,n2 from t1 order by pk
    PK     N2
    117165529     100
    274000876     200000
    350682010     9999
    737652242     90000
    774177177     99999
    1369893126     1000
    1663704428     100000
    1720465556     8888
    1793125955     0
    1972069382     1000000
    Now see the records with money at 99,999 (just like in your example). You want 2 records, so the VIEWS now come into play. The view itself CALLS the function, this occurs when you select from the view. The function will either return 90,000 (your defined cap) or the remained after subtracting the money from 90,000. The 3 views are defined below (the FUNCTION which is shown after will have to be compiled first) ...
    --[VIEWS START]
    CREATE OR REPLACE VIEW VIEW1
    (PK,SHOW_MONEY)
    AS SELECT PK,FN_TRIM_MONEY(N2,1) FROM T1;
    CREATE OR REPLACE VIEW VIEW2
    (PK,SHOW_MONEY)
    AS SELECT PK,FN_TRIM_MONEY(N2,2) FROM T1 WHERE N2 >= 99999;
    CREATE OR REPLACE VIEW VIEW_ALL
    (PK,SHOW_MONEY)
    AS
    SELECT * FROM VIEW1
    UNION ALL
    SELECT * FROM VIEW2;
    --[VIEWS END]
    OK now for the actual function ...
    --[FUNCTION START]
    CREATE OR REPLACE FUNCTION
    FN_TRIM_MONEY
    PI_MONEY NUMBER,
    PI_VIEW_ID NUMBER
    RETURN NUMBER AS
    LS_TEMP VARCHAR2(2000);
    LI_TEMP NUMBER;
    LD_TEMP DATE;
    LI_CON_MONEY_MAX CONSTANT NUMBER := 90000;
    LS_RETURN VARCHAR2(2000);
    BEGIN
    IF (PI_MONEY > LI_CON_MONEY_MAX) THEN
    IF PI_VIEW_ID = 1 THEN
    LI_TEMP := LI_CON_MONEY_MAX;
    ELSIF PI_VIEW_ID = 2 THEN
    LI_TEMP := (PI_MONEY - LI_CON_MONEY_MAX);
    END IF;
    ELSE
    LI_TEMP := PI_MONEY;
    END IF;
    IF LI_TEMP < 0 THEN
    LI_TEMP := 0;
    END IF;
    LS_RETURN := LI_TEMP;
    RETURN LS_RETURN;
    END;
    SHOW ERRORS;
    --[FUNCTION END]
    I compiled the function and views with no errors. This is what I get when I query the 3 views ...
    --[VIEW 1]
    PK     SHOW_MONEY
    117165529     100
    274000876     90000
    350682010     9999
    737652242     90000
    774177177     90000
    1369893126     1000
    1663704428     90000
    1720465556     8888
    1793125955     0
    1972069382     90000
    --[VIEW 2]
    PK     SHOW_MONEY
    274000876     110000
    774177177     9999
    1663704428     10000
    1972069382     910000
    --[VIEW ALL]
    PK     SHOW_MONEY
    117165529     100
    274000876     90000
    274000876     110000
    350682010     9999
    737652242     90000
    774177177     90000
    774177177     9999
    1369893126     1000
    1663704428     90000
    1663704428     10000
    1720465556     8888
    1793125955     0
    1972069382     90000
    1972069382     910000
    So notice the PK entry 774177177 listed twice, once with 90,000 and other with 9,999. Also notice we now have 14 records from the original 10, meaning 4 records qualified for the split (all data from VIEW 2).
    This is why Oracle kicks ass, views and functions are very powerful when used together and can return pretty much anything.
    Thanks,
    Tyler D.
    [email protected]

  • Collecting data from multiple rows into one column

    I'd like to run a query and put a collection of items into one output column instead of multiple rows. See the example below:
    Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Prod
    PL/SQL Release 10.2.0.5.0 - Production
    "CORE     10.2.0.5.0     Production"
    TNS for 32-bit Windows: Version 10.2.0.5.0 - Production
    NLSRTL Version 10.2.0.5.0 - Production
         CREATE TABLE "SKIP"."INGREDIENTS"
       (     "INGRED_ID" NUMBER,
         "INGRED_NAME" VARCHAR2(20 BYTE),
         "STORES" VARCHAR2(20 BYTE)
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS" ;
    REM INSERTING into SKIP.INGREDIENTS
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (1,'SEA SALT','Food lion');
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (2,'TABLE SALT','Food lion');
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (3,'FLOUR','Piggly Wiggly');
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (4,'YEAST',null);
    Insert into SKIP.INGREDIENTS (INGRED_ID,INGRED_NAME,STORES) values (5,'BEER','ABC Store');
      CREATE TABLE "SKIP"."PRETZELS"
       (     "PRETZEL_ID" NUMBER,
         "PRETZEL_NAME" VARCHAR2(20 BYTE),
         "PRETZEL_DESC" VARCHAR2(100 BYTE)
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS" ;
    REM INSERTING into SKIP.PRETZELS
    Insert into SKIP.PRETZELS (PRETZEL_ID,PRETZEL_NAME,PRETZEL_DESC) values (1,'CLASSIC','Classic knot pretzel');
    Insert into SKIP.PRETZELS (PRETZEL_ID,PRETZEL_NAME,PRETZEL_DESC) values (2,'THICK STICK','Straight pretzel, abt 1/2" in dia');
      CREATE TABLE "SKIP"."INGRED_XREF"
       (     "PRETZEL_ID" NUMBER,
         "INGRED_ID" NUMBER
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "USERS" ;
    REM INSERTING into SKIP.INGRED_XREF
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (1,1);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (1,2);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (1,4);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (2,2);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (2,3);
    Insert into SKIP.INGRED_XREF (PRETZEL_ID,INGRED_ID) values (2,5);
    --  Constraints for Table INGRED_XREF
      ALTER TABLE "SKIP"."INGRED_XREF" MODIFY ("PRETZEL_ID" NOT NULL ENABLE);
      ALTER TABLE "SKIP"."INGRED_XREF" MODIFY ("INGRED_ID" NOT NULL ENABLE);
    {code}
    Desired output (note how the ingredients are all listed in one column, separated by commas):
    {code}
    PRETZEL_ID PRETZEL_NAME     PRETZEL_DESC                        INGREDIENTS
    1          CLASSIC          Classic knot pretzel                SEA SALT, TABLE SALT, YEAST
    2          THICK STICK      Straight pretzel, abt 1/2" in dia   TABLE_SALT, FLOUR, BEER

    See the FAQ : {message:id=9360005}
    Especially links concerning string aggregation.

  • How to get multiple rows at one time in a table?

    hi
    I have a JTable bound with ViewObject and i use multiple selection mode setting to get selection row.
    My question is when i select more then one row at one time i only can get those index from JTable but can't get those rows from ViewObject.is it possible to get rows from ViewObject? or how to use JTable row index to get row from ViewObject?

    repost

  • Bash script question, how do I create multiple directories on one line

    I am making a package for amavisd-new (yes I am aware that there is one in community but I can't say I like the way it is done).
    I have an install script from which I want to create multiple directories if they do not exist.
    So I want to create a directory /var/spool/amavis with subdirectories of var tmp virusmails spammassassin .
    I can't seem to be able to find a way to do this on one line.

    pelle.k wrote:
    peets wrote:Hehe because it's less typing!
    Good one!
    Also, it's by far the more dynamic method.
    If you want to get pedantic, it's also far less efficient in terms of execution time: each iteration of the loop forks a new process, whereas using a single mkdir command forks only once.  The "best" way is the curly-braces method demonstrated above by chimeric.

  • How to update multiple rows in one query using php

    i am new to this can any one help me how to update multiple rows at a time i am doing an school attendance page

    Often the situation is such that you have multiple courses across a range of dates.So students may take more than one course, and you need to track attendance for each course date. The following graphic demonstrates this:
    In such a situation, you need four database tables as follows:
    students (student_id, student_name, etc.)
    courses (course_id, course_name, etc.)
    students_courses (student_id, course_id)
    attendance (student_id, course_id, dater)
    A fifth table may also be needed to define the dates of courses, but you may also be able to build this array programmatically by using PHP's robust date functions, which can give you, for instance, all the Tuesdays and Thursdays between a start date and end date.
    The students_courses table simply keeps track of which students are taking which courses, so it has just two columns for the primary keys of both of the main tables. The attendance table is similar, but it also includes a date field. The following view of the attendance table demonstrates this:
    So if David's solution does cover your needs, consider yourself lucky, because this could quickly grow from a beginner-appropriate project to a moderately advanced one.

  • How do I input multiple numbers to go to multiple variables in one line?

    I was wondering what I had to do to input 5 variables on one line. I have the program running fine, but I'm stuck at the part where it says "The numbers will be input five per line, on four lines".. Aside from poor grammar, it doesn't make any sense to me. Here's the whole question:
    Write code that will fill the array twoDArray(declared in the line of code below) with numbers typed in at the keyboard. The numbers will be input five per line, on four lines. Use the following array declaration:I don't need any immediate help with the array itself, just the input (unless the input is directly related to the array). Just in case, I'm going to post my code. This is still very messy, because I'm not done, and it's might be somewhat sloppy as I'm new to 2d arrays (in java).
    Thanks for the help.
    import java.io.*;
    class darrays
    public static void main(String[] args) throws IOException
    InputStreamReader inStream = new InputStreamReader (System.in);
    BufferedReader stdin = new BufferedReader(inStream);
    int[][] twoDArray = new int[4][5];
    int x,y;
    String input;
    for (x = 0; x <= 3; x++)
         for (y = 0; y<=4; y++)
    input = stdin.readLine ();
    twoDArray[x][y] = Integer.parseInt (input);
    for (x = 0; x <= 3; x++)
         for (y = 0; y<=4; y++)
    System.out.print(twoDArray[x][y] + " ");
    System.out.println("");
    }     

    Slightly off-topic
    When I was learning Basic (good old Kemeny & Kurtz style, when Basic was simply a simplified Fortran, not Bill Gates style) you simply have to write
    READ A, B, C, D, E
    DATA 10, 20, 30, 40, 50
    or something like
    INPUT "A", A: INPUT "B", B etc.
    In Java you are required to handle the mysteries of StringTokenizer...
    Java 1.5 is promising to make it easier:
          Scanner sc = Scanner.create(new File("myNumbers"));
          while (sc.hasNextLong()) {
              long aLong = sc.nextLong();
          }where you get the longs (decimal formatted, separated with blanks) from a text file.
    But not so easy as the good old INPUT statement.
    Even C's scanf is not so easy, because has lots of subtleties
    (when you finally mastered the esoteric art of using char* as strings, you are really fed up of char* strings, because they usually blow up due to buffer overflows or mere programmer errors, and start to use Java instead, even having to master the StringTokenizer and other classes.).

  • How to insert multiple rows in a single insert statement in MaxDB?

    hi,
    I was looking at syntax but i could not get it right.. may be some could help me.
    // Insert single row works fine
    INSET INTO test_table(column_name) values (value1) IGNORE DUPLICATES
    // Insert multiple rows, doesn't
    INSET INTO test_table(column_name) values (value1), (value2), (value3) IGNORE DUPLICATES
    Can somebody help me with this.
    thanks,
    sudhir.

    Multiple inserts do only work with parametrized statements, usually used in interfaces like JDBC, ODBC etc.
    With static SQL statements it is not possible.
    Regards Thomas

  • Passing multiple rows from one action to another

    Hi,
    I've build a Guided Procedure Process with two actions. Both actions call a Visual Composer Model (deployed as Flex).
    The Processdesign is:
    Process
    ---Block
    Action 1
    CO 1 as VC Model (Flex)
    Action 2
    CO 2 as VC Model (Flex)
    From the first vc model I want to pass multiple rows (its a vc table) to the second vc model. Therefor I've group the out-going parameters from model 1 with the in-coming parameters from model 2 at the block-level.
    Now, when I start my process I have two results in the table of  vc model 1 and will pass them to model 2. But only one record (always the first) is shown at model 2.
    Can you say me the reason for this? Have I configured the parameter-grouping false? Or isn't it possible to pass multiple rows at guided procedures?
    I'm using Visual Composer 7.0 and Guided Procedures 7.0 technology.
    Thanks in advance
    Claudia

    hi,
    Do structure mapping to pass row values
    Thanks
    Gopal

  • How to trigger Condition Access sequence multiple times for one line item?

    Hi,
    We have a situation that, User will enter a Promo code (custom Field) in Sales order Header Additional data B tab to apply discount for line items.
    Logic goes like this:
    1. For each Promo code .. there may be multiple sale deals (Max 3 at this point).
    2. For each line item (refering to tkomp table) we have to apply the sale deals (found above) the Condition access sequence will pick the right sale deal to apply the line item.
    3.we have enhanced the tkomp structure to hold the sale deal.
    Challenge:
    As we have the standard logic to trigger the condition access sequence once for each line item, how we can apply 3 sale deals for single line item. Is there any logic or way to trigger the condition access sequence multiple times for single line item with diffrent sale deals. ~ There may be one valid sale deal for one line.
    Functional team maintained diffrent access tables in the access sequence!!!
    Fnds, please help me to get some clue
    Thanks,
    Sunil Y

    Hi Eduardo , Thanks for the response.
    I am trying to explain again, this is the requirment given by the functional guys.
    we have Promo code in Hearder Addtional data B tab --> Have to retrieve Sale Deals -->
    At this point of time we may have at max 3 Sale Deals. we don't know which sale deal is vallied for which item we have in TKOMP.  We have enhanced the TKOMP structure to hold one sale deal only (ZZPROMO).
    We have enhanced USEREXIT_PRICING_PREPARE_TKOMP in RV60AFZZ to populate the value in TKOMP. Then it will go for diffrent access sequence to find the proper condition.
    Our challenge is that, for each line item we have 3 sale deals, we don't know which one is valid for which line. but we have to apply the vallied sale Deal to the line items.  Line item 10  may have Sale Deal 2 , item 20 may have Sale Deal3 and 30 may have sale deal 1.
    We may have solution, by fixing some thing in the code or through config. But i am confused that is it a valid requirment?
    Please help me ...
    Thanks,
    Sunil Y

Maybe you are looking for