Multiple Column Sub queries

Hi,
I am facing some problems in teaching Multiple column subqueries and also ig u'll could with some example show me how to use sub-query using from clause??

Essentially you are using subqueries within the FROM clause.
Here is an example of an embedded view (i.e. view-on-the-fly):
select a.person_id, a.fname, a.lname,
c.job_id
from person a,
(select b.person_id, b.fname,
b.lname, b.job_id
from jobs b) c
where a.person_id = c.person_id

Similar Messages

  • The issue with using the multiple columns sub-query in WHERE clause

    Hi All,
    my database version is 10.2.
    the problem i am trying to deal with is that when I use multiple column sub-query in the WHERE clause of the SELECT statement, the actual row number returned from the sub-query is different from the whole statement.
    And what I found is that, whenever there is NULL in any of those columns returned from the SUB-QUERY, the outer query will just return NULL for that whole row.
    Here is an example:
    select empno, ename, job, mgr, hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  mgr, hiredate, sal, deptno from t;
    7782     CLARK     MANAGER     7839     09-JUN-81     2450     10
    7839     KING     PRESIDENT  NULL  17-NOV-81     5000     10
    7934     MILLER     CLERK     7782     23-JAN-82     1300     10
    select * from EMP where (EMPNO, ENAME, job, MGR, HIREDATE, SAL, DEPTNO) in (
    select empno, ename, job, mgr, hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  mgr, hiredate, sal, deptno from t);
    7782     CLARK     MANAGER     7839     09-JUN-81     2450          10     
    7934     MILLER     CLERK     7782     23-JAN-82     1300          10     If I specifically deal with the NULL situations for the columns which might return NULL, I can get the result right.
    select * from EMP where (EMPNO, ENAME, job, NVL(MGR,-1), HIREDATE, SAL, DEPTNO) in (
    select empno, ename, job, nvl(mgr,-1), hiredate, sal, deptno from EMP
    intersect
    select empno, ename, job,  nvl(mgr,-1), hiredate, sal, deptno from t);
    7782     CLARK     MANAGER     7839     09-JUN-81     2450          10     
    7839     KING     PRESIDENT  null   17-NOV-81     5000          10     
    7934     MILLER     CLERK     7782     23-JAN-82     1300          10     the problem is that, I feel this is a very lame way of handling it.
    So, I wonder or am asking if there is any better or standard way to do it?
    any help would be highly appreciated.
    Thanks

    Hi,
    As you discovered, INTERSECT treats NULL as a value, but IN does not.
    What you did with NVL is one way to handle the situation. If there was a chance that any of the columns could be NULL, then you might prefer something like this:
    select      *
    from      EMP
    where      ( EMPNO      || '~' ||
           ENAME      || '~' ||
           job           || '~' ||
           MGR           || '~' ||
           TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')
                    || '~' ||
           SAL           || '~' ||
           DEPTNO
         ) in (
              select  EMPNO      || '~' ||
                     ENAME      || '~' ||
                   job     || '~' ||
                   MGR     || '~' ||
                   TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')               
                        || '~' ||
                   SAL      || '~' ||
                   DEPTNO
              from     emp
             intersect
              select  EMPNO      || '~' ||
                     ENAME      || '~' ||
                   job     || '~' ||
                   MGR     || '~' ||
                   TO_CHAR (HIREDATE, 'DD-MON-YYYY HH24:MI:SS')               
                        || '~' ||
                   SAL      || '~' ||
                   DEPTNO
              from      t
             );This assumes that you can identify some string (I used '~') that never occurs in the strings in these tables.
    This is implicitly converting the NUMBERs. That's usually not a good thing to do. but explicitly converting them would make this even more tedious.
    You should explicitly convert any DATEs to strings, however. Depending on your default format, and your data, you might get away with implicit conversions even for DATEs, but don't bet on it.
    If you had to do this often, you might consider writing a user-defined function:
    delimited_string (empno, ename, job, mgr, hiredate, sal, deptno) would return a string like
    '7839~KING~PRESIDENT~~17-NOV-1981~5000~10'
    This will make the coding easier, but beware: it will make the execution slower.

  • Tricky query with multiple hierarchial sub queries

    Here's a pussle that I cannot solve. Who can help me?
    Given table F (records form a binary tree with levels 0, 1, and
    2):
    Id IdParent
    F1 null
    F2 F1
    F3 F2
    F4 F2
    F5 F1
    F6 F5
    F7 F5
    and given table D (records form a similar binary tree with
    levels 0, 1, and 2):
    Id IdParent
    D1 null
    D2 D1
    D3 D2
    D4 D2
    D5 D1
    D6 D5
    D7 D5
    and given table P (cross referencing tables F and D):
    IdF IdD
    F2 D6
    F3 D2
    F5 D7
    and given table S (which holds the seed to the query):
    IdF
    F3
    and given table I (just any collection of records that reference
    table D which we want to select records from):
    Id IdD
    I1 D1
    I2 D2
    I3 D3
    I4 D4
    I5 D5
    I6 D6
    I7 D7
    I8 D1
    I9 D5
    all together being related like in figure 1:
    S.IdF =>> F.Id
    F.Id <- P.IdF
    P.IdD -> D.Id
    D.Id <<= I.IdD
    where =>> denotes 'is or is a descenden of'
    and -> denotes 'is'
    I want to build a query that lets me select all records from
    table I, which reference table D, such that the referenced
    records in table D are hierarchial descendents of any record
    that is referenced by records in table P, for which they
    reference records in table F, which are ancestors to records
    referenced by records in table S.
    If it wasn't for the hierarchial approach on both sides of the
    cross referencing table, matters would have been easy. Then the
    releational map would have been like in figure 2:
    S.IdF <- P.IdF
    P.IdD -> I.IdD
    and the query would have been:
    SELECT I.Id
    FROM I, P, S
    WHERE I.IdD = P.IdD
    AND P.IdF = S.IdF
    So in what I am looking for, you may say that the '='-signs in
    this select statement should denote 'is or is a descenden of'
    going towards the side of table P.
    Given the tables listed above and given the query I am seeking,
    I expect to retrieve the following result set:
    I.Id
    I2
    I3
    I4
    I6
    Tricky, eh? I belive the figures are the best angles to
    understand this problem.

    You do this with subqueries and hierarchical queries...
    First the hierarchal subquery on F...
    SQL> SELECT f.id
      2    FROM f
      3   CONNECT BY PRIOR f.idp = f.id
      4   START WITH f.id IN ( SELECT idf FROM s )
      5       ;
    ID
    F3
    F2
    F1
    Then join with the cross reference table...
    SQL> SELECT p.idd
      2    FROM p
      3       , (  SELECT f.id
      4              FROM f
      5             START WITH f.id IN ( SELECT idf FROM s )
      6             CONNECT BY PRIOR f.idp = f.id
      7         ) s
      8   WHERE s.id = p.idf
      9       ;
    ID
    D6
    D2
    Use this as a subquery in a hierarchial query for the
    descendents in D...
    SQL> SELECT d.id
      2    FROM d
      3   START WITH d.idd IN ( SELECT p.idd
      4                         FROM p
      5                            , ( SELECT f.id
      6                                  FROM f
      7                                 START WITH f.id IN ( SELECT
    idf FROM s )
      8                                 CONNECT BY PRIOR f.idp = f.id
      9                             ) s
    10                        WHERE s.id = p.idf
    11                      )
    12   CONNECT BY PRIOR d.id = d.idp
    13       ;
    ID
    D2
    D3
    D4
    D6
    Then use that as a subquery to return the I result set...
    SQL> SELECT i.id
      2    FROM i
      3   WHERE i.idd  IN  ( SELECT d.id
      4                        FROM d
      5                       START WITH d.id IN ( SELECT p.idd
      6                                             FROM p
      7                                                , ( SELECT
    f.id
      8                                                      FROM f
      9                                                     START
    WITH f.id IN ( SELECT idf FROM s )
    10                                                     CONNECT
    BY PRIOR f.idp = f.id
    11                                                 ) s
    12                                            WHERE s.id = p.idf
    13                                          )
    14                       CONNECT BY PRIOR d.id = d.idp
    15                    )
    16       ;
    ID
    I2
    I3
    I4
    I6Good Luck...

  • Decode with multiple column sub query

    Dear's
    What is the wrong with the query
    select * from common_master
    where
    (company_code,lpad(rtrim(ltrim(bu_code)),12,' ')) IN
    decode ('ADMIN','ADMIN',(select company_code ,lpad(rtrim(ltrim(bu_code)),12,' ') from common_master )
    ,(select company_code ,lpad(rtrim(ltrim(bu_code)),12,' ') from user_system_privs) )
    The error message as
    Error starting at line 16 in command:
    select * from common_master
    where
    (company_code,lpad(rtrim(ltrim(bu_code)),12,' ')) IN
    decode ('ADMIN','ADMIN',(select company_code ,lpad(rtrim(ltrim(bu_code)),12,' ') from common_master )
    ,(select company_code ,lpad(rtrim(ltrim(bu_code)),12,' ') from user_system_privs) )
    Error at Command Line:18 Column:53
    Error report:
    SQL Error: ORA-00920: invalid relational operator
    00920. 00000 - "invalid relational operator"
    *Cause:   
    *Action:
    Dennis

    You can club the columns in where clause and in decode
    like
    select * from common_master
    where
    (company_code || lpad(rtrim(ltrim(bu_code)) || to_char(12) ||' ') IN
    ( select decode ('ADMIN','ADMIN',company_code || lpad(rtrim(ltrim(bu_code)) || to_char(12) || ' ') from common_master ),
    ,company_code || lpad(rtrim(ltrim(bu_code)) || to_char(12) ||' ') from user_system_privs) )
    HTH,
    ~Yogesh

  • Multiple column subqeuries

    Hi Friends
    I am preparing for OCP SQL & PLSQL. CAn any body explain me
    "How to write Multiple column subqueries? and There was a question like
    Which statement about multiple column sub-queries is correct for a non-pair wise comparison?
    A. Produce a cross product
    B. Produce a non-crossed product
    C. Return zero row
    D. Produce error when executed
    can any one explain what pairwise and non pairwise comparision is? Thanks in advance

    http://forums.oracle.com/forums/message.jsp?id=484231

  • Selecting Multiple columns in Sub-query

    Hi All,
    I've been using three co-related queries to fetch data as shown below in the pseudo code. All these sub-queries are same, except the column name. I want to avoid the same query to be executed thrice for three columns. Is there any way to avoid this?
    insert into my_table
    select colA,
    colB,
    (select field1 from table1 where table1.fieldx =tableA.fieldy ) col1,
    (select field2 from table1 where table1.fieldx =tableA.fieldy) col2,
    (select field3 from table1 where table1.fieldx =tableA.fieldy) col3
    from tableA , table B 
    where con1= con2
        and con3 = con4
        and con4=con5;All suggestions are welcomed
    Regards,
    K

    Hi,
    Perhaps this is what you want:
    INSERT INTO my_table (colA, colB. col1, col2, col3)    -- list the columns explicitly
    WITH     table_1_summary          AS
         SELECT       fieldx
         ,       MIN (field1)     AS col1
         ,       MIN (field2)     AS col2
         ,       MIN (field3)     AS col3
         FROM       table1
         GROUP BY  fieldx
    SELECT       colA
    ,       colB
    ,       t1.col1
    ,       t1.col2
    ,       t1.col3
    FROM       tableA          a
    ,       tableB          b
    ,       table_1_summary     t1
    WHERE       con1          = con2
    AND       con3          = con4
    AND       con4          = con5
    AND       t1.field1 (+)     = a.fieldy
    ;Something a little shorter (and a little more efficient) might work, depending on you data, especially what columns are unique.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using.

  • Merge statement - update multiple columns from a single sub-select

    Is it possible to write in 10gR2, a MERGE statement, with UPDATE for multiple columns from a single sub_select?
    like this:
    MERGE INTO tableA
    using ( select * from temp) tmp
    on( tableA. col1 = tmp.col1)
    when matched then
    update set  ( tableA.col5,
                       tableA.col6,
                       tableA.col7) = ( select sum(col2), sum(col3), sum(col5)
                                                                                 from tableX
                                                                                where tableX.col1 = tableA.col1...)

    Hi,
    The USING clause is not a sub-query, so it can't reference columns from tables that are not in it.
    Include tableA in the USING clause if you really need to refer to it there. (It's not obvious that you do.)
    As always, it helps if you post:
    (1) The version of Oracle (and any other relevant software) you're using
    (2) A little sample data (just enough to show what the problem is) from all the relevant tables
    (3) The results you want from that data (In the case of a DML statement, such as MERGE, this will be the state of the tables when everything is finished.)
    (4) Your best attempt so far (formatted)
    (5) The full error message (if any), including line number
    Executable SQL statements (like "CREATE TABLE AS ..." or "INSERT ..." statements) are best for (2).
    If you can present your problem using commonly available tables (for example, tables in scott schema, or views in the data dictionary), then you can omit (2).
    Formatted tabular output is okay for (3).

  • Multiple Column Report Question

    Post Author: LCS213
    CA Forum: Crystal Reports
    I'm creating a student transcript report that has multiple columns, and is three groups deep.  The first two groups need to be in a columnar layout. However, I'd like the third group to contain a subreport that spans the width of the entire page. 
    Are there any options within Crystal XI to do this?  I know in the Section Expert, i can format the detail level with multiple columns, and on the Layout tab, I can select "Format Groups with multiple columns".  But that seems like it either formats ALL groups or NO groups.  Am I mistaken?  Is there a workaround I'm missing?
    Thanks in advance for any help on this issue!

    Hi Dan,
    According to your description, we are not clear about the “6 sections for each Additional task”. Do you mean six data records? If so, based on my understanding, there are three groups and eighteen records in your report. You want to make those records appear
    on eighteen separated pages, right?
    In Reporting Service, we can add a page break to groups within data regions to control the amount of information on each page. In your scenario, you should add page break to group “Sub task”, group “Additional Task” and details. As we tested in our environment,
    add page break to these records, the report appears in eighteen pages. Please refer to steps below:
    1.On Group Properties of Details1, choose “Between each instance of a group” option on Page Breaks page. Please refer to screenshot below:
     Choose same option on Group Properties for group “Month” and “Name”.
    2.Click drop-down button next to Column Groups, then choose Advanced Mode.
    3.Click on Static under Row Groups, set RepeatOnNewPage as True in Tablix Member Properties.
    4.Click Preview, the results before and after adding page break look like below:
    If you still have any question, please post some detail information or screenshot about the report design you expect.
    Best regards,
    Qiuyun Yu

  • How to filter rows where multiple columns meet criteria, ignoring rows where only some columns meet criteria

    Hi All,
    Question: How do I filter rows out of a query where multiple columns are equal to a single question mark character?
    Background: I'm using SQL 2008 R2.  Furthermore, the part of my brain that helps me create less-than-simple queries hasn't been working for the last 4 days, apparently, and now I need help.
    We have about 4,000 rows in a table.  This data set was generated from an exported report, and many of the rows in the detail table were not actual data rows but were simply "header" rows.  For those table rows, most of the columns have
    a single question mark as the value.
    Some of the detail rows have one or more question mark values, too, so it's important that these rows don't get filtered out.
    When I include criteria like "WHERE col1 <> '?' AND col2 <> '?' AND col3 <> '?' AND col4 <> '?'", all rows with a question mark value for even a single one of those columns get filtered out.  How do I filter out rows
    where all columns 1-4 contain a question mark value?
    Thanks for your help,
    Eric

    I just tried to create to create a scenario for you. Please see ig you're looking for something like this.
    Create table test_Question_mark
    RecordID INT identity(1,1),
    Col1 varchar(10),
    Col2 varchar(10),
    Col3 varchar(10),
    Col4 varchar(10),
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','?','?','?')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','??','?','?')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','??','??','?')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('??','??','??','??')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('?','?','?','?')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('??','test ??','??','??')
    insert into test_Question_mark (Col1, Col2, Col3, col4) values ('??','test ?','??','??')
    --drop table test_Questio_mark
    select * from test_Question_mark
    select * from test_Question_mark 
    WHERE 
    (CHARINDEX('?', Col1,1) > 0 AND CHARINDEX('?', Col1, CHARINDEX('?', Col1,1)+1) = 0) AND 
    (CHARINDEX('?', Col2) > 0 AND CHARINDEX('?', Col2, CHARINDEX('?', Col2,1)+1) = 0) AND 
    (CHARINDEX('?', Col3,1) > 0 AND CHARINDEX('?', Col3, CHARINDEX('?', Col3,1)+1) = 0) AND 
    (CHARINDEX('?', Col4,1) > 0 AND CHARINDEX('?', Col4, CHARINDEX('?', Col4,1)+1) = 0) 
    --drop table test_Questio_mark
    I hope above solution will help.
    Thanks!
    Ashish.

  • STATIC TIME STAMP IN MULTIPLE COLUMNS

    I have a single spreadsheet for Monday - Friday.  There are multiple columns for each day.  It has been asked of me the following:
    When the customer name is typed for the first time in columns: E, T, AH, AV, BJ  rows 5-28 then the static date & time would appear in another column on the same row.  I would be adding columns (M, AB, AQ, BF, BU)  for date/time.  
    Example: Customer name typed in E5 the date time would show in M5 for Monday.  For Tuesday, it would be T5 with date in AB5, etc.
    I have very little experience with VBA and have searched the internet for a solution, there are many conditions and have tried for using solutions for just one column, but none have worked.  
    Thank you
    Linda
    woodlinda

    You can have only one Worksheet_Change event procedures per worksheet. You have to combine the two Worksheet_Change event procedure into one:
    Private Sub Worksheet_Change(ByVal Target As Range)
        If Not Intersect(Target, Columns("C:BB")) Is Nothing Then
           Rows(Target.Row + 1).Hidden = False
        End If
        If Not Intersect(Range("E5:E28,T5:T28,AH5:AH28,AV5:AV28,BJ5:BJ28"), _
                Target) Is Nothing Then
            Application.EnableEvents = False
            Intersect(Range("E5:E28,T5:T28,AH5:AH28,AV5:AV28,BJ5:BJ28"), _
                Target).Offset(0, 8) = Now
            Application.EnableEvents = True
        End If
    End Sub
    Regards, Hans Vogelaar (http://www.eileenslounge.com)

  • With clause vs sub-queries

    db and dev 10g rel2 , hi all,
    i am trying to learn the "WITH CLAUSE" , and i do not see any difference between using it and using sub-queries .
    when i searched for this , i found that the with clause is used when You need to reference the subquery block multiple places in the query by specifying the query name , but i can not imagine an example for doing so .
    if you could provide me with an example please ? and telling me about another situations in which i could need using the "with clause" if any ?
    thanks

    >
    db and dev 10g rel2 , hi all,
    i am trying to learn the "WITH CLAUSE" , and i do not see any difference between using it and using sub-queries .
    when i searched for this , i found that the with clause is used when You need to reference the subquery block multiple places in the query by specifying the query name , but i can not imagine an example for doing so .
    if you could provide me with an example please ? and telling me about another situations in which i could need using the "with clause" if any ?
    >
    It isn't just about referencing a subquery multiple times. There are other advantages to using 'common table expressions'/'subquery factoring' also.
    Take a look at the example below. It first defines 'dept_costs' as a query block, then defines 'avg_cost' as a new query block and it references the first query block.
    Then the actual query references both query blocks just as if they are tables. And, in fact, in some circumstances Oracle will actually materialize them AS temporary tables.
    Look at how easy it is to understand the entire statement. You can focus first on the 'dept_costs' query block WITHOUT having to look at anything else. That is because the query block is self-contained; you are defining a result set. There is no 'join' or connection to any other part of the statement.
    It is easy for a developer, and for Oracle, to understand what is needed for that one piece.
    Next you can focus entirely on the 'avg_cost' query block. Since it uses the first query block just as if it were a table you can treat it as a table. That means you do NOT even need to look at the first query block to understand what the second query block is doing.
    Same with the actual query. You can analyze it by treating the two query blocks just as if they were other tables.
    Even better you can test the first query block by itself in sql*plus or other tool to confirm that it works and you can create an execution plan for it to make sure it will use an appropriate index. You can also then test the first and second query blocks together to make sure THEY have a proper execution plan.
    Then when you test then entire statement you already know that the query blocks work correctly.
    Try to do THAT with a query that uses nested sub-queries.
    Sure - you could write a set of nested sub-queries to accomplish the same thing (Oracle will sometimes rewrite your query that way itself) but it becomes one big query and the individual pieces are not nearly as easy to see, analyze or understand.
    It can be difficult if not impossible to extract a nested query in order to test it even to just try to get the syntax working. And when you do extract it you will often be testing something that isn't quite exactly the same as when i t was nested.
    So: easier to understand, easier to write and test (especially for new developers) as well as easier to use multiple times without having to duplicate it.
    >
    subquery_factoring_clause
    The WITH query_name clause lets you assign a name to a subquery block. You can then reference the subquery block multiple places in the query by specifying the query name. Oracle Database optimizes the query by treating the query name as either an inline view or as a temporary table.
    >
    The SQL Language doc has an example.
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_10002.htm#i2129904
    >
    Subquery Factoring: Example The following statement creates the query names dept_costs and avg_cost for the initial query block containing a join, and then uses the query names in the body of the main query.
    WITH
    dept_costs AS (
    SELECT department_name, SUM(salary) dept_total
    FROM employees e, departments d
    WHERE e.department_id = d.department_id
    GROUP BY department_name),
    avg_cost AS (
    SELECT SUM(dept_total)/COUNT(*) avg
    FROM dept_costs)
    SELECT * FROM dept_costs
    WHERE dept_total >
    (SELECT avg FROM avg_cost)
    ORDER BY department_name;
    DEPARTMENT_NAME DEPT_TOTAL
    Sales 313800
    Shipping 156400

  • Sub queries

    i have a longish query which runs correctly in Oracle 8i Lite thro SQL Plus but does not run when using JDBC.
    The query has multiple subqueries and it looks like
    delete from node_initial_values d where d.node_id in (select c.node_id from node_master c where c.node_id=d.node_id and c.node_id in (select e.node_id from network_design e where c.node_id=e.node_id and e.network_id in (select b.network_id from network_master b where e.network_id=b.network_id and b.network_id in (select g.network_id from output_network_scenario g where g.network_id=b.network_id and g.output_network_master_id in (select a.output_network_master_id from output_network_master a where a.output_name= 'network three')))));
    assume all the tables exist with correct data. the above query works perfectly well in SQL*plus but when i use
    the following code i get an error
    PreparedStatement deleteNodeInitialValuesPst=getConn.prepareStatement("delete from node_initial_values d where .... a where a.output_name= ?)))))");
    deleteNodeInitialValuesPst.setString(1,"network three");
    deleteNodeInitialValuesPst.executeUpdate();
    getConn.commit();
    ... rest of the code
    the error code oracle 8i lite gives is
    java.sql.SQLException: [POL-4200] bad action for transaction operation
    would really appreciate any help in this regard...
    specifically can anyone tell me if prepared statement is the correct function to use here...
    thanks

    I made the following changes:
    changes to the code, new code mentioned below
    changed the database to oracle 8i enterprise edition running on NT.
    new code now is
    // connetion parameter and other code here
    String deleteNodeInitialValuesStr=
    "delete from node_initial_values d where d.node_id in (select c.node_id from node_master c where c.node_id=d.node_id and c.node_id in (select e.node_id from network_design e where c.node_id=e.node_id and e.network_id in (select b.network_id from network_master b where e.network_id=b.network_id and b.network_id in (select g.network_id from output_network_scenario g where g.network_id=b.network_id and g.output_network_master_id in (select a.output_network_master_id from output_network_master a where a.output_name='"+nextElementStr+"')))))";
    Statement deleteNodeInitialValuesSt=getConn.createStatement();
              deleteNodeInitialValuesSt.executeQuery(deleteNodeInitialValuesStr);
    getConn.commit();
    } // end try
    catch(SQLException ex) {
         while(ex !=null){
    out.println("Java SQL Exception: " + ex.getMessage()+"<br>");
    out.println("Vendor error code: " + ex.getErrorCode()+ "<br>");
    out.println("SQL State: " + ex.getSQLState() + "<br>");
    ex=ex.getNextException();
    } // end while
    } // end catch
    // more code here
    the output i get is
    Java SQL Exception: 202
    Vendor error code: 0
    SQL State: null
    I turned off getConn.commit(), but the error code remains the same. is there an alternative to the sub queries above. where can i get the meaning of the error codes thrown by the exception ?
    thanks

  • Using Sub Queries in OBIEE

    Hi,
    I am new to the OBIEE world and was wondering how we can work with sub queries. I have the following problem.
    I have a table namely XYZ in which we have "effective date" and "Amount". In the answers section have have filter out the data for the month of 01-Nov-08 to 30-Nov-08 which shows the total cash amount for that month. Now the problem is that I need to use the same "effective date" and "Amount" to get the opening balance which is calculated by Sum(Amount) where "effective date" < 01-Nov-2008. If i try to do this I do not see any results as the data gets filtered out. Can someone please help me on this?
    Thanks

    Hi,
    In column formula put column level filter like this FILTER("Facts Revenue".Revenue USING (Time."Day Date" < date '2006-10-09'))
    Regards
    Naresh

  • Can anyone tell me WHY Oracle won't allow sub-queries in outer joins?

    Hi,
    I've recently been tasked with converting a series of InterBase dbs to Oracle.
    Many of the queries in the InterBase dbs use sub-queries in outer joins. Oracle won't countenance this (01799 - a column may not be outer-joined to a subquery).
    I can get around it using functions but WHY won't Oracle allow this?
    SQL Server allows it, InterBase allows it (I don't know about ANSI SQL) but it seems to be a common enough technique...
    I'm just curious (and also a little frustrated!).
    Thanks in advance,,,

    Hi,
    >>Oracle treat an empty string as a NULL
    Well, you same answer your question. Because it is empty
    SGMS@ORACLE10> create table tab (cod number, name varchar2(1));
    Table created.
    SGMS@ORACLE10> insert into tab values (1,'');
    1 row created.
    SGMS@ORACLE10> insert into tab values (2,' ');
    1 row created.
    SGMS@ORACLE10> commit;
    SGMS@ORACLE10> select cod,dump(name) from tab;
           COD DUMP(NAME)
             1 NULL
             2 Typ=1 Len=1: 32
    SGMS@ORACLE10> select * from tab where name is null;
           COD NAME
             1Cheers
    If you talking about language tools, for example PHP treat empty string <> of NULL values. e.g: functions like is_empty() and is_null()
    Message was edited by:
    Legatti

  • Multiple Column Header in Report (BEx and Web Reporting)

    Hi All,
            I've a requirement where my reports is having multiple column header.
       To be precise the column header is further divided into many sub-columns (upto 4 levels).
    Structure cannot help in this case since we have more than 2 such columns and we are using web reporting as well.
    Here is how it looks
                             <b>Header-A</b>
    Header-B1   |   Header-B2   |   Header-B3    |  Header-Bn
    Hdr-C1 |Hdr-C2 |Hdr-D1 |Hdr-D2 |Hdr-E1 |Hdr-E2 |Hdr-Fn..
    The above is a sample header structure.
    This report will be a Web Based report and I need to know whether its possible to do it in BEx also.
    We are not using Crystal Reports.
    If there is any document related to this, please mail to
    [email protected]
    Thanks & Regards,
    Chandran Ganesan

    Hi Chandran,
    I hope i am getting your problem right.
    If your
    Header-B1 | Header-B2 | Header-B3 | Header-Bn
    Hdr-C1 |Hdr-C2 |Hdr-D1 |Hdr-D2 |Hdr-E1 |Hdr-E2 |Hdr-Fn..
    are a set of key figures, then there is an option.
    For example:
    You drag Header-B1,Hdr-C1 |Hdr-C2
    into column section.Right click on Hdr-C1, Hdr-C2 and select down under. So your Hdr-C1, Hdr-C2 will be under
    Header-B1.
    Like wise drag Header-B2,Hdr-D1,Hdr-D2
    Right click on Hdr-D1,Hdr-D2 and say Down under and these two will fit below Header-B2.
    You can repeat the above steps for Header-B3... Header-Bn
    The output will be same as the one you have specified above.
    Hope it helps,
    Regards,
    Parth.

Maybe you are looking for