Select * from tbl1 less select * from tbl2 is null

Hi all
I have 2 tables with the same 8 column, a column has the value zero from top to bottom.
60 000 lines, tbl1 tbl2 has 70 000 lines.
I need to see the 10,000 lines of tbl2 that are distinguished by the lines of tbl1.
If I run select * from tbl1 intersect select * from tbl2, I get all the 60,000 tbl1 lines.

However, if I run select * from tbl2 less select * from tbl1 I get no line?

I can't understand why, can anyone help, please.

Thank you
Kowalsky

Are you sure that it's really 10,000 TBL2 lines which are distinguished by a line any in TBL1? Instead of 10,000 additional rows in double?

Justin

Tags: Database

Similar Questions

  • How to deal with Menu select when there are NULL or a value with SQL

    I have a Menu(:P_55X) SELECT with:

    "NULL VALUE DISPLAY" = NULL

    'NULL RETURN VALUE' = NULL

    The graphical query is as follows.


    SELECT NULL LINK,
    START_DATE "FOR_MONTH",
    ROUND(AVG("SLA"),3) "SLA_UPTIME"
    from SLA_TIMES_ZABBIX
    LEFT JOIN (SELECT DISTINCT NODE_NAME,OS_TYPE from CMS.CMS_NODE_OS where remove_dt is NULL) OSNODE on LOWER(SLA_TIMES_ZABBIX.NODE_NAME)=LOWER(OSNODE.NODE_NAME)
    where OS_TYPE=:P55_X group by START_DATE order by START_DATE ASC;
    

    How can I accout for the (: P55_X) variable is sometimes NULL and not null sometimes. which means I can't use the '=' when values is null because I need an IS NULL it.

    The column in the database has a value or is set to NULL.

    Thank you

    Robert

    where (OS_TYPE = :P55_X OR (:P55_X IS NULL and OS_TYPE IS NULL))
    
  • Search, select and delete Pages Null?

    While trying to find a way to quickly reduce the size of large PDF files that are read online, I thought I would highlight a keyword on the pages that I need and then delete pages without annotations. I decided to replace step 2 action to search and highlight words with my own script. The script I came up with, (my first) works very well on the 35-page document that I used to develop:

    var pageArray =]

    for (var i = 0; i < this.numPages; i ++)

    {

    Aannots = this.getAnnots (i);

    If (Aannots is nothing)

    {

    pageArray.push (i);

    };

    pageArray.sort ();

    pageArray.reverse ();

    }

    for (var j = 0; j < pageArray.length; j ++)

    {

    this.deletePages (pageArray [j], [j] pageArray)

    }

    but when run on a very grand, 2000 + page doc, it removes some of the pages, then crashes or finishes with:

    «TypeError: invalid argument type.»

    Undefined Doc.deletePages:62:Batch: Exec

    = > Start parameter. » »

    in the console.

    If I continue to run this code in the console, it subsequently deletes all pages not annotated.

    Since the arguments come from the matrix, I print and am surprised that it is not in reverse numerical order, than I expected.

    Could it be the problem?  or one of them?

    Thanks for any help you can give... to 65, I don't know if I'll live long enough to understand this!

    When you remove items from any kind of table, it is always a good idea to loop top from the end of the beginning, because you delete items inside you effectively change the size of the array and this can screw up the next steps in your loop.

    Otherwise, you will need to reverse the order of the table (which your code is trying to do, but it does not work because of how works the sort function). Try this code instead:

    var pageArray=[]
    for (var i = 0; i <  this.numPages; i++) {
        Aannots = this.getAnnots(i);
        if (Aannots == null) {
            pageArray.push(i);
      };
    }
    pageArray.reverse();
    
    for (var j = 0; j < pageArray.length; j++) {
        this.deletePages(pageArray[j],pageArray[j])
    }
    
  • From 0 to NULL

    Hi buddies!

    I am faced with a situation where I need to convert the values 0 to empty string or NULL.

    For example,.

    I have a 3 column table Testing

    column at the beginning, middle, end

    They are of type varchar2 (20) that contains numbers.

    If the column had to display 0, I should replace it with NULL.

    How can I do that. Please guide me.

    Should I provide more details?

    Thank you.

    Benard

    Use a DECODING

    Thus

    decode(col_1,'0',NULL,col_1)
    

    converts null values for '0', but if the line is not a '0', it returns the actual value.

    Hemant K Collette

  • Newbie. SELECT with Clause: bad execution plan.

    Hello

    1)

    SQL> WITH CTATEL AS
      2  (SELECT A.CTA_FACTURAC, A.NUM_TELEFONO
      3  FROM PFA_CONTABON A, PGA_CTAFACTU B, PGA_ABONOS C
      4  WHERE B.CTA_FACTURAC=A.CTA_FACTURAC
      5  AND C.NUM_TELEFONO=A.NUM_TELEFONO)
      6  SELECT 71, A.CTA_FACTURAC, B.NUM_TELEFONO, A.COD_CONFACTU, SYSDATE, 0, A.TOT_IMPORTE*166.386, A.TOT_IMPORTE, 'E'
      7  FROM SOL_FICHERO a, CTATEL b
      8  WHERE ID_SOLICITUD=71
      9  AND A.CTA_FACTURAC=B.CTA_FACTURAC
     10  AND (A.NUM_TELEFONO IS NULL OR (A.NUM_TELEFONO <> '0' AND B.NUM_TELEFONO IS NOT NULL AND A.NUM_TELEFONO=B.NUM_TELEFONO))
     11  AND A.COD_CONFACTU IS NOT NULL AND  EXISTS (SELECT 1 FROM PGSM_CONFACTU WHERE COD_CONFACTU=A.COD_CONFACTU);
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 711563975
    
    ---------------------------------------------------------------------------------------------------
    | Id  | Operation                       | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                |                 |     1 |    64 |     6   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS                   |                 |     1 |    64 |     6   (0)| 00:00:01 |
    |   2 |   NESTED LOOPS                  |                 |     1 |    54 |     5   (0)| 00:00:01 |
    |   3 |    NESTED LOOPS                 |                 |     1 |    45 |     4   (0)| 00:00:01 |
    |   4 |     NESTED LOOPS SEMI           |                 |     1 |    26 |     2   (0)| 00:00:01 |
    |*  5 |      TABLE ACCESS BY INDEX ROWID| SOL_FICHERO     |     2 |    44 |     2   (0)| 00:00:01 |
    |*  6 |       INDEX RANGE SCAN          | SOL_FICHERO_I01 |     6 |       |     1   (0)| 00:00:01 |
    |*  7 |      INDEX UNIQUE SCAN          | PK_CONFACTU     |  5820 | 23280 |     0   (0)| 00:00:01 |
    |*  8 |     INDEX RANGE SCAN            | PK_CONTABON     |     1 |    19 |     2   (0)| 00:00:01 |
    |*  9 |    INDEX UNIQUE SCAN            | PK_CTAFACTU     |     1 |     9 |     1   (0)| 00:00:01 |
    |* 10 |   INDEX UNIQUE SCAN             | PK_ABONOS       |     1 |    10 |     1   (0)| 00:00:01 |
    ---------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       5 - filter("A"."COD_CONFACTU" IS NOT NULL)
       6 - access("ID_SOLICITUD"=71)
       7 - access("COD_CONFACTU"="A"."COD_CONFACTU")
       8 - access("A"."CTA_FACTURAC"="A"."CTA_FACTURAC")
           filter("A"."NUM_TELEFONO" IS NULL OR "A"."NUM_TELEFONO"="A"."NUM_TELEFONO" AND
                  "A"."NUM_TELEFONO"<>'0')
       9 - access("B"."CTA_FACTURAC"="A"."CTA_FACTURAC")
      10 - access("C"."NUM_TELEFONO"="A"."NUM_TELEFONO")
    
    
    

    2)

    SQL> WITH CTATEL AS
      2  (SELECT A.CTA_FACTURAC, A.NUM_TELEFONO
      3  FROM PFA_CONTABON A, PGA_CTAFACTU B, PGA_ABONOS C
      4  WHERE B.CTA_FACTURAC=A.CTA_FACTURAC
      5  AND C.NUM_TELEFONO=A.NUM_TELEFONO)
      6  SELECT 71, A.CTA_FACTURAC, NULL, A.COD_CONFACTU, SYSDATE, 0, A.TOT_IMPORTE*166.386, A.TOT_IMPORTE, 'E'
      7  FROM SOL_FICHERO a
      8  WHERE ID_SOLICITUD=71
      9  AND A.NUM_TELEFONO IS NOT NULL AND A.NUM_TELEFONO='0'
     10  AND EXISTS (SELECT 1 FROM CTATEL b WHERE A.CTA_FACTURAC=B.CTA_FACTURAC)
     11  AND A.COD_CONFACTU IS NOT NULL AND  EXISTS (SELECT 1 FROM PGSM_CONFACTU WHERE COD_CONFACTU=A.COD_CONFACTU);
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3992598922
    
    -------------------------------------------------------------------------------------------------
    | Id  | Operation                     | Name            | Rows  | Bytes | Cost (%CPU)| Time     |
    -------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT              |                 |     1 |    26 |     7   (0)| 00:00:01 |
    |*  1 |  FILTER                       |                 |       |       |            |          |
    |   2 |   NESTED LOOPS SEMI           |                 |     1 |    26 |     2   (0)| 00:00:01 |
    |*  3 |    TABLE ACCESS BY INDEX ROWID| SOL_FICHERO     |     1 |    22 |     2   (0)| 00:00:01 |
    |*  4 |     INDEX RANGE SCAN          | SOL_FICHERO_I01 |     6 |       |     1   (0)| 00:00:01 |
    |*  5 |    INDEX UNIQUE SCAN          | PK_CONFACTU     |  5820 | 23280 |     0   (0)| 00:00:01 |
    |   6 |   NESTED LOOPS                |                 |     1 |    38 |     5   (0)| 00:00:01 |
    |   7 |    NESTED LOOPS               |                 |     1 |    28 |     4   (0)| 00:00:01 |
    |*  8 |     INDEX UNIQUE SCAN         | PK_CTAFACTU     |     1 |     9 |     2   (0)| 00:00:01 |
    |*  9 |     INDEX RANGE SCAN          | PK_CONTABON     |     1 |    19 |     2   (0)| 00:00:01 |
    |* 10 |    INDEX UNIQUE SCAN          | PK_ABONOS       |     1 |    10 |     1   (0)| 00:00:01 |
    -------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       1 - filter( EXISTS (SELECT /*+ */ 0 FROM "FACTMS"."PGA_ABONOS_1"
                  "C","FACTMS"."PGA_CTAFACTU" "B","FACTMS"."PFA_CONTABON_1" "A" WHERE
                  "B"."CTA_FACTURAC"="A"."CTA_FACTURAC" AND "A"."CTA_FACTURAC"=:B1 AND
                  "B"."CTA_FACTURAC"=:B2 AND "C"."NUM_TELEFONO"="A"."NUM_TELEFONO"))
       3 - filter("A"."COD_CONFACTU" IS NOT NULL AND "A"."NUM_TELEFONO" IS NOT NULL AND
                  "A"."NUM_TELEFONO"='0')
       4 - access("ID_SOLICITUD"=71)
       5 - access("COD_CONFACTU"="A"."COD_CONFACTU")
       8 - access("B"."CTA_FACTURAC"=:B1)
       9 - access("B"."CTA_FACTURAC"="A"."CTA_FACTURAC")
           filter("A"."CTA_FACTURAC"=:B1)
      10 - access("C"."NUM_TELEFONO"="A"."NUM_TELEFONO")
    

    3)

      1  WITH CTATEL AS
      2  (SELECT A.CTA_FACTURAC, A.NUM_TELEFONO
      3  FROM PFA_CONTABON A, PGA_CTAFACTU B, PGA_ABONOS C
      4  WHERE B.CTA_FACTURAC=A.CTA_FACTURAC
      5  AND C.NUM_TELEFONO=A.NUM_TELEFONO)
      6  SELECT 71, A.CTA_FACTURAC, B.NUM_TELEFONO, A.COD_CONFACTU, SYSDATE, 0, A.TOT_IMPORTE*166.386, A.TOT_IMPORTE, 'E'
      7  FROM SOL_FICHERO a, CTATEL b
      8  WHERE ID_SOLICITUD=71
      9  AND A.CTA_FACTURAC=B.CTA_FACTURAC
     10  AND (A.NUM_TELEFONO IS NULL OR (A.NUM_TELEFONO <> '0' AND B.NUM_TELEFONO IS NOT NULL AND A.NUM_TELEFONO=B.NUM_TELEFONO))
     11  AND A.COD_CONFACTU IS NOT NULL AND  EXISTS (SELECT 1 FROM PGSM_CONFACTU WHERE COD_CONFACTU=A.COD_CONFACTU)
     12  UNION ALL
     13  SELECT 71, A.CTA_FACTURAC, NULL, A.COD_CONFACTU, SYSDATE, 0, A.TOT_IMPORTE*166.386, A.TOT_IMPORTE, 'E'
     14  FROM SOL_FICHERO a
     15  WHERE ID_SOLICITUD=71
     16  AND A.NUM_TELEFONO IS NOT NULL AND A.NUM_TELEFONO='0'
     17  AND EXISTS (SELECT 1 FROM CTATEL b WHERE A.CTA_FACTURAC=B.CTA_FACTURAC)
     18* AND A.COD_CONFACTU IS NOT NULL AND  EXISTS (SELECT 1 FROM PGSM_CONFACTU WHERE COD_CONFACTU=A.COD_CONFACTU)
    
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 3945970136
    
    -----------------------------------------------------------------------------------------------------------------------
    | Id  | Operation                       | Name                        | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    -----------------------------------------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT                |                             |  3351 |   127K|       |   776  (53)| 00:00:10 |
    |   1 |  TEMP TABLE TRANSFORMATION      |                             |       |       |       |            |          |
    |   2 |   LOAD AS SELECT                |                             |       |       |       |            |          |
    |*  3 |    HASH JOIN                    |                             |   323K|    11M|    12M| 66832   (4)| 00:13:22 |
    |*  4 |     HASH JOIN                   |                             |   338K|  9254K|  4176K| 39353   (3)| 00:07:53 |
    |   5 |      INDEX FAST FULL SCAN       | PK_CTAFACTU                 |   203K|  1788K|       |   190   (4)| 00:00:03 |
    |   6 |      INDEX FAST FULL SCAN       | PK_CONTABON                 |    16M|   300M|       | 13975   (4)| 00:02:48 |
    |   7 |     INDEX FAST FULL SCAN        | PK_ABONOS                   |    15M|   150M|       |  9766   (5)| 00:01:58 |
    |   8 |   UNION-ALL                     |                             |       |       |       |            |          |
    |*  9 |    HASH JOIN                    |                             |  3350 |   127K|       |   388   (5)| 00:00:05 |
    |  10 |     NESTED LOOPS SEMI           |                             |     1 |    26 |       |     2   (0)| 00:00:01 |
    |* 11 |      TABLE ACCESS BY INDEX ROWID| SOL_FICHERO                 |     2 |    44 |       |     2   (0)| 00:00:01 |
    |* 12 |       INDEX RANGE SCAN          | SOL_FICHERO_I01             |     6 |       |       |     1   (0)| 00:00:01 |
    |* 13 |      INDEX UNIQUE SCAN          | PK_CONFACTU                 |  5820 | 23280 |       |     0   (0)| 00:00:01 |
    |  14 |     VIEW                        |                             |   323K|  4112K|       |   379   (4)| 00:00:05 |
    |  15 |      TABLE ACCESS FULL          | SYS_TEMP_0FD9D6621_1BE166BB |   323K|  6009K|       |   379   (4)| 00:00:05 |
    |* 16 |    HASH JOIN SEMI               |                             |     1 |    33 |       |   388   (5)| 00:00:05 |
    |  17 |     NESTED LOOPS SEMI           |                             |     1 |    26 |       |     2   (0)| 00:00:01 |
    |* 18 |      TABLE ACCESS BY INDEX ROWID| SOL_FICHERO                 |     1 |    22 |       |     2   (0)| 00:00:01 |
    |* 19 |       INDEX RANGE SCAN          | SOL_FICHERO_I01             |     6 |       |       |     1   (0)| 00:00:01 |
    |* 20 |      INDEX UNIQUE SCAN          | PK_CONFACTU                 |  5820 | 23280 |       |     0   (0)| 00:00:01 |
    |  21 |     VIEW                        |                             |   323K|  2214K|       |   379   (4)| 00:00:05 |
    |  22 |      TABLE ACCESS FULL          | SYS_TEMP_0FD9D6621_1BE166BB |   323K|  6009K|       |   379   (4)| 00:00:05 |
    -----------------------------------------------------------------------------------------------------------------------
    
    Predicate Information (identified by operation id):
    ---------------------------------------------------
    
       3 - access("C"."NUM_TELEFONO"="A"."NUM_TELEFONO")
       4 - access("B"."CTA_FACTURAC"="A"."CTA_FACTURAC")
       9 - access("A"."CTA_FACTURAC"="B"."CTA_FACTURAC")
           filter("A"."NUM_TELEFONO" IS NULL OR "A"."NUM_TELEFONO"="B"."NUM_TELEFONO" AND "A"."NUM_TELEFONO"<>'0')
      11 - filter("A"."COD_CONFACTU" IS NOT NULL)
      12 - access("ID_SOLICITUD"=71)
      13 - access("COD_CONFACTU"="A"."COD_CONFACTU")
      16 - access("A"."CTA_FACTURAC"="B"."CTA_FACTURAC")
      18 - filter("A"."COD_CONFACTU" IS NOT NULL AND "A"."NUM_TELEFONO" IS NOT NULL AND "A"."NUM_TELEFONO"='0')
      19 - access("ID_SOLICITUD"=71)
      20 - access("COD_CONFACTU"="A"."COD_CONFACTU")
    

    I use this WITH clausule in the query above:

    operating system

    WITH CTATEL AS 
    (SELECT A.CTA_FACTURAC, A.NUM_TELEFONO 
    FROM PFA_CONTABON A, PGA_CTAFACTU B, PGA_ABONOS C 
    WHERE B.CTA_FACTURAC=A.CTA_FACTURAC 
    AND C.NUM_TELEFONO=A.NUM_TELEFONO) 
    

    Why 3) plan is so bad? (In any case, it's like "UNION ALL" of 1) and 2).

    Thanks in advance,

    Jose Luis

    We do not know if one of them is 'bad' plans.

    In fact, there is no such thing as a bad plan, one or several inaccurate estimates.

    To determine whether a plan is 'bad', you really see who believes are inaccurate - and which means the time of execution of the execution plans and runtime enforcement measures.

    Please take a look at the notice in the following thread:

    HOW to: Validate a query of SQL statement tuning - model showing

    What happens in the third SQL, is that because you referenced the subquery WITH twice, Oracle decides to materialise it in a temporary table for the reason that it is cheaper that to do the same thing one subquery normally twice - a reasonable approach.

    It is probably more likely that the third query estimates are more accurate than the other two.

  • Select list or view Auto text

    Hi guys,.

    I'm trying to disable my tabular presentation the Application column . If the data exists, it must be blocked, but if the user clicks the Add button the selection list should appear.

    I tried with javascript is in many ways...

    $('td[headers="APPLICATION"]') .attr ("disabled", "disabled").addClass('apex_disabled');

    document.getElementById('f05_000'+i).disabled = true;

    $x('f05_000'+i).readOnly = "readonly";
    ......

    But when I click on submit button I got error of constraint because the list selection change of value null.

    now I'm doing it

    Select
    ID,
    CODE_U,
    ACCESS,
    case
    When
    v('REQUEST') = "Add" THEN
    APEX_ITEM. SELECT_LIST_FROM_LOV (5, APPLICATION, NULL, 'LOV_LISTE_APPLICATION', ' YES ', NULL,' - choose "")
    ON THE OTHER
    APEX_ITEM. TEXT_FROM_LOV (APPLICATION, 'LOV_LISTE_APPLICATION')
    COMPLETE THE APPLICATION
    of GESTION_DES_ACCES
    WHERE CODE_U =: P2_CODE_U

    But it does not work too. Can you give me some suggestions?

    I use Apex 4.1.1


    Thank you
    Eric

    After you turn off the value of the selection list, you can't get the value of the selection list. In your case, you can hide the selection list until you create a text element with the value selected in the select list, try the code below in DA

    $('select[name="f05"]').each( function(i) {
    
         var rowSelected= $(this).attr("id").substr(4);
    
            var appSelect= $('#f05_'+rowSelected).attr("id");
    
              //To change the background color for Application column
    
               $x(appSelect).style.background = "#F2F2F5";
    
              //To get the value from "Application" select list and hide it
    
              var fake = $(""+$("#f05_"+rowSelected+ " :selected").text()+"");
              $("#f05_"+rowSelected).before(fake);
              $("#f05_"+rowSelected).hide(); 
    
            }
    );
    

    Thank you
    Lacombe

  • Select the data if a value has a certain value?

    Hello, I'm trying to do...


    In pseucode, it looks like to...

    If this field has a value, then select a, b, c,... of table
    another "don't do anything".

    How can I do that, I tried...

    Select decode (LKP2. EXCLUDED_BOOK_CD, not null,
    (select 1 double),
    ('NOT NULL', 'ALL')
    OF LKP2 fcl_chunk_pid_correspondence
    WHERE LKP2. CHUNK_ID =: p_chunk_id
    AND LKP2. GCDS_ENTITY = "TRANSACTION".
    AND LKP2. EXCLUDED_BOOK_CD IS NOT NULL
    AND LKP2. UBR = "OTHER";

    But this does not work if there is not any row for where.

    Thanks in advance!

    write a case statement as

    Select the case while sal is not null, then end of sal from emp;

  • can 'build' a select statement by using a control of IF-ELSE?

    I need to create a stored procedure that accepts as pararmeter account number and status. If the status is 'A' for approved, so I want to return all price records in my table of prices for this account number, otherwise if the status is 'R' for the dismissal, I want to read data from a price change of queue, which has also the error code and description. If the status is null, then I want to send prices of the assets of the PRICE table AND rejected him to the Chronogram of the queue of price:

    Can I do something like this in PL/SQL?
    If param_status = 'A' or param_status is null THEN
       SELECT ACCT_NO, PRICE, EFFECTIVE_DATE, null, null
       FROM ACCOUNT
       where ACCT_NO = param_acct_no
    
    Elsif param_status = 'R' or param_status is null THEN
    
    UNION
       SELECT ACCT_NO, PRICE, ENTRY_DATE, ERR_CD, ERR_DESCRIPTION
       from PRICE_CHANGE_QUE
       where ACCT_NO = param_acct_no
           and  STATUS = 'R';
    END IF;
    I ', m using Oracle 11.2, and I plan to return the results as a cursor must be used in a .NET application.

    I need display all prices of ASSETS, or any REJECTED price, according to it if the status is sent on or not.

    Hello

    If you want an application that does it all:

    select  ACCT_NO, PRICE, EFFECTIVE_DATE, null,   null
    from      ACCOUNT
    where     ACCT_NO     = PARAM_ACCT_NO
    and     'A'     = nvl (:PARAM_STATUS, 'A')
         --
        union
         --
    select     ACCT_NO, PRICE, ENTRY_DATE,     ERR_CD, ERR_DESCRIPTION
    from     PRICE_CHANGE_QUE
    where     ACCT_NO = param_acct_no
    and       STATUS      = 'R'
    and     'R'     = nvl (:PARAM_STATUS, 'R')
    ;
    

    SQL is sufficient for this purpose; you needn't PL/SQL.

    It will probably be more effective to your .NET application so check param_status is 'A', 'R' or NULL first, then branch to one of the 3 most effective query.

    I hope that answers your question.
    If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
    Explain, using specific examples, how you get these results from these data.
    If the problem involves (for example param_status) parameters that are not in any table, and then after a few differetn sets of parameters and the results you want from the same sample for each game data.
    Always tell what version of Oracle you are using.
    See the FAQ forum {message identifier: = 9360002}

  • How to write a select statement inside the case operator

    Hi all

    I want to write a query that get the result of another table of case operator.

    for example

    Select a, b, c of the double
    where a = 1
    and b = case when b is null then 'select any value from the other table' any other purpose;


    Please help me to write this query.

    Thank you

    Select a, b, c of the double
    where a = 1
    and b = case when b is null then 'select any value from the other table' any other purpose;

    Guilty plea

    Select a, b, c from tableA a
    where a.a = 1
    and a.b = (select decode (a.b, null, (select 1 from tableB b where rownum = 1), a.b) double)

  • for j in (select one, c (select 1 of the double),) loop... end loop;... error

    declare
    begin
     for cur in (select (select 1 from dual) col from dual)
     loop
      null;
     end loop;
    end;
    TOAD, OK, BUT in the wrong FORM!

    Published by: indoracle on February 23, 2012 02:38

    Published by: indoracle on February 23, 2012 02:40

    As you may or may not know, the PL/SQL engine forms is not the same as that of the database; Forms is generally a lower version than the database. As for your code block, please try this instead:

    BEGIN
      FOR cur in ( SELECT col1 FROM ( SELECT 1 AS col1 FROM dual) ) LOOP
        NULL;
      END LOOP;
    END;
    

    This form of the loop For cursor to compile in 10.1.2 Forms. The problem was that the Forms PL/SQL engine could not derive your view online column.

    Hope this helps,
    Craig B-)

    If someone useful or appropriate, please mark accordingly.

  • create the table in SELECT (question)

    Hello

    In regards to create the table as subquery, I read that:

    The data type of column definitions and the NOT NULL constraint are passed to the new table. Note that only the explicit NOT NULL constraint is inherited. The PRIMARY KEY column will not function NOT NULL column null. Any other rule of constraint is not passed to the new table. However, you can add constraints in the column definition.

    Can someone explain to me how to do this? Or, how we need to specify the constraints (and also the default values for columns, because it is possible) for the columns in the column definition?

    In addition, I do not understand this: the PRIMARY KEY column will not function NOT NULL column zero.
    Can someone give me some small examples regarding these?
    For example, it generates an error:
    create table test1 (a, b, c default sysdate) 
    as 
    select 1, 'b' from dual
    Thank you!

    Edited by: Roger22 the 01.09.2011 11:37

    Hello

    When you set a primary key consists of a unique constraint and a constraint not null, but they are both implicit with the primary key. When you create the table because it will copy only the explicitly declared NOT NULL constraints so it isn't look upward than the implicit NOT NULL primary key.

    SQL> create table dt_pk
      2  (   id      number primary key,
      3      col1    number not null,
      4      col2    number
      5  )
      6  /
    
    Table created.
    
    SQL> desc dt_pk
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ID                                        NOT NULL NUMBER
     COL1                                      NOT NULL NUMBER
     COL2                                               NUMBER
    
    SQL> create table dt_pk2 as select * from dt_pk;
    
    Table created.
    
    SQL> desc dt_pk2;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ID                                                 NUMBER
     COL1                                      NOT NULL NUMBER
     COL2                                               NUMBER
    
    SQL> select constraint_name,constraint_type from user_constraints where table_name='DT_PK'
      2  /
    
    CONSTRAINT_NAME                C
    ------------------------------ -
    SYS_C006935772                 C
    SYS_C006935773                 P
    
    SQL> select constraint_name,constraint_type from user_constraints where table_name='DT_PK2'
      2  /
    
    CONSTRAINT_NAME                C
    ------------------------------ -
    SYS_C006935774                 C
    

    However, a primary key can reuse existing constraints and indexes instead of declaring new. For example, we can explicitly declare a constraint not null on the column id and then create a primary key. This means that we will now inherit the constraint not null in the ETG, as it has been explicitly declared and is a constraint separate in there own right that has been 'borrowed' by the pk constraint.

    SQL> create table dt_pk3 (id number not null, col1 number not null, col2 number);
    
    Table created.
    
    SQL> alter table dt_pk3 add constraint dt_pk3_pk primary key (id);
    
    Table altered.
    
    SQL> select constraint_name,constraint_type from user_constraints where table_name='DT_PK3'
      2  /
    
    CONSTRAINT_NAME                C
    ------------------------------ -
    SYS_C006935775                 C
    SYS_C006935776                 C
    DT_PK3_PK                      P
    
    SQL> create table dt_pk4 as select * from dt_pk3;
    
    Table created.
    
    SQL> desc dt_pk3;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ID                                        NOT NULL NUMBER
     COL1                                      NOT NULL NUMBER
     COL2                                               NUMBER
    
    SQL> desc dt_pk4;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ID                                        NOT NULL NUMBER
     COL1                                      NOT NULL NUMBER
     COL2                                               NUMBER 
    

    Regarding the definition of the default values, you must always specify the column in the select, but doing so means follow you the semantics of a default in a standard INSERT statement, i.e. you specified the column, you must provide a value, in which case even if the value is null, the default value will not be used. However, the new inserted rows where the column with the default value is not specified will revert to the default.

    SQL> create table test1 (a, b, c default sysdate)
      2  as
      3  select 1, 'b' from dual
      4  /
    create table test1 (a, b, c default sysdate)
                        *
    ERROR at line 1:
    ORA-01730: invalid number of column names specified
    
    SQL> create table test1 (a, b, c default sysdate)
      2  as
      3  select 1, 'b', null c from dual
      4  /
    select 1, 'b', null c from dual
                   *
    ERROR at line 3:
    ORA-01723: zero-length columns are not allowed
    
    SQL> create table test1 (a, b, c default sysdate)
      2  as
      3  select 1, 'b', cast(null as date) c from dual
      4  /
    
    Table created.
    
    SQL> select * from test1;
    
             A B C
    ---------- - ---------
             1 b
    
    SQL> insert into test1(a,b) values(2,'b');
    
    1 row created.
    
    SQL> select * from test1;
    
             A B C
    ---------- - ---------
             1 b
             2 b 01-SEP-11
    

    To create a constraint, you must list all columns without the data types and constraints list online.

    SQL> create table dt_cons (id number, col1 number, col2 number, constraint chk2 check(col2 IS NULL or col2>10))
      2  as select * from dt_pk3
      3  /
    create table dt_cons (id number, col1 number, col2 number, constraint chk2 check(col2 IS NULL or col2>10))
                          *
    ERROR at line 1:
    ORA-01773: may not specify column datatypes in this CREATE TABLE
    
    SQL> create table dt_cons (constraint chk2 check(col2 IS NULL or col2>10))
      2  as select * from dt_pk3
      3  /
    create table dt_cons (constraint chk2 check(col2 IS NULL or col2>10))
                         *
    ERROR at line 1:
    ORA-00904: : invalid identifier
    
    SQL> create table dt_cons (col2 constraint chk2 check(col2 IS NULL or col2>10))
      2  as select * from dt_pk3
      3  /
    create table dt_cons (col2 constraint chk2 check(col2 IS NULL or col2>10))
                          *
    ERROR at line 1:
    ORA-01730: invalid number of column names specified
    
    SQL> create table dt_cons (id,col1,col2 constraint chk2 check(col2 IS NULL or col2>10))
      2  as select * from dt_pk3
      3  /
    
    Table created.
    
    SQL> desc dt_cons
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     ID                                        NOT NULL NUMBER
     COL1                                      NOT NULL NUMBER
     COL2                                               NUMBER
    
    SQL> insert into dt_cons values(2,2,2);
    insert into dt_cons values(2,2,2)
    *
    ERROR at line 1:
    ORA-02290: check constraint (JJACOB_APP.CHK2) violated
    
    SQL> insert into dt_cons values(2,2,10);
    insert into dt_cons values(2,2,10)
    *
    ERROR at line 1:
    ORA-02290: check constraint (JJACOB_APP.CHK2) violated
    
    SQL> insert into dt_cons values(2,2,11);
    
    1 row created.
    
    SQL> insert into dt_cons values(2,2,null);
    
    1 row created.
    
    SQL>
    

    HTH

    David

  • Insert data from a particular region.

    I have two region report...

    I use apex item to insert data into a table. When I try to insert the data from the 2nd report region, region 1 data get insert instead of the 2nd region report data.

    How to distinguish the point of apex from one region to another region?

    This is my 2nd region (doc) report
    insert into doc values(apex_application.g_f02(i),apex_application.g_f03(i),apex_application.g_f04(i));
    How to solve this problem?

    SKUD.

    Hello

    Make sure that the columns of report 2 region should not have same value p_idx.
    Example-

    Report 1 query
    
    select apex_item.text(1 , null);
    
    Report 2 query
    
    select apex_item.text(1, null);
    

    In the example above if you see the both the query have same p_idx value in 1...

    In this case, if you try to save the data in the second report it will save the data in the first report.

    To avoid this, you must make sure that the p_idx value is different... This is... If you the first query has five columns with p_idx the value 1, 2, 3, 4, 5... so for next report make sure that the value of p_idx must be greater than 5... for example... 6, 7, etc.

    Kind regards
    Shijesh

  • display of the values of selected option buttons

    Hello

    It is an application that would allow users to go through a step-by-step process to build their product, in this case, it's ice cream.


    Description:

    There are six option buttons, four belonging to a radiobuttongroup and two others belonging to an another radiobuttongroup. In addition, there is a mx:TextArea (including the editable value false).

    This Panel will most likely go into a mx:ViewStack as a "first step" in the process of personalization of the ice cream. The selection of a radiobutton to every radiobuttongroup must be required to move forward (go to the next "step", as in the Panel following in the ViewStack).

    Problem:

    Allowing the user to select an item in each of the two radiobuttongroups and write values of these two selected radiobutton [such as specified by the value of the radiobutton = property 'radioButtonValue'] to the mx:TextArea, on different lines.

    I have been moderately successful in trying to do it, but I didn't know how to write two values in the same text box
    without crushing them each other.

    Misc.

    At first, I tried something to the effect of: ( changed from the 2 flex components Explorer)

    < mx:Script >
    <! [CDATA]

    Import mx.events.ItemClickEvent;

    Event handler function to display the selected button
    in a text box.
    private void handleConeType(event:ItemClickEvent):void
    {
    If (event.currentTarget.selectedValue is "sugarCone")
    {
    iceConeTextBox.text = "Sugar cône";
    }
    on the other
    {
    If (event.currentTarget.selectedValue is "waferCone")
    {
    iceConeTextbox.text = 'Wafer cone. "
    }
    }
    }
    }
    []] >
    < / mx:Script >
    Quite exaggerated to get something to work, I know. It was not very effective, and I sincerely hope that there are better ways to do this.

    I would like if possible avoid using two mx:textareas.

    Example of

    Here is a link to better describe what I'm talking about (Note: View Source is enabled).

    ConeChooser Application


    Thank you!

    You can access the selected radio button value the id of Group of radio button groups, you don't need to check each radio button individually. Then coneType.selectedValue will give you the value of a button radio is selected in the group, and the coneType.selection.label will give you the label of the currently selected option button or null if none is selected.

    Try this code:


    http://www.Adobe.com/2006/mxml '.
    Width = "100%" height = "100%" layout = "absolute" >

    private function updateText (): void {}
    var totalSelected:uint = 0;
    var cone: String = "";
    var size: String = "";
    If (coneType.selectedValue! = null) {}
    Cone = coneType.selection.label;
    totalSelected ++;
    }
    If (coneSize.selectedValue! = null) {}
    size = coneSize.selection.label;
    totalSelected ++;
    }
    iceConeTextBox.text = '\r', cone + size;
    If (totalSelected == 2) {}
    next_btn.enabled = true; to go to the next view in the viewstack
    }
    }
    ]]>

    horizontalCenter = red "0.5" = "0.5" layout = "absolute" >

    text = "Select your cone." y = "10" height = "44" fontSize = "25" horizontalCenter = "0" / >



    label = "Sugar Cone" width = "150" x = "2" y = "62" / >

    label = "Waffle Cone' width = '150' x '2' = y ="88"/ >

    label = 'Wafer cône' width = '150' x '2' = y = "114" / >

    label = "Chocolate dipped Wafer cone" width = "201" x = "2" y = "140" / >






    Vygo

  • How to select the default printer

    Hi all

    Here's the scenario:
    Report Version:2.5.5.2.7 (I know really old :) )
    Form Version: 4.5.7.1.6
    OS: Windows Xp with SP2
    Whenever the user clicks on the button PRINT an invoice form, the report should
    print directly without showing no preview (is a different button for preview).
    I choose the number of copies that must be printed in a table in DB.
    Make a list of parameter (for destype, desname, copies, etc.) and call the report. (RUN_PRODUCT)
    It is if I take the name of the printer to DB something like \\machine_name\printer_name and assign it to desname, it works very well.
    However, instead of picking it from the DB, I want to know if I can get the default name of the printer directly from the machine where the report is running.

    Reason: If a printer goes wrong and the user wants to print to a different printer, I don't have to keep on changing the values in the comic book.

    All entries/tracks will be appreciatted.

    Thank you
    Bobin

    P.S : I bestow points like cookies ;)

    Hi Buqa,
    Nice to see you in the forum reports ;) if I saw you in the forum of pl/sql.

    In fact if you want to print to the default printer. Then just the DESTYPE PRINTER setting there. The report will go directly to the default printer and if you mention the DESNAME then it will go to the selected printer you. I mean if the printer selected, you'll pass null, then you can just move the DESTYPE then report will go directly to the default printer.

    By NOTHING, I mean not to pass the parameter in the case of the DEFAULT PRINTER.

    -Clément

  • Select a specific empty data type variable in a view

    Hello

    I'm creating a view

    SELECT id, seq, null createdate-> need for it to be of data type, null-> need qty is data from table1 number type


    -where table1 has only id & seq and I don't want to create these new 2 fields in the table

    is there a way?

    pls advise

    SELECT id, seq, null createdate--> need is the data type, no Qty

    select id , seq , cast(null as date) createdate, cast(null as number) qty ...
    

Maybe you are looking for

  • WX558AV: HP EliteBook 8460p Notebook PC driver issues

    Operating system: Windows 7 Ultimate Service Pack 1 Has decided to change the laptop computers by copying of old laptop to drive hard usb to the new laptop. I plugged my drive hard usb, but windows does not recognize it. Then I looked in the Device M

  • Reset send # listed on the login screen

    on my user Windows XP screen of choice for the connection, under my name is a note that says that I have 1 unread email message. I clicked it to see what it is, and that's the one I set up in Outlook 2003 (only). There is no emails unread in my Inbox

  • Vista are no longer updated correctly?

    as of last June my Dell Inspiron 1720 with Vista was having this problem http://answers.microsoft.com/en-us/windows/forum/windows_vista-system/vista-freezes-as-user-login-screen-boots/ace639e6-d663-428c-ab98-4b664d3cc66e Recently, a new type of lock

  • WHENEVER I TRY TO WATCH A VIDEO IT FREEZES ALL OTHER SENCOND

    FREEZES TOO

  • Computer does not connect to any network anywhere.

    I have a computer that I can't connect to any wireless network. I have a Linksys router that already has my main computer, a laptop, PS3 and a wii connected but this laptop just easy to store. It was, essentially, that across the Canada but do not pi