Need a help in PL/SQL array

Hi below is my requirement
I need to generate value AA to ZZ. I know we can do with this in squencer, But I want this in Array such that if the value passed is AD the return should be AE.. if value sent is AZ then it should return BA
Inner loop handles A to Z and Outer loop ahndles A-Z.. So if we pass AR the inner loop wijj go till R when it finds matching R then it should pick next value i.e S
and write AS.
Please help me in doing this with Array function in PL/SQL
Thanks in advance
Edited by: shrivatsa on Apr 28, 2009 2:40 PM

Not sure why you need a plsql array for this. With above provided sql you could do it also like this:
SQL> var code varchar2(3)
SQL> exec :code := 'FFF'
PL/SQL procedure successfully completed.
SQL> with table1 as (
select '1FFFAA' str from dual union all
select '2FFFAB' from dual union all
select '3CCCAR' from dual union all
select '4CCCAS' from dual union all
select '5RRRAY' from dual union all
select '6RRRAZ' from dual
h as
select a||b ab, lead(a||b) over (order by a,b) next
   from (select chr(64+level) a from dual connect by level <= 26),
        (select chr(64+level) b from dual connect by level <= 26)
select max(:code || next) next
  from table1, h
where substr(str,-5,3) = :code
   and substr(str,-2,2) = ab
NEXT                             
FFFAC                            
1 row selected.
SQL> exec :code := 'RRR'
PL/SQL procedure successfully completed.
SQL> with table1 as (
select '1FFFAA' str from dual union all
select '2FFFAB' from dual union all
select '3CCCAR' from dual union all
select '4CCCAS' from dual union all
select '5RRRAY' from dual union all
select '6RRRAZ' from dual
h as
select a||b ab, lead(a||b) over (order by a,b) next
   from (select chr(64+level) a from dual connect by level <= 26),
        (select chr(64+level) b from dual connect by level <= 26)
select max(:code || next) next
  from table1, h
where substr(str,-5,3) = :code
   and substr(str,-2,2) = ab
NEXT                             
RRRBA                            
1 row selected.

Similar Messages

  • Help with pl sql arrays

    Hi,
    pretty new to Oracle and am not a programmer by profession.
    Am trying to write a stored procedue that will create statements to
    insert across a gateway, and have some of the insert statements
    contain trims, depending on the column type.
    so I am looping through one record at a time from dba_tab_columns.
    Basically the below.
    FOR tab in (
    SELECT table_name,column_name,data_type
    FROM dba_tab_columns where owner='MY_OWNER'
    LOOP
    END LOOP;
    END;
    But, what I really need to do is to loop all of the columns found for
    each table into an array, so that at the end of the loop for each
    table, one line is printed out something like this:
    insert into my_table ( col1,col2 ... col_last) select col1,col2 ..
    col_last from table@gateway_link.
    The problem is in how to use the arrays to get each loop iteration to
    be stored, and all printed out in one line at the end of each loop
    iteration.
    I hope I'm explaining this clearly enough. It sounds pretty simple,
    but I am not able to figure it out.
    Thanks for any help.
    fwellers.

    I don't understand how you know which table is going to select from which remote table, but that's your problem
    as a code-snippet, I'll give you the following idea:
    SQL> get t7
      1  declare
      2    type tab_typ is table of varchar2(30);
      3    l_tables        tab_typ;
      4    l_columns       tab_typ;
      5    l_str            varchar2(4000);
      6    cursor l_tab_cur is select table_name from all_tables where owner = 'SCOTT' and table_name in ('EMP', 'DEPT');
      7    -- if you want to fill the table names, you could use str2tbl(tab_param)
      8    cursor l_col_cur (p_tab_name varchar2) is
      9      select column_name from all_tab_columns where owner = 'SCOTT' and table_name = p_tab_name;
    10  begin
    11    -- either set tables by hand;
    12    l_tables := tab_typ('EMP', 'DEPT');
    13    -- or fill it by a cursor
    14    open l_tab_cur;
    15    fetch l_tab_cur bulk collect into l_tables;
    16    close l_tab_cur;
    17    -- process the column of the tables
    18    for i in 1..l_tables.count loop
    19      dbms_output.put_line('processing table ' || l_tables(i));
    20      open l_col_cur(l_tables(i));
    21      fetch l_col_cur bulk collect into l_columns;
    22      close l_col_cur;
    23      l_str := 'insert into my_table' || i || ' (';
    24      for j in 1..l_columns.count loop
    25        l_str := l_str || l_columns(j) || ', ';
    26      end loop;
    27      l_str := substr(l_str, 1, length(l_str) -2) || ')';
    28      dbms_output.put_line(l_str);
    29      l_str := 'select ';
    30      for j in 1..l_columns.count loop
    31        l_str := l_str || l_columns(j) || ', ';
    32      end loop;
    33      l_str := substr(l_str, 1, length(l_str) -2) || ' from ' || l_tables(i) || '@remote_db;';
    34      dbms_output.put_line(l_str);
    35    end loop;
    36* end;
    SQL> /
    processing table EMP
    insert into my_table1 (EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO)
    select EMPNO, ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO from EMP@remote_db;
    processing table DEPT
    insert into my_table2 (DEPTNO, DNAME, LOC)
    select DEPTNO, DNAME, LOC from DEPT@remote_db;
    PL/SQL procedure successfully completed.
    SQL>

  • Help with PL/SQL arrays or Types

    Hi,
    I have a SQL query that returns the ID and the DESCRIPTION. I would like to loop through Ref Cursor and store these values into multi-array or something. What is the best way to achieve this? I appreciate your help.
    ID DESCRIPTION
    1 test1
    2 test2
    3 test3
    Thanks..

    You could use SELECT ... BULK COLLECT INTO arrayname, although for any serious volumes or concurrency it will take some redesign to avoid grabbing all the server's memory resources. Also I expect Billy will be along in a minute to tell you your approach is all wrong.
    Why do you need an array?

  • Need some help with multi dimensional arrays plz

    Hello,
    Lets say I have a three-dim array, call it pyList. This array goes from pyList[0][0][0] to pyList[5][5][5] (216 values). Now, I also have a two-dim array, call it V, which goes from V[0][0] to V[35][5]. What I would like to do is assign V[0][0] the value in pyList[0][0][0], V[0][1] to pyList[0][0][1], and so on up to V[0][5] = pyList[0][0][5]. Then I want V[1][0] = pyList[0][1][0]...
    I want this to go on until V[35][5] = pyList[5][5][5]. Basically Im splitting up pyList into chunks of 6 consecutive values and making each row in V equal to those 6 values.
    Is this possible to do? I cant seem to figure out the proper way to set up the for loops so that my indices are correct.
    If anything is unclear please let me know.
    Any help is greatly appreciated.
    Thank you
    -Big_Goon

    Do you need to create new arrays? That is, should the array V[0] be a different object than pyList[0][0]?
    Since "multidimensional arrays" are simply arrays of arrays it is possible to write V[0] = pyList[0][0] and then every V[0][x] is the same as pyList[0][0][x]. But if you change either of them the change will show in both arrays.
    Otherwise, you will need a loop:for (int y = 0; y < 36; y++)
        System.arraycopy(pyList[y / 6][y % 6], 0, V[y], 0, 6);Or maybe it's more maintanable with two:for (int y = 0; y < 6; y++)
    for (int x = 0; x < 6; x++)
        System.arraycopy(pyList[y][x], 0, V[6*y + x], 0, 6);

  • Need a help in pl/sql cursors

    Hi,
    wrong posted...if i have any clarifications i can mail to all.
    thanks...

    This is how formatted code looks like.
    I have removed superflous BEGIN .. END (Which lead to code that would not compile)
    This is your code, not mine
    DECLARE
      CURSOR stagingtablerecords IS
        SELECT *
        FROM   mdat_lseveh_options;
      r      mdat_lseveh_options%ROWTYPE;
      svar   NUMBER;
    BEGIN
      FOR r IN stagingtablerecords LOOP
        IF r.heading_sw = 'Y' THEN
          INSERT INTO pref_accessory_category (acc_cat_id,
                                               acc_cat_desc,
                                               last_modified,
                                               model_cd,
                                               model_yr,
                                               interior,
                                               ext_accessory
          VALUES      (refcatidseq.NEXTVAL,
                       r.std_equip_txt,
                       SYSDATE,
                       r.model_cd,
                       r.model_year,
                       NULL,
                       NULL
          svar := acc_cat_id; -- Problem here
        ELSIF r.heading_sw = 'N' THEN
          INSERT INTO pref_accessory (acc_id,
                                      acc_desc,
                                      acc_cat_id,
                                      model_cd,
                                      model_yr,
                                      last_modified
          VALUES      (refaccidseql.NEXTVAL,
                       r.std_equip_txt,
                       svar,
                       r.model_cd,
                       r.model_year,
                       SYSDATE
        END IF;
      END LOOP;
      COMMIT;
    END;
    /You have a problem with your staging table, since there is no information on which accessories belongs to which categories.
    You seem to rely on some sort of order, but this order do not exist, unless expressed explicitly.
    If data comes from a file and is sorted in there, then you could add a line number, or a sequential number or such as you load them into stage table.
    This number should be used when reading from stage table to ensure lines are processed like
    Y1
    N1
    N1
    N1
    Y2
    N2
    N2
    Right now, you have no control over the stage table
    Edit:
    I would try with something like, (Not tested, or anything else - And never tried this with sequences, suspect it may not work)
    INSERT ALL
    WHEN heading_sw = 'Y' THEN
      INTO   pref_accessory_category (acc_cat_id,
                                      acc_cat_desc,
                                      last_modified,
                                      model_cd,
                                      model_yr,
                                      interior,
                                      ext_accessory
      VALUES (refcatidseq.NEXTVAL,
              std_equip_txt,
              SYSDATE,
              model_cd,
              model_year,
              NULL,
              NULL
    WHEN heading_sw = 'N' THEN
      INTO   pref_accessory (acc_id,
                             acc_desc,
                             acc_cat_id,
                             model_cd,
                             model_yr,
                             last_modified
      VALUES (refaccidseql.NEXTVAL,
              r.std_equip_txt,
              refcatidseq.CURRVAL,
              r.model_cd,
              r.model_year,
              SYSDATE
      SELECT   std_equip_txt,
               model_cd,
               model_year
      FROM     stagingtablerecords
      ORDER BY your_new_column;Regards
    Peter

  • How to create oracle.sql.array

    I need to create an oracle.sql.array to pass in my custom objects array to the database. I know you can create it using the ArrayDescriptor class but the problem with that is the connection object is need.
    I am using the writeSql() method of the SQLData interface. I therefore dont have the connection object. Any ideas?

    haha
    you misunderstand. i have in my code:
    <code>
         // update the organisation
         public boolean setOrganisation(Organisation pOrg) {
              Organisation org = pOrg;
              OracleCallableStatement callStat = null;
              Connection conn = null;
              boolean OK = false;
              try {
                   conn = getConnection(getUserName());
                   pOrg.setConnection(conn);
                   callStat = (OracleCallableStatement) conn.prepareCall("{call p_cmt.update_organisation(?)}");
                   callStat.setObject(1, org);
                   callStat.execute();
                   OK = true;
              } catch (Exception e) {
                   logger.severe("error writing organisation with id " + org.getId() + ". " + e);
              } finally {
                   cleanUpConnections(conn, callStat);
              return OK;
    </code>
    This writes the object organisation to the database. Now in the class organisation i have the following method which is called automatically when writing the organisation object to the database:
    <code>
         public void writeSQL(SQLOutput p_stream) throws SQLException {
              p_stream.writeInt(id);
              p_stream.writeObject(country);
         if (finIndexArr == null)
              finIndexArr = new ListElement[0];
         ArrayDescriptor af = ArrayDescriptor.createDescriptor(
         ObjectMapper.elementList, conn);
         ARRAY arr = new ARRAY(af, conn, finIndexArr);          
              p_stream.writeArray(arr);
    </code>
    The problem is the last bit. To put the finIndexArr into an array i need the connection object. So i have to pass into the organisation object the connection object which seems unneccessary and pointless to me. I was just looking at an alternative way of creating the array without the need of the connection object. Since the setOrganisation() above has the connection to the database i dont see why i need to specify it in the array as well

  • Help: APEX - PL/SQL Function

    Hello,
    i need some help with a SQL statement.
    I have the follwing Table "TABF":
    ID Number,
    B_Number varchar2(10),
    G_Type varchar2(10),
    Site varchar2(50),
    Event varchar2(50),
    Date varchar(10),
    Dataset varchar2(50),
    Mode varchar2(50),
    Topic varchar2(10),
    Parameter varchar2(10),
    Value varchar2(10)The table is filled with records which, like this:
    B Number | G-Type |Site       |Event  |Date     | Dataset   | Mode    | Topic    | Parameter | Value
    800257   |   4.2  |  USA      | Test  |18.08.08 | Pre       |MBA      | Field    | F_C       | 73,9015 
    800257   |   4.2  |  USA      | Test  |03.04.96 | BL        |MBA      | Field    | F_C       | 73,6951 
    800257   |   4.2  |  USA      | Test  |03.04.96 | BL        |MBA      | Field    | F_C       | 73,71 
    800257   |   4.2  |  USA      | Test  |18.08.08 | Post      |MBA      | Field    | F_C       | 73,7526 
    800257   |   4.2  |  USA      | Test  |18.08.08 | Pre       |MBA      | Field    | F_C       | 4,5170 
    800257   |   4.2  |  USA      | Test  |03.04.96 | BL        |MBA      | Field    | F_H       | 24,6074 
    800257   |   4.2  |  England  | Test  |03.04.96 | BL        |MBA      | Field    | F_H       | 24,62 
    800257   |   4.2  |  England  | Test  |18.08.08 | Post      |MBA      | Field    | F_H       | 24,4717  Now im looking for a SELECT statement or better a function that returns a SELECT under the following condition:
    If B_Number and Event and Date and Dataset are equal, then add 3 additional columns (Topic2, Paramter2, Value2) at the first aquivalent entry.
    Then the row can be delete/ignored. If there will be another record where B_Number,Event, Date are equal to a row above then Topic3, Paramter3 and Value 3 should be added as a new column at the first record where the conditions equals.
    And so on.....
    The result should look like this for the example above:
    B Number | G-Type |  Site     |Event  |Date     | Dataset   | Mode    | Topic    |Parameter   | Value    | Topic2   |  Parameter2  | Value2
    800257   |    4.2 |  USA      | Test  |18.08.08 | Pre       | MBA     | Field    | F_C        | 73,9015  | -        | -            | -
    800257   |    4.2 |  USA      | Test  |03.04.96 | BL        | MBA     | Field    | F_C        | 73,6951  | Field    | F_H          | 24,6074
    800257   |    4.2 |  USA      | Test  |03.04.96 | BL        | MBA     | Field    | F_C        | 73,71    | Field    | F_H          | 24,62 
    800257   |    4.2 |  USA      | Test  |18.08.08 | Post      | MBA     | Field    | F_C        | 73,7526  | -        | -            | -
    800257   |    4.2 |  USA      | Test  |18.08.08 | Pre       | MBA     | Field    | F_C        | 4,5170   | -        | -            | -
    800257   |    4.2 |  England  | Test  |18.08.08 | Post      | MBA     | Field    | F_H        | 24,4717  | -        | -            | -Hope you understand my problem and some1 can help me.
    Thank you
    Regards
    Chris
    Edited by: user11369135 on 09.07.2009 00:50

    user11369135 wrote:
    Hello,
    i need some help with a SQL statement.
    I have the follwing Table "TABF":
    Now im looking for a SELECT statement or better a function that returns a SELECT under the following condition:
    If B_Number and Event and Date and Dataset are equal, then add 3 additional columns (Topic2, Paramter2, Value2) at the first aquivalent entry.
    Then the row can be delete/ignored. If there will be another record where B_Number,Event, Date are equal to a row above then Topic3, Paramter3 and Value 3 should be added as a new column at the first record where the conditions equals.
    And so on.....
    Edited by: user11369135 on 09.07.2009 00:50if I understand correctly then you want a simple GROUP BY on B_number, Event, Date and Dataset.
    But you want additionaly show 3 columns from one of the rows that was grouped.
    This can be done using the little known KEEP syntax.
    Documentation: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions056.htm#sthref1389
    Example from the docs
    Aggregate Example
    The following example returns, within each department of the sample table hr.employees, the minimum salary among the employees who make the lowest commission and the maximum salary among the employees who make the highest commission:
    SELECT department_id,
    MIN(salary) KEEP (DENSE_RANK FIRST ORDER BY commission_pct) "Worst",
    MAX(salary) KEEP (DENSE_RANK LAST ORDER BY commission_pct) "Best"
       FROM employees
       GROUP BY department_id;
    DEPARTMENT_ID      Worst       Best
               10       4400       4400
               20       6000      13000
               30       2500      11000
               40       6500       6500
               50       2100       8200
               60       4200       9000
               70      10000      10000
               80       6100      14000
               90      17000      24000
              100       6900      12000
              110       8300      12000
                        7000       7000

  • Help in designing SQL

    Hi All,
    I need little help in designing SQL. My input and output data is given below:
    Input
    Key
    Date_1
    Date_2
    Key1
    2/14/2011 5:22:35 PM
    2/22/2011 3:05:13 PM
    Key1
    2/24/2011 1:48:07 PM
    5/24/2011 4:50:16 PM
    Key1
    2/24/2011 1:48:59 PM
    4/25/2011 3:36:19 PM
    Key1
    5/24/2011 5:18:19 PM
    6/16/2011 3:17:40 PM
    Key1
    6/16/2011 3:25:42 PM
    6/24/2011 1:33:13 PM
    Key1
    6/17/2011 1:12:54 PM
    6/25/2011 5:55:55 PM
    Output
    Key
    Date_1
    Date_2
    Key1
    2/14/2011 5:22:35 PM
    2/22/2011 3:05:13 PM
    Key1
    2/24/2011 1:48:07 PM
    5/24/2011 4:50:16 PM
    Key1
    5/24/2011 5:18:19 PM
    6/16/2011 3:17:40 PM
    Key1
    6/16/2011 3:25:42 PM
    6/25/2011 5:55:55 PM
    Here out of 2nd and third record of input, output is 2nd record of output and 5th and 6th record of input would come out as  4th record of output. Basically, if we overlapping duration between Date_1 and Date_2, we need to take min of Date_1 and max of Date_2 for that overlapping records. In case of no overlapping, we would simply output input record like  record 1 and 4 of input.
    Out of
    Key1
    2/24/2011 1:48:07 PM
    5/24/2011 4:50:16 PM
    Key1
    2/24/2011 1:48:59 PM
    4/25/2011 3:36:19 PM
    2/24/2011 1:48:07 PM was  min of above 2 and 5/24/20114:50:16 was max of above 2.
    Similarly in other overlapping scenario:
    Key1
    6/16/2011 3:25:42 PM
    6/24/2011 1:33:13 PM
    Key1
    6/17/2011 1:12:54 PM
    6/25/2011 5:55:55 PM
    6/16/2011 3:25:42 PM  was min of above 2 and 6/25/2011 5:55:55 PM was max of above 2.
    Pls help.
    Thanks.

    Hi Frank.,
    The above logic with NVL is not working.
    My input sample is:
    Key
    Date_1
    Date_2
    Key1
    2/14/2011 5:22:35 PM
    2/22/2011 3:05:13 PM
    Key1
    2/24/2011 1:48:07 PM
    5/24/2011 4:50:16 PM
    Key1
    2/24/2011 1:48:59 PM
    Key1
    5/24/2011 5:18:19 PM
    6/16/2011 3:17:40 PM
    Key1
    6/16/2011 3:25:42 PM
    6/24/2011 1:33:13 PM
    Key1
    6/17/2011 1:12:54 PM
    6/25/2011 5:55:55 PM
    I am giving create and insert statement below for creation of above data. Please see if you can help me:
    CREATE TABLE test1
      KEY1          NUMBER     ,   
      DATE_1               DATE ,          
      date_2              DATE
    insert into test1
    values(1, TO_TIMESTAMP ('2/14/2011 5:22:35 PM', 'MM/DD/YYYY HH:MI:SS AM'),TO_TIMESTAMP ('2/22/2011 3:05:13 PM', 'MM/DD/YYYY HH:MI:SS AM')  ) ;
    values(1, TO_TIMESTAMP ('2/24/2011 1:48:07 PM', 'MM/DD/YYYY HH:MI:SS AM'),TO_TIMESTAMP ('5/24/2011 4:50:16 PM', 'MM/DD/YYYY HH:MI:SS AM')  ) ;
    values(1, TO_TIMESTAMP ('2/24/2011 1:48:59 PM', 'MM/DD/YYYY HH:MI:SS AM'), '' ) ;
    values(1, TO_TIMESTAMP ('5/24/2011 5:18:19 PM', 'MM/DD/YYYY HH:MI:SS AM'),TO_TIMESTAMP ('6/16/2011 3:17:40 PM', 'MM/DD/YYYY HH:MI:SS AM')  ) ;
    values(1, TO_TIMESTAMP ('6/16/2011 3:25:42 PM', 'MM/DD/YYYY HH:MI:SS AM'),TO_TIMESTAMP ('6/24/2011 1:33:13 PM', 'MM/DD/YYYY HH:MI:SS AM')  ) ;
    values(1, TO_TIMESTAMP ('6/17/2011 1:12:54 PM', 'MM/DD/YYYY HH:MI:SS AM'),TO_TIMESTAMP ('6/25/2011 5:55:55 PM', 'MM/DD/YYYY HH:MI:SS AM')  ) ;
    commit;
    Expected output would be:
    Output
    Key
    Date_1
    Date_2
    Key1
    2/14/2011 5:22:35 PM
    2/22/2011 3:05:13 PM
    Key1
    2/24/2011 1:48:07 PM
    Key1
    5/24/2011 5:18:19 PM
    6/16/2011 3:17:40 PM
    Key1
    6/16/2011 3:25:42 PM
    6/25/2011 5:55:55 PM
    Thanks....

  • Need a help in SQL query

    Hi,
    I need a help in writing an SQL query . I am actually confused how to write a query. Below is the scenario.
    CREATE TABLE demand_tmp
    ( item_id  NUMBER,
      org_id   NUMBER,
      order_line_id NUMBER,
      quantity NUMBER,
      order_type NUMBER
    CREATE TABLE order_tmp
    ( item_id  NUMBER,
       org_id   NUMBER,
       order_line_id NUMBER,
       open_flag  VARCHAR2(10)
    INSERT INTO demand_tmp
    SELECT 12438,82,821,100,30 FROM dual;
    INSERT INTO demand_tmp
    SELECT 12438,82,849,350,30 FROM dual;
    INSERT INTO demand_tmp
    SELECT 12438,82,NULL,150,29 FROM dual;
    INSERT INTO demand_tmp
    SELECT 12438,82,0,50,-1 FROM dual;
    INSERT INTO order_tmp
    SELECT 12438,82,821,'Y' FROM dual;
    INSERT INTO order_tmp
    SELECT 12438,82,849,'N' FROM dual;
    Demand_tmp:
    Item_id        org_id   order_line_id       quantity       order_type     
    12438     82                 821                 100       30     
    12438     82                 849                 350       30     
    12438     82              NULL                 150       29     
    12438     82                    0                  50       -1     
    Order_tmp :
    Item_id        org_id        order_line_id      open_flag     
    12438     82                  821                Y     
    12438     82                  849                N     I need to fetch the records from demand_tmp table whose order_line_id is present in order_tmp and having open_flag as 'Y' or if order_type in demand_tmp table is 29.
    The below query will give the records whose order line id is present in order_tmp. But, If i need records which are having order_type=29 the below query wont return any records as order_line_id is NULL. If I place outer join I will get other records also (In this example order_type -1 records) . Please help me how can we write a query for this. Expected o/p is below.
    Query :
    Select item_id,org_id,order_line_id,quantity,order_type,open_flag
    from demand_tmp dt , order_tmp ot
    where dt.order_line_id = ot.order_line_id
    AND dt.item_id=ot.item_id
    AND dt.org_id = ot.org_id
    AND ot.open_flag = 'Y';
    Expected Output :                         
    item_id     org_id     order_line_id     quantity     order_type   open_flag
    12438     82                 821               100                    30             Y
    12438     82              NULL               150                29         NULL Thanks in advance,
    Rakesh
    Edited by: Venkat Rakesh on Oct 7, 2012 6:32 PM
    Edited by: Venkat Rakesh on Oct 7, 2012 8:39 PM

    Hi Rakesh,
    the query is not working as you would like ( but IS working as expected ) since your trying to compare null to another value.
    Comparing null always results in FALSE, also if you compare null to null. This is because null means undefined.
    select 1 from dual where null=null results in no data found.
    I would suggest using a non natural key to join the tables.
    For example include a column ID in the master table which is filled with a sequence and include that field as a foreign key in the detail table.
    This way you can easily join master and detail on ID = ID, and you don't have to worry about null values in this column since it's always filled with data.
    Regards,
    Bas
    btw, using the INNER JOIN and OUTER JOIN syntax in your SQL makes it better readable, since you're separating join conditions from the where clause, just a tip ;)

  • Need help: Form6i PL/SQL library not found!

    New oracle user need your help:
    I installed Form6i and PO8i on NT, and config the tnsnames.ora file, they both worked fine to connect. But when I try to look into the PL/SQL library, it said PL/SQL library can not found. I deleted the classpath because with it I can't run Java, and the Sun help menu told me I can delete classpath to let it use current directory, is this the reason that Oracle can't find the library?
    One more question: when I connect to database from Form, Username, Password, then Databasename, for this last one, if I leave it blank, it will connect to the database, but if I type in my database name(the default DB name), it will again give me error message, said TNS can't resolve service. Does anybody have a clue? Thank you so much!

    The answer for on more question:
    It's not db name but service name.
    A sample in tnsname.ora:
    DKORCL[the service name].world =
    (DESCRIPTION =
    (ADDRESS_LIST =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dlt_db_srv[host_name])(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = dkorcl[oracle service name])
    You say,"u can leave it blank ",then u must work at the server.And the name u type in is not correct.
    May this help u!
    null

  • Need help to convert SQL MSSQL statement to work with PL in ORACLE

    Hi All,
    I have the trigger below and it worked on MSSQL server for windown and
    I really need your help to convert this trigger to work on PL/ORACLE:
    create trigger deleteLD
         on tablea for delete
    as
    set nocount on
    begin
         declare @tablename varchar(100)
         declare @dropSql varchar(50)
         select @tablename= dataset from deleted
         set @tablename = 'LD_' + @tablename
         set @tablename = @tablename + 'UTMSTATS'
         if exists (select * from sysobjects where name = @tablename)
         begin
              set @tablename = 'drop table ' + @tablename
              EXEC (@tablename)
         end
    end
    GO
    Your help is greatly appreciated.
    Thanks,
    JP

    not sure if this is something that you want:
    Create Or Replace Trigger deleteLD
      Before Delete on tablea
    Declare
      vCtr          number := 0;
    Begin
    select count(*)
       into vCtr
       from all_tables
      where table_name = :new.tablename;
    if vCtr > 0 then
       dbms_utility.exec_ddl_statement('drop table '||:new.table_name);
    end if;
    End;note: not tested

  • Need help on my SQL statement

    Hello experts,
    I need to write a dynamic sql statement which will enable users to pick the date and the BI system will take them 3 months back. I tried 3 months variables I kept getting SQL error then I tried 90 days. Now it keep showing that there is no data which for sure I know its not trure.
    This is my statement: +"GL Calendar"."Fiscal Date" >=timestampadd(SQL_TSI_DAY,-90, timestamp'@{ABCcost}{2013-05-16 00:00:00}')AND("GL Calendar"."Fiscal Date">=timestamp'@{ABCcost}{2013-05-16 00:00:00}')+
    Anything that Im missing..

    Rayan,
    I am not sure if I am following you, cause we want to enable the user to pick whatever date and then from there they will get 3 months back and the rest of their info. I tried it didn't work, may be I placed at wrong place
    Can you probably copy my statement above and insert in-between.
    thanks,
    Edited by: 994621 on May 17, 2013 11:28 AM

  • Problem Encountering in oracle.sql.ARRAY type

    Hi,
    i am using one stored procedure to get a set of records.
    i am getting it by mapping those things with java.sql.Array. And after that i am getting the values as ResultSet from that Array. The same thing is working fine in Windows platform. If i posted those thing into Unix - AIX, i am facing an ArrayIndexOutofBoundsException while getting ResultSet from oracle.sql.ARRAY class. I checked out ARRAY instance.it is not null. Both Application and Database are same except O.S.
    Can Anybody help me. I need it imm.
    Thanks in Advance
    Regards
    Eswaramoorthy.G

    Hi
    Did you ever figure out what the problem was with this? We have a client that is experiencing the same problem on AIX but we cannot reproduce using their database running under NT nor Sun. Any information would be appreciated. You can respond directly to [email protected]
    Thanks in adavance
    Rick DeMilia
    Sungard DataSystems

  • Deadlock in Oracle.sql.ARRAY type

    Hi,
    We've come across the deadlock situation below when running multiple J2EE MDB instances that are trying to write to the DB:
    [deadlocked thread] [ACTIVE] ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)':
    Thread '[ACTIVE] ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)'' is waiting to acquire lock 'oracle.jdbc.driver.T4CConnection@90106ee' that is held by thread '[ACTIVE] ExecuteThread: '8' for queue: 'weblogic.kernel.Default (self-tuning)''
    Stack trace:
    oracle.sql.ARRAY.toBytes(ARRAY.java:673)
    oracle.jdbc.driver.OraclePreparedStatement.setArrayCritical(OraclePreparedStatement.java:5985)
    oracle.jdbc.driver.OraclePreparedStatement.setARRAYInternal(OraclePreparedStatement.java:5944)
    oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:8782)
    oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:8278)
    oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:8868)
    oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:240)
    weblogic.jdbc.wrapper.PreparedStatement.setObject(PreparedStatement.java:287)
    org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:356)
    org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:216)
    org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:127)
    org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl.setValues(PreparedStatementCreatorFactory.java:298)
    org.springframework.jdbc.object.BatchSqlUpdate$1.setValues(BatchSqlUpdate.java:192)
    org.springframework.jdbc.core.JdbcTemplate$4.doInPreparedStatement(JdbcTemplate.java:892)
    org.springframework.jdbc.core.JdbcTemplate$4.doInPreparedStatement(JdbcTemplate.java:1)
    org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:586)
    org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:614)
    org.springframework.jdbc.core.JdbcTemplate.batchUpdate(JdbcTemplate.java:883)
    org.springframework.jdbc.object.BatchSqlUpdate.flush(BatchSqlUpdate.java:184)
    com.csfb.fao.rds.rfi.common.dao.storedprocs.SaveEarlyExceptionBatchStoredProc.execute(SaveEarlyExceptionBatchStoredProc.java:93)
    com.csfb.fao.rds.rfi.common.dao.EarlyExceptionDAOImpl.saveEarlyExceptionBatch(EarlyExceptionDAOImpl.java:34)
    com.csfb.fao.rds.rfi.application.rulesengine.RulesEngine.saveEarlyExceptions(RulesEngine.java:302)
    com.csfb.fao.rds.rfi.application.rulesengine.RulesEngine.executeRules(RulesEngine.java:209)
    com.csfb.fao.rds.rfi.application.rulesengine.RulesEngine.onMessage(RulesEngine.java:97)
    com.csfb.fao.rds.feeds.process.BaseWorkerMDB.onMessage(BaseWorkerMDB.java:518)
    weblogic.ejb.container.internal.MDListener.execute(MDListener.java:466)
    weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
    weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:327)
    weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4547)
    weblogic.jms.client.JMSSession.execute(JMSSession.java:4233)
    weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3709)
    weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
    weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5058)
    weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
    weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    [deadlocked thread] [ACTIVE] ExecuteThread: '8' for queue: 'weblogic.kernel.Default (self-tuning)':
    Thread '[ACTIVE] ExecuteThread: '8' for queue: 'weblogic.kernel.Default (self-tuning)'' is waiting to acquire lock 'oracle.jdbc.driver.T4CConnection@b48b568' that is held by thread '[ACTIVE] ExecuteThread: '7' for queue: 'weblogic.kernel.Default (self-tuning)''
    Stack trace:
    oracle.sql.ARRAY.toBytes(ARRAY.java:673)
    oracle.jdbc.driver.OraclePreparedStatement.setArrayCritical(OraclePreparedStatement.java:5985)
    oracle.jdbc.driver.OraclePreparedStatement.setARRAYInternal(OraclePreparedStatement.java:5944)
    oracle.jdbc.driver.OraclePreparedStatement.setObjectCritical(OraclePreparedStatement.java:8782)
    oracle.jdbc.driver.OraclePreparedStatement.setObjectInternal(OraclePreparedStatement.java:8278)
    oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.java:8868)
    oracle.jdbc.driver.OraclePreparedStatementWrapper.setObject(OraclePreparedStatementWrapper.java:240)
    weblogic.jdbc.wrapper.PreparedStatement.setObject(PreparedStatement.java:287)
    org.springframework.jdbc.core.StatementCreatorUtils.setValue(StatementCreatorUtils.java:356)
    org.springframework.jdbc.core.StatementCreatorUtils.setParameterValueInternal(StatementCreatorUtils.java:216)
    org.springframework.jdbc.core.StatementCreatorUtils.setParameterValue(StatementCreatorUtils.java:127)
    org.springframework.jdbc.core.PreparedStatementCreatorFactory$PreparedStatementCreatorImpl.setValues(PreparedStatementCreatorFactory.java:298)
    org.springframework.jdbc.object.BatchSqlUpdate$1.setValues(BatchSqlUpdate.java:192)
    org.springframework.jdbc.core.JdbcTemplate$4.doInPreparedStatement(JdbcTemplate.java:892)
    org.springframework.jdbc.core.JdbcTemplate$4.doInPreparedStatement(JdbcTemplate.java:1)
    org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:586)
    org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:614)
    org.springframework.jdbc.core.JdbcTemplate.batchUpdate(JdbcTemplate.java:883)
    org.springframework.jdbc.object.BatchSqlUpdate.flush(BatchSqlUpdate.java:184)
    com.csfb.fao.rds.rfi.common.dao.storedprocs.SaveEarlyExceptionBatchStoredProc.execute(SaveEarlyExceptionBatchStoredProc.java:93)
    com.csfb.fao.rds.rfi.common.dao.EarlyExceptionDAOImpl.saveEarlyExceptionBatch(EarlyExceptionDAOImpl.java:34)
    com.csfb.fao.rds.rfi.application.rulesengine.RulesEngine.saveEarlyExceptions(RulesEngine.java:302)
    com.csfb.fao.rds.rfi.application.rulesengine.RulesEngine.executeRules(RulesEngine.java:209)
    com.csfb.fao.rds.rfi.application.rulesengine.RulesEngine.onMessage(RulesEngine.java:97)
    com.csfb.fao.rds.feeds.process.BaseWorkerMDB.onMessage(BaseWorkerMDB.java:518)
    weblogic.ejb.container.internal.MDListener.execute(MDListener.java:466)
    weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
    weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:327)
    weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4547)
    weblogic.jms.client.JMSSession.execute(JMSSession.java:4233)
    weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3709)
    weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
    weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5058)
    weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
    weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
    weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Looking at the ARRAY.toBytes() method:
    public byte[] toBytes()
    throws SQLException
    synchronized (getInternalConnection())
    return this.descriptor.toBytes(this, this.enableBuffering);
    ..., it synchronizes on the following method (getInternalConnection() -> getPhysicalConnection()):
    oracle.jdbc.internal.OracleConnection getPhysicalConnection()
    if (this.physicalConnection == null)
    try
    this.physicalConnection = ((oracle.jdbc.internal.OracleConnection)new OracleDriver().defaultConnection());
    catch (SQLException localSQLException)
    return this.physicalConnection;
    defaultConnection() does the following:
    public Connection defaultConnection()
    throws SQLException
    if ((defaultConn == null) || (defaultConn.isClosed()))
    synchronized (OracleDriver.class)
    if ((defaultConn == null) || (defaultConn.isClosed()))
    defaultConn = connect("jdbc:oracle:kprb:", new Properties());
    return defaultConn;
    So there's synchronizations on the connection instance and OracleDriver.class object... I can't see how this can deadlock. To get to the point of needing the lock on OracleDriver.class, the thread would already have the lock on the connection instance.... clearly I'm missing something.
    Thanks
    Edited by: 928154 on 17-Apr-2012 03:42

    Welcome to the forum. If you want help, at least try to think where to post a question and look for a forum that matches the topic. Lets examine what you have:
    - its Weblogic, so if you would ask a non-programming related question anywhere it would be in the Weblogic forum
    - HOWEVER, if you check the top of the stacktrace, you'll see that the problem stems from the JDBC driver, so a JDBC related forum would be a closer match
    For future reference, Weblogic specific questions should go here: https://forums.oracle.com/forums/category.jspa?categoryID=193
    and JDBC/OJDBC driver related questions should go here: Java Database Connectivity (JDBC)
    Final tip: use \ tags to post code so it is readable.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Java.sql.SQLException: Internal Error while using oracle.sql.ARRAY.getArray

    Hello All,
    Here is the issue description. Our application uses Oracle Object Types and LIST. We deployed our application on QA environment which has Oracle 10g. Application runs fine...no issues. Now we moved to UAT. UAT environment is same as QA environment and DBA have created replica of QA database.
    Now WAR file which works fine with QA database , somehow doesnt work with UAT database. Application throws following exception when code tries to call getArray() on java.sql.Array.
    We tried to point UAT weblogic to QA database and it worked fine.....but when we point UAT weblogic to UAT database , we get following exception. So we know that this is a database issue.
    DBA claims that QA env database and UAT env database are same.
    Can anybody please tell me what wrong here? What setting is not done on UAT database which is done on QA?
    java.sql.SQLException: Internal Error at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:125) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:162) at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:227) at oracle.jdbc.oracore.OracleTypeCOLLECTION.initCollElemTypeName(OracleTypeCOLLECTION.java:975) at oracle.jdbc.oracore.OracleTypeCOLLECTION.getAttributeType(OracleTypeCOLLECTION.java:1005) at oracle.jdbc.oracore.OracleNamedType.getFullName(OracleNamedType.java:96) at oracle.jdbc.oracore.OracleTypeADT.createStructDescriptor(OracleTypeADT.java:1958) at oracle.jdbc.oracore.OracleTypeADT.unpickle81(OracleTypeADT.java:1432) at oracle.jdbc.oracore.OracleTypeUPT.unpickle81UPT(OracleTypeUPT.java:426) at oracle.jdbc.oracore.OracleTypeUPT.unpickle81rec(OracleTypeUPT.java:383) at oracle.jdbc.oracore.OracleTypeCOLLECTION.unpickle81_imgBody_elems(OracleTypeCOLLECTION.java:928) at oracle.jdbc.oracore.OracleTypeCOLLECTION.unpickle81_imgBody(OracleTypeCOLLECTION.java:872) at oracle.jdbc.oracore.OracleTypeCOLLECTION.unpickle81(OracleTypeCOLLECTION.java:692) at oracle.jdbc.oracore.OracleTypeCOLLECTION._unlinearize(OracleTypeCOLLECTION.java:217) at oracle.jdbc.oracore.OracleTypeCOLLECTION.unlinearize(OracleTypeCOLLECTION.java:189) at oracle.sql.ArrayDescriptor.toJavaArray(ArrayDescriptor.java:663) at oracle.sql.ARRAY.getArray(ARRAY.java:282) at weblogic.jdbc.wrapper.Array_oracle_sql_ARRAY.getArray(Unknown Source)
    Please help.

    425260 wrote:
    This can happen if you use the oracle.sql.ARRAY class with WebLogic.
    WebLogic wraps oracle.sql.ARRAY with its own class (i.e. weblogic.jdbc.wrapper.Array_oracle_sql_ARRAY). The easiest solution is to replace oracle.sql.ARRAY with the JDBC standard java.sql.Array.
    <PRE class=jive-pre><CODE class="jive-code jive-java">Object[] items = (Object[])array.getArray();
    <FONT color=navy><B>if</B></FONT> (items.length &gt; 0) <FONT color=navy>{</FONT>
    <FONT color=navy><B>for</B></FONT> (<FONT color=navy><B>int</B></FONT> i = 0; i &lt; items.length; i++) <FONT color=navy>{</FONT>
    Object arrayItem = items;
    <FONT color=navy>}</FONT>
    <FONT color=navy>}</FONT>
    </CODE></PRE>
    The <B>array</B> object is a java.sql.Array. Here no unwrapping of the WebLogic wrapper is needed.
    If you absolutely need the oracle.sql.ARRAY class than you must use an <B>unwrap</B> API on the WebLogic wrapper class.
    <PRE class=jive-pre><CODE class="jive-code jive-java"><FONT color=navy><B>if</B></FONT> (object <FONT color=navy><B>instanceof</B></FONT> weblogic.jdbc.wrapper.Array)
    array = (ARRAY) ( ((weblogic.jdbc.wrapper.Array)object).unwrap(Class.forName(<FONT color=red>"oracle.sql.ARRAY"</FONT>)) );
    <FONT color=navy><B>else</B></FONT>
    array = (ARRAY) object;
    </CODE></PRE>
    Here, <B>array</B> is an oracle.sql.ARRAY. Try to see if this <A class=bodylinkwhite href="http://www.software-to-convert.com/3gp-conversion-software/3gp-to-myspace-video-software.html"><FONT face=tahoma,verdana,sans-serif color=#000 size=1>helps</FONT></A>. Good luck.
    Thanks for your explanation! It's very valuable, It is exactly what I need, I understand this part.

Maybe you are looking for

  • OS 9.2.2 system folder not recognised in tiger

    Hi, I'm a bit lost here. I'm trying to get Classic to run in OS X 10.4.11. which has no previous copy of OS9 on it. The OS X was a clean install. I installed a copy of OS9.1 onto a USB dongle and then managed to boot the G3 through this and install O

  • Premiere Pro CC's sequence lost. Is there a way to "search" for it from outside the project?

    I seem to have lost a sequence created in Premiere Pro CC. I can't find it anywhere inside the Project bin. We have so many same-name, older projects (between Auto-Save, different drives and so on) that looking inside each of them would take forever.

  • Help with buttons on flash!

    i'm currently building an interactive flash website with videos. i have a menu page (frame 1) with small videos and buttons on each of those videos, which take you to a larger version of that video. however, all of my buttons seem to be attached to e

  • Generating an idoc on deletion of shipping doc

    Hi I want to generate an idoc when we delete the shipping doc from VT02N. How do i do this? I am new to ALE and idoc . thanks sankar

  • Splitting string with changing length length

    Hi, I am trying to read the position of an automatic stage in X,Y,Z axes. The stage returns a string of the three axes, and I would like to get the position of each axis separately. The thing is that the length of the string changes as the stage move