Question on dual table..

after i insert another row into dual table,
SQL*PLUS still returns only one row. But PL/SQL Developer returns 2 rows.
What does SQL*PLUS do to return only one row no matter many rows exist in DUAL table?

http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:1562813956388

Similar Messages

  • Silly question on dual table

    Hello gurus
    This dual table is a dummy table with varchar2(1)....my question is how it can select many psedocolumns from dual doesn't it exceed the allowed space of varchar2(1)
    Edited by: 964145 on Oct 9, 2012 5:35 PM

    >
    it cannot be a real table
    >
    Not sure why you say that.
    The DDL for it is in the dcore.bsq file (11.2) in the rdbms/admin folder
    create table dual    /* pl/sql's standard pckg requires dual. */
      (dummy varchar2(1))    /* note, the optimizer knows sys.dual is single row */
      storage (initial 1)
    insert into dual values ('X')
    /See the SQL Language doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28286/queries009.htm#SQLRF20036
    >
    Selecting from the DUAL Table
    DUAL is a table automatically created by Oracle Database along with the data dictionary. DUAL is in the schema of the user SYS but is accessible by the name DUAL to all users. It has one column, DUMMY, defined to be VARCHAR2(1), and contains one row with a value X. Selecting from the DUAL table is useful for computing a constant expression with the SELECT statement. Because DUAL has only one row, the constant is returned only once. Alternatively, you can select a constant, pseudocolumn, or expression from any table, but the value will be returned as many times as there are rows in the table. Refer to "About SQL Functions" for many examples of selecting a constant value from DUAL.
    >
    And the Database Concepts doc
    http://docs.oracle.com/cd/B28359_01/server.111/b28318/datadict.htm
    >
    The DUAL Table
    The table named DUAL is a small table in the data dictionary that Oracle Database and user-written programs can reference to guarantee a known result. This table has one column called DUMMY and one row containing the value X.
    >
    And those pseudo-columns you ask about
    >
    select sysdate,UID,rowid from dual;
    >
    You can query those from any table but as the doc quote above says you will get as many values as there are rows in the table.

  • Question about dual table

    Hi,
    Can anyone clarify me this
    Can I insert rows into dual table (being a programmer) ?? Using oracle 9i ... If no, can DBA do that ??? Say suppose, I have inserted 100 records in the dual table .. In any way, my applications are going to get hampered after inserting the records in the dual table
    Regards

    Or perhaps this:
    SQL> SELECT * FROM
      2  ( select rownum from dual connect by rownum <= 10 );
        ROWNUM
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.In 9i at least you most certainly can insert into sys.dual, which is a regular table in the SYS schema, although you deserve all you get if you do so:
    /Users/williamr: su - oracle
    Password:
    /Users/oracle: sqlplus '/ as sysdba'
    SQL*Plus: Release 9.2.0.1.0 - Developer's Release on Fri Mar 10 19:21:45 2006
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Developer's Release
    With the Partitioning and Oracle Data Mining options
    SQL> SELECT COUNT(*) FROM sys.dual;
      COUNT(*)
             1
    1 row selected.
    SQL> INSERT INTO dual VALUES ('Z');
    1 row created.
    SQL> SELECT COUNT(*) FROM sys.dual;
      COUNT(*)
             2
    1 row selected.
    SQL> set serverout on
    SQL> EXEC DBMS_OUTPUT.PUT_LINE(user);
    BEGIN DBMS_OUTPUT.PUT_LINE(user); END;
    ERROR at line 1:
    ORA-01422: exact fetch returns more than requested number of rows
    ORA-06512: at "SYS.STANDARD", line 264
    ORA-06512: at line 1
    SQL> roll
    Rollback complete.
    SQL> EXEC DBMS_OUTPUT.PUT_LINE(user);
    SYS
    PL/SQL procedure successfully completed.
    SQL> So it is technically possible, but monumentally inadvisable to mess about with sys.dual.
    For a rather surreal suggestion related to this scenario, see:
    oracle-wtf.blogspot.com/2006/03/create-your-own-dual-table.html

  • Dual table in 10g

    Hi!
    1 am using forms 6.
    my forms were running good but after i take my application to 10g, some forms have not been compiling.
    in every form where dual table has been referenced error has come, remaining forms run well
    like
    select sysdate
    into l_Date
    from dual
    if in form i use sys.dual then it works
    in sql plus i can select using select * from dual
    is this a bug or any other problem?
    thanx

    error has comeGive us a clue. What error? Please post error number and message or at least describe the behaviour.
    Also, this is primarily a database forum. As your queries run in SQL*Plus it strikes me this is most likely to be a problem with Forms, and so you may be better off trying the OTN > Products > Developer Suite > Forms forum. Unlike this forum, actual Oracle employees answer questions there, so it's definitely a better bet.
    Are you using Forms 6 or 6i? Forms 6 is de-supported and so may not play nicely with 10g. 6i is supported and either is or will be certified to run against 10g.
    Cheers, APC

  • How to return number range from sql (dual table)

    in sql plus
    I need to display values (numbers)1 to 52 from dual
    eg,
    1
    2
    3
    4
    5
    etc...
    Is this possible, can you display a range of numbers from an sql statment without creating atble holding the required numbers.
    I am trying to display 1 to 52 (week numbers) but I need to do this from the dual table.
    Creating a table with values 1 to 52 looks like a waste?
    Thanks in anticipation.
    SD.

    If you're running on 9i you may find the solution I posted Re: List all days of a month in single SQL to be useful. Otherwise the general discussion will provide some illumination.
    Cheers, APC

  • Doubt in DUAL TABLE

    Hi,
    below is one query
    SQL> select * from dual;
    D
    XNow from the below Query I came to know that there is one field in the dual table DUMMY which is having VARCHAR2(1)
    SQL> desc dual;
    Name                                                  Null?    Type
    DUMMY                                                          VARCHAR2(1)now my doubt is when I run the below query how it is displaying text more than 1 character
    SQL> select 'how are you' from dual;
    'HOWAREYOU'
    how are youplease explain
    thanks in advance.

    Hi,
    What you are SELECTing here nas no relation to any column in the table.
    There's nothing special about the dual table regarding literals. Try
    SELECT  'Hello'
    FROM    scott.dept;Notice that scott.dept does not have any 5-character columns, yet a query on scott.dept is producing a 5-character column.
    When you query a table, you don't have to SELECT all of the columns in the table. In fact, you don't have to SELECT any of the columns in the table, as you demonstrated.
    The query you posted, like the query above, does not refer to any columns in its base table; it's not surprising that the output doesn't resemble any column in the base table. In the case of the query above, which is based on a table that has 3 columns, the one column that we are SELECTing can't have the characteristics of all 3 columns in the table. Which column do you think the output should resemble, and why? 'Hello' is the first column of output; does that mean it has to resemble the first column in the table, which happens to be defined as NUMBER (2)? 'Hello' is also the last column of output; does that mean it has to resemble the last column of the table? 'Hello' is directly in the center of the output; does that mean it has to resemble the column that happens to be in the middle of the table? Of course not!
    Once agian, it is perfectly legal, and sometimes extremely useful, to have columns in a result set that have no connection at all to any column in the table.

  • Select multiple rows from dual table

    Is it possible to select multiple rows from dual table using a single select statement.
    i.e., i want the out put to be
    column_name
    1
    2
    3
    4
    Edited by: vidya.ramachandra on Dec 14, 2009 8:24 AM

    Aside from the fact you're responding to an old thread...
    1002424 wrote:
    While using CONNECT BY, I see it always leave behind one row.
    Suppose I have a condition based on which I have to generate constant rows like
    SELECT 1 FROM DUAL WHERE ROWNUM < N;
    Here if N = 0, still it gives out single row.... you are obviously doing something wrong in your code elsewhere, because that SQL statement does not always return a single row...
    SQL> SELECT 1 FROM DUAL WHERE ROWNUM < 0;
    no rows selected
    SQL>

  • DUAL Table problem

    As a quick way to grant privileges to almost all the objects in my schema to a role, i created a procedure (Courtesy of user CD from Oracle Forums). But when i executed the below mentioned procedure i got the error :
    ORA-01720: grant option does not exist for 'SYS.DUAL'
    To avoid granting privileges to sys.dual, I tried adding AND OBJECT_NAME < > 'SYS.DUAL' and AND OBJECT_NAME < > 'DUAL' to the query. But that this didn't help.
    But when i query SELECT * FROM DUAL; i can see that DUAL table exists in my schema.
    Any thoughts?
    Here is what i did
    CREATE ROLE newrole;
    DECLARE
    v_sql VARCHAR2(4000);
    BEGIN
    FOR obj IN (SELECT object_name
    , object_type
    , DECODE (OBJECT_TYPE,
    'PROCEDURE','EXECUTE',
    'FUNCTION' ,'EXECUTE',
    'PACKAGE' ,'EXECUTE',
    'SYNONYM' ,'SELECT' ,
    'SEQUENCE' ,'SELECT' ,
    'MATERIALIZED VIEW','SELECT',
    'SELECT, INSERT, UPDATE, DELETE') rights
    FROM user_objects where object_type IN
    ('FUNCTION','PROCEDURE','PACKAGE','SYNONYM','SEQUENCE','MATERIALIZED VIEW','TABLE','VIEW'))
    LOOP
    v_sql := 'GRANT ' || obj.rights || ' ON ' || obj.object_name || ' TO NEWROLE';
    dbms_output.put_line(v_sql);
    EXECUTE IMMEDIATE v_sql;
    END LOOP;
    END;
    /

    One of your views must reference DUAL, perhaps indirectly.
    If this comes up again you can create an exception to catch the error inside the loop for the current item and continue. Not pretty, but it should work something like (untested)
      for record in cursor loop
        --block to catch exception
        declare
           my_error exception;
          --substitute proper error number for -000001 below
          pragma exception_init(-000001,my_error)
        begin
        exception
          when my_error then
            null;
        end;
        --continue processing with next loop item   
      end loop;

  • Sql query and dual table

    Hi,
    1. Do dual table take any physical space in the database or it is only logically present?
    2. Suppose a table contains 100 rows. Write a query to return 42,43,44 rows.
    Thanks,
    Mrinmoy

    user3001930 wrote:
    Hi,
    1. Do dual table take any physical space in the database or it is only logically present?Dual table is physically stored. But starting from 10g (I guess) they indroduced the FAST DUAL access path. Which means if you use the DUAL table not to get the value from the table and only to select a constant value then it will not hit the actually table.
    2. Suppose a table contains 100 rows. Write a query to return 42,43,44 rows.You can use the analytic function ROW_NUMBER for this purpose.

  • How to generate multiple records on a single sql from dual table

    I wanted to generate ten sequence nos in a single sql statement from dual table.
    Is there any way to use that.
    I think somebody can help me on this by using level clause

    I'm not 100% sure if I understand your requirement: Do you really want to use an Oracle Sequence, as Alex already demonstrated?
    Or just a 'one-time-bunch-of-sequential-numbers'.
    In the latter case you can just select level:
    SQL> select level
      2  from   dual
      3  connect by level <= 10;
         LEVEL
             1
             2
             3
             4
             5
             6
             7
             8
             9
            10
    10 rows selected.

  • Use of addImageTheme method with dual table in query

    Is it possible to specify a query using the dual table that specifies a BLOB type? I'm trying to specify a image theme dynamically using the bean API. My image is a JPEG.

    Hi Jen,
    if you create a table with a BLOB to store the image, plus a geometry column with the image MBR, then you can easily build the dynamic image theme using the API. Your SQL on the image theme would be something like: select mbr, image from image_table.
    I'm not sure if there is a direct function at the SQL level that takes an image file and generates a BLOB. Maybe someone has done something similar. If this function exists, then you may be able to create an image theme issuing a SQL with dual table.
    Joao

  • [Solved]SIMPLE Question ON "CREATE TABLE as SELECT".

    Hi there,
    I was wondering how to work it out smartly and briefly.
    For example, I already have a "tableA" as following.
    tableA
    id name
    1 name1
    2 name2
    create table tmp as
    select id, name from tableA;
    It will create the tmp table successfully.
    If I want to add a new column 'tel' in tmp table,
    I can run as following.
    create table tmp as
    select id, name, 999 tel, 'aaaaaaaaa' ps from tableA;
    It will add 'tel NUMBER' column and 'ps char(9)' in tableA.
    If I want to add 'col varchar(50)' in tableA,
    I do not want to make a string which contains 50 characters in Select command.
    How can I make it work in a smart way?
    Thanks.
    Phil
    Message was edited by:
    user615355

    Is there a reason that you need this to be in a single statement? You would normally be better served here with a separate CREATE TABLE and INSERT (possibly as a direct path operation).
    That said, you could use the CAST operator, i.e.
    SCOTT @ jcave102 Local> create table a as select cast('a' as varchar2(50)) col1 from dual;
    Table created.
    Elapsed: 00:00:00.48
    SCOTT @ jcave102 Local> desc a;
    Name                                                  Null?    Type
    COL1                                                           VARCHAR2(50)
    SCOTT @ jcave102 Local> Justin

  • Question on using table types in methods

    Hi
       I have a simple question involving passing table types in method
    I want to pass an internal table by reference - to a method and within the method populate the internal table (t1) using a select * into the internal table and then sort t1 by f1 and f2. t1 is an internal table based on a ABAP dictionary table ( at1 )
    Question is : If I use a generic type TABLE declaration , it does not allow sort operation specifically by fields. If I use type at1 as in
    the METHODS M1 exporting t1 type at1statement, syntax error is - t1 is not an internal table.
    How do I achieve the above using the method implementation ?
    Sample code that I try
    CLASS C1 DEFINITION
    PUBLIC SECTION
    METHODS M1 exporting t1 type table
    ENDMETHOD
    ENDCLASS
    CLASS C1 IMPLEMENTATION
    METHOD M1
    select * from at1 into t1.
    sort t1 field f1 f2
    ENDCLASS

    You should define a TABLE TYPE based upon the data dictionary type (at1) either in the data dictionary using SE11 or in the TYPES section of the class.
    Then define the parameter of this new type.
    Cheers
    Graham Robbo

  • Avoid Hard Parsing for executing dynamic SQL using DUAL table Oracle

    I want to know if dynamic sql statements involving DUAL table can be modified to remove HARD PARSING.
    We have several SQL statements are stored in configuration table, here is sample example
    -- query 1 before replacing index values as stored in config table ---
    select count(*) from dual where  'REPLACE_VALUE_OF_INDEX_3' IN ('K')
    AND (('REPLACE_VALUE_OF_INDEX_13' IN ('1053','1095','1199') ) OR ('REPLACE_VALUE_OF_INDEX_13' IN ('1200') ))
    AND 'REPLACE_VALUE_OF_INDEX_2' IN ('6')
    AND 'REPLACE_VALUE_OF_INDEX_15' IN ('870001305')
    -- query 1 after replacing index values--
    select count(*) from dual where  'REPLACE_VALUE_OF_INDEX_10' IN ('K')
    AND (('1030' IN ('1053','1095','1199') ) OR ('1030' IN ('1200') ))
    AND '2' IN ('6')
    AND 'X' IN ('870001305')
    -- query 2 before replacing index values as stored in config table --
    select count(*) from dual where  'REPLACE_VALUE_OF_INDEX_5' IN ('361A','362A')
    AND 'REPLACE_VALUE_OF_INDEX_22' BETWEEN '200707' AND '200806'
    -- query 2 after replacing index values--
    select count(*) from dual where  '3MAA' IN ('361A','362A') AND '201304' BETWEEN '200707' AND '200806'

    If I got it right you have some (maybe lots of) conditions stored in a table (be patient - it's my interpretation)
    create table eb_conditions as
    select 1 rid,q'{:5 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'}' cndtn from dual union all
    select 2,q'{:2 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'}' from dual union all
    select 3,q'{:1 IN ('K') AND ((:2 IN ('1053','1095','1199') ) OR (:4 IN ('1200') )) AND :3 IN ('6') AND :5 IN ('870001305')}' from dual
    RID
    CNDTN
    1
    :5 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'
    2
    :2 IN ('361A','362A') AND :3 BETWEEN '200707' AND '200806'
    3
    :1 IN ('K') AND ((:2 IN ('1053','1095','1199') ) OR (:4 IN ('1200') )) AND :3 IN ('6') AND :5 IN ('870001305')
    and you have to check the conditions using values stored in an array
    I used a table instead: the vl at rid = 1 representing the value of bind variable :1 in eb_conditions table and so on ...
    create table eb_array as
    select 1 rid,'K' vl from dual union all
    select 2,'1199' from dual union all
    select 3,'200803' from dual union all
    select 4,'1000' from dual union all
    select 5,'870001305' from dual
    RID
    VL
    1
    K
    2
    1199
    3
    200803
    4
    1000
    5
    870001305
    You want to check the conditions using select count(*) from dual where <condition with binds substituted fron the array>
    Judging from the title Hard Parsing represents the major problem and you cannot avoid it since every condition to be verified is different from every other condition.
    I think your best bet is not to evaluate conditions row by row - context shift cannot be avoided and there might be more than one for each iteration.
    So try to do it in a single step:
    declare
    w_cndtn varchar2(4000);
    w_clob  clob;
    w_cursor sys_refcursor;
    one number;
    two number;
    begin
      dbms_lob.createtemporary(w_clob,false);
      for rw in (select rid,
                        max(cndtn) cndtn,
                        listagg(val,',') within group (order by rn)||',' usng
                   from (select c.rid,c.cndtn,c.rn,c.bind,
                                replace(rtrim(c.bind),':'||to_char(v.rid),''''||v.vl||'''') val
                           from (select rid,
                                        cndtn,
                                        regexp_substr(cndtn,':\d+ ',1,level) bind,
                                        level rn
                                   from eb_conditions
                                 connect by level <= regexp_count(cndtn,':')
                                        and prior rid = rid
                                        and prior sys_guid() is not null
                                ) c,
                                eb_array v
                          where instr(c.bind,':'||v.rid||' ') > 0
                  group by rid
      loop
        w_cndtn := rw.cndtn;
        while instr(w_cndtn,':') > 0
        loop
          w_cndtn := replace(w_cndtn,trim(regexp_substr(w_cndtn,':\d+ ',1,1)),substr(rw.usng,1,instr(rw.usng,',') - 1));
          rw.usng := substr(rw.usng,instr(rw.usng,',') + 1);
        end loop;
        w_cndtn := 'select '||to_char(rw.rid)||' cndtn_id,count(*) from dual where '||w_cndtn||' union all ';
        w_clob := w_clob ||' '||w_cndtn;
      end loop;
      w_clob := substr(w_clob,1,instr(w_clob,'union all',-1,1) - 1);
      open w_cursor for w_clob;
      loop
        fetch w_cursor into one,two;
        exit when w_cursor%notfound;
        dbms_output.put_line(to_char(one)||':'||to_char(two));
      end loop;
      dbms_lob.freetemporary(w_clob);
    end;
    1:0
    2:0
    3:0
    Statement processed.
    Regards
    Etbin

  • How to use dual table in ODI in source side for nested queries?

    Hi,
    Any idea how to use dual table in source for more than once. I want to build a ODI interface for the following source query
    SELECT ACTV_TYP.ACTV_TYP_SRC_CD, ACTV_TYP.ACTV_TYP, PORT_ACTV_TYP.PORT_ACTV_TYP_SRC_CD, PORT_ACTV_TYP.PORT_ACTV_TYP, SFT_DLT_STS.SFT_DLT_STS_SRC_CD, SFT_DLT_STS.SFT_DLT_STS
    FROM
    SELECT LOW_VALUE PORT_ACTV_TYP_SRC_CD, MEANING PORT_ACTV_TYP
    FROM CUSTOMS.DOMAIN_ALLOW_COLUMNS_VALUES
    WHERE TABLE_NAME = 'BRKR_PORTS'
    AND COLUMN_NAME = 'WORK_PORT_TYPE') PORT_ACTV_TYP,
    (SELECT LOW_VALUE SFT_DLT_STS_SRC_CD, MEANING SFT_DLT_STS
    FROM CUSTOMS.DOMAIN_ALLOW_COLUMNS_VALUES
    WHERE TABLE_NAME = 'BANKS'
    AND COLUMN_NAME = 'REC_STATUS') SFT_DLT_STS,
    (SELECT 1 ACTV_TYP_SRC_CD, '?????' ACTV_TYP FROM DUAL
    UNION ALL
    SELECT 2 ACTV_TYP_SRC_CD, '???????' ACTV_TYP FROM DUAL) ACTV_TYP
    Regards

    If the below query is equivalent , it seems you don't need dual table at all , just default the values in the interface.
    You are using dual tables to populate values ACTV_TYP.ACTV_TYP_SRC_CD, ACTV_TYP.ACTV_TYP values. Look at your query in the following manner :
    SELECT '1', '?????', PORT_ACTV_TYP.PORT_ACTV_TYP_SRC_CD, PORT_ACTV_TYP.PORT_ACTV_TYP, SFT_DLT_STS.SFT_DLT_STS_SRC_CD, SFT_DLT_STS.SFT_DLT_STS
    FROM
    SELECT LOW_VALUE PORT_ACTV_TYP_SRC_CD, MEANING PORT_ACTV_TYP
    FROM CUSTOMS.DOMAIN_ALLOW_COLUMNS_VALUES
    WHERE TABLE_NAME = 'BRKR_PORTS'
    AND COLUMN_NAME = 'WORK_PORT_TYPE') PORT_ACTV_TYP,
    (SELECT LOW_VALUE SFT_DLT_STS_SRC_CD, MEANING SFT_DLT_STS
    FROM CUSTOMS.DOMAIN_ALLOW_COLUMNS_VALUES
    WHERE TABLE_NAME = 'BANKS'
    AND COLUMN_NAME = 'REC_STATUS') SFT_DLT_STS
    UNION
    SELECT 2 , '??????', PORT_ACTV_TYP.PORT_ACTV_TYP_SRC_CD, PORT_ACTV_TYP.PORT_ACTV_TYP, SFT_DLT_STS.SFT_DLT_STS_SRC_CD, SFT_DLT_STS.SFT_DLT_STS
    FROM
    SELECT LOW_VALUE PORT_ACTV_TYP_SRC_CD, MEANING PORT_ACTV_TYP
    FROM CUSTOMS.DOMAIN_ALLOW_COLUMNS_VALUES
    WHERE TABLE_NAME = 'BRKR_PORTS'
    AND COLUMN_NAME = 'WORK_PORT_TYPE') PORT_ACTV_TYP,
    (SELECT LOW_VALUE SFT_DLT_STS_SRC_CD, MEANING SFT_DLT_STS
    FROM CUSTOMS.DOMAIN_ALLOW_COLUMNS_VALUES
    WHERE TABLE_NAME = 'BANKS'
    AND COLUMN_NAME = 'REC_STATUS') SFT_DLT_STS
    Now you can use dataset to make UNION.

Maybe you are looking for

  • I made changes to songs on my iPod 4G through iTunes, but the changes do not show up on my iPod.What is the problem?

    I have the iTunes program for Windows. Last night I upgraded my 4th generation iPod touch to the ios 5 software, which wiped out all my music. I put some of the music back on my ipod after it was restored, but then I tried changing the song informati

  • Substitute an apostrophe in a String class

    I've spent two days on this problem so I figure it's time to drop the "trial and error" and get an answer. I am building an employee directory on which a tooltip will display the employee's name and 3 phone numbers. The data will be formatted in the

  • Idoc LOISTD01 to JDBC

    Hello, I've a interface IDOC to JDBC, I need update_insert into table of database. My problem is a mapping with IDOC LOISTD01. Structure of IDOC E1PLSEL 1..unbounded      E1MDPSL 1.. unbounded Structure table of database mt_database   STATEMENT     

  • HP 8530w - SSD not detected

    Hello, Recently I managed to get an SSD from work, namely the A-Data S596 (500 SERIES). When putting it into my HP Elitebook 8530w, the disk was not detected. I have already upgraded the BIOS to the newest version. The SSD's firmware has also recentl

  • How to see the current drill-level?

    Hello, I want to apply some conditional formating on a report with drill-down function, depending on the drill-level of the report. Question: How can I determine on which level the user currently is in order to apply my formating? Thank you Turalf