Number of tables in from clause

Hi,
Can anyone tell me how many number of tables can we have in from clause in oracle.

Over 800 so far without any error. :)
But boy does it run slow :(
select 1 from
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,
dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual,dual

Similar Messages

  • Sequence of tables in from clause and sequence of "where clause" conditions

    Is Sequence of tables in "From Clause" and sequence of "where clause" conditions matters in 10g for performance?
    Edited by: user6763079 on Jun 1, 2011 3:33 AM

    user6763079 wrote:
    Is Sequence of tables in "From Clause" and sequence of "where clause" conditions matters in 10g for performance?In general it does not matter.
    It could matter if the Rule Based Optimizer (RBO) is used. However this RBO is only used if enforced by a hint or if no table statistics are collected. Starting from 10g the table statistics are automatically selected by a regular database job. So in general the CBO would be used.
    The CBO will consider different access paths. If the number of tables is low enough, then all possible combinations are considered and the order does not make any difference.
    Edited by: Sven W. on Jun 1, 2011 4:00 PM

  • How to change tables in from  clause dynamically

    Hi,
    I have to add some join conditions in where clause and tables in from clause based on some input parameters and data in other tables.
    How can i achieve this ? I must use procedure/function or dynamic query preparation or any more alternatives?
    Regards,
    Krishna

    Yes, you can use dynamic sql for that.
    But be aware that you'll be needing to concatenate the table names in your FROM-clause, you cannot bind them...
    So you'll be trashing the shared pool.
    Maybe alternative approaches are possible, but you provide too little input for my crystal ball here...

  • Query results varying with unused table in from clause

    Hi all,
    I have table (processing_table2) specified in the FROM clause of SQL query but I havent used any of its value in the SQL statement but it still affects the results of the query. Please help me here as i am clueless.
    Below is the query provided
    SELECT SUM((CREV.sadc_extd*CSSP.redit_pcnt)/100)
    FROM revenue_lines crev,
    sales_split cssp,
    processing_table2
    WHERE crev.order_num='7631090072'
    Results of the above query : 344028065018.359
    SELECT
    SUM((CREV.sadc_extd*CSSP.redit_pcnt)/100)
    FROM revenue_lines crev,
    sales_split cssp
    WHERE crev.order_num='7631090072'
    Results of the above query :26463697309.1046
    Some one suggest me here pls !!!!

    924804 wrote:
    Hi all,
    I have table (processing_table2) specified in the FROM clause of SQL query but I havent used any of its value in the SQL statement but it still affects the results of the query. Please help me here as i am clueless.
    Below is the query provided
    SELECT SUM((CREV.sadc_extd*CSSP.redit_pcnt)/100)
    FROM revenue_lines crev,
    sales_split cssp,
    processing_table2
    WHERE crev.order_num='7631090072'
    Results of the above query : 344028065018.359
    SELECT
    SUM((CREV.sadc_extd*CSSP.redit_pcnt)/100)
    FROM revenue_lines crev,
    sales_split cssp
    WHERE crev.order_num='7631090072'
    Results of the above query :26463697309.1046
    Some one suggest me here pls !!!!CARTESIAN PRODUCT changes result set

  • CBO and FROM clause

    hi,
    is the concept of ordering of tables in FROM clause still valid for CBO.
    I mean the concept of oracle selecting the driving table based on the positions of table in FROM clause still valid??
    If yes, then how should the tables be placed? the one with least rows in the end of from clause??
    Also is it better to leave to CBO or put a /*+ORDER */ hint??because additional time will be wasted by CBO in collecting stats??
    Any authentic document which speaks about optimization techniques??( i mean SQL tuning rules)
    s
    Message was edited by:
    user571638

    When I started, my focus was also on SQL tuning rules but I found out that this was not the most efficient way to tune performance. You can save a lot of time on performance tuning when you let the CBO work for you:
    http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14211/toc.htm

  • Is it possible to create a view where table in the From clause changes name

    is it possible to create a view from a from a table like this
    create view my_view as select id, col1, col2, result from <<my_latest_cacahe_table>>;
    the table in the from clause changes the name .
    I have another table which indicates the the latest name of my cache tables. Always there are two records there. The latest one and previous one.
    select * from cache_table_def
    table_name cache_table_name refresh_date
    my_table cache_table245 1/23/2012
    my_table cache_table235 1/22/2012
    create table cache_table_def (table_name varchar2(25), cache_table_name varchar2(25), refresh_date date);
    insert into cache_table_def values( 'my_table','cache_table245','23-jan-2012');
    insert into cache_table_def values ( 'my_table','cache_table546','22-jan-2012');
    create table cache_table245 (id number, col1 varchar2(50), col2 varchar2(20), result number);
    insert into cache_table245 values(1, 'test123', 'test345',12.12);
    insert into cache_table245 values (2, 'test223', 'test245',112.12);
    create table cache_table235 (id number, col1 varchar2(50), col2 varchar2(20), result number);
    insert into cache_table235 values (1, 'test123', 'test345',92.12);
    insert into cache_table235 values (2, 'test223', 'test245',222.12);
    what I need to do is find the latest cache_table name for my_table and use that in my view defintion
    When user select from the the view it always reurns the data from the latest cache_table
    is it possible to do something like this in oracle 11g?
    I have no control on the cache tables names. that is why I need to use the latest name from the table.
    Any ideas really appreciated.

    I've worked up an example that does what you ask. It uses the SCOTT schema EMP table. Make two copies of the EMP table, EMP1 and EMP2. I deleted dept 20 from emp1 and deleted dept 30 from emp2 so I could see that the result set really came from a different table.
    -- create a context to hold an environment variable - this will be the table name we want the view to query from
    create or replace context VIEW_CTX using SET_VIEW_FLAG;
    -- create the procedure specified for the context
    - we will pass in the name of the table to query from
    create or replace procedure SET_VIEW_FLAG ( p_table_name in varchar2 default 'EMP')
      as
      begin
          dbms_session.set_context( 'VIEW_CTX', 'TABLE_NAME', upper(p_table_name));
      end;
    -- these are the three queries - one for each table - none of them will return data until you set the context variable.
    select * from emp where 'EMP' = sys_context( 'VIEW_CTX', 'TABLE_NAME' );
    select * from emp1 where 'EMP1' = sys_context( 'VIEW_CTX', 'TABLE_NAME' );
    select * from emp2 where 'EMP2' =  sys_context( 'VIEW_CTX', 'TABLE_NAME' )
    -- this is how you set the context variable depending on the table you want the view to query
    exec set_view_flag( p_table_name => 'EMP' );
    exec set_view_flag( p_table_name => 'EMP1' );
    exec set_view_flag( p_table_name => 'EMP2');
    -- this will show you the current value of the context variable
    SELECT sys_context( 'VIEW_CTX', 'TABLE_NAME' ) FROM DUAL
    -- this is the view definition - it does a UNION ALL of the three queries but only one will actually return data
    CREATE VIEW THREE_TABLE_EMP_VIEW AS
    select * from emp where 'EMP' = sys_context( 'VIEW_CTX', 'TABLE_NAME' )
    union all
    select * from emp1 where 'EMP1' = sys_context( 'VIEW_CTX', 'TABLE_NAME' )
    union all
    select * from emp2 where 'EMP2' =  sys_context( 'VIEW_CTX', 'TABLE_NAME' )
    -- first time - no data since context variable hasn't been set yet
    SELECT * FROM THREE_TABLE_EMP_VIEW
    -- get data from the EMP table
    exec set_view_flag( p_table_name => 'EMP' );
    SELECT * FROM THREE_TABLE_EMP_VIEW
    -- get data from the EMP2 table
    exec set_view_flag( p_table_name => 'EMP2');
    SELECT * FROM THREE_TABLE_EMP_VIEW
    For your use case you just have to call the context procedure whenever you want to switch tables. You can union all as many queries as you want and can even put WHERE clause conditions based on other filtering criteria if you want. I have used this approach with report views so that one view can be used to roll up report data different ways or for different regions, report periods (weekly, quarterly, etc). I usually use this in a stored procedure that returns a REF CURSOR to the client. The client requests a weekly report and provides a date, the procedure calculates the START/END date based on the one date provided and sets context variables that the view uses in the WHERE clause for filtering.
    For reporting it works great!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • CAN I PASS A TABLE NAME AS A VARIABLE IN THE FROM CLAUSE?

    For some reason, I am trying to use a variable name containing the actual table name in the from clause and it won't allow me. I keep getting the error saying I need to declare the variable I'm using eventhough I've used it in another statement that is not the FROM clause.
    Example
    SELECT count(col1), sum(col2)
    FROM v_table_name;
    v_table_name was declared as:
    v_tablename VARCHAR2(20);
    v_tablename := real_table_name;
    Is it not allowed to use variables in the FROM clause or am I missing something here?

    You can use the Forms "From Clause Query" as the datasource for the data block. Then you can change the QUERY_DATA_SOURCE_NAME using set_block_property, so you can use any SQL statement you like. Of course you must name/alias the columns in a consistent manner so that the number of database items on the block matches those being queried.

  • Can't get query to work.  table alias in subquery in FROM clause

    How can I rearrange this query to work?
    SELECT
                               TO_CHAR(dt.date_time, 'YYYY-MM-DD') start_date,
                                       (SELECT COUNT(*) FROM
                                            (SELECT DISTINCT a.non_asp, a.start_time, a.end_time
                                                  FROM appointments a
                      WHERE  a.start_time >= dt.date_time AND a.start_time < dt.date_time + 1
                                       ) num_overlap
                             FROM
                                  table(times_pkg.between_times(TO_DATE('2010-05-30'),
                                             TO_DATE('2010-07-03'), 60*24, 'Y')) dtbetween_times is a table function that returns times at given intervals.
    I am trying to get a count of distinct (non_asp, start_time, end_time) sets that fall on each day.
    However, it doesn't recognize dt.date_time in the FROM clause.

    Hi,
    A sub-query can be correlated only to its immediate parent. You're trying the correlate the SELECT DISTINCT sub-query to its grandparent.
    You can re-write the sub-query as a join, like this:
    SELECT  TO_CHAR(dt.date_time, 'YYYY-MM-DD') start_date,
         a.num_overlap
    FROM     table ( times_pkg.between_times ( TO_DATE('2010-05-30'),
                               TO_DATE('2010-07-03'),
                               60*24,
                               'Y'
               ) dt
    JOIN    (
           SELECT    start_time,
                    end_time,
                  COUNT (DISTINCT non_asp)     AS num_overlap
           FROM         appointments
         )  a         ON  a.start_time         >= dt.date_time
                  AND a.start_time         < dt.date_time + 1
    ;You could also eliminate the extra level between the SELECT DISTINCT sub-query and the main query by using SELECT (DISTINCT ...).

  • Passing Table Name to Stored Procedure for From Clause

    Is it possible to pass a table name to a stored procedure to be used in the From clause? I have the same task to perform with numerous tables and I'd like to use the same SP and just pass the table name in. Something like this:
    =======================================
    CREATE OR REPLACE PROCEDURE SP_TEST(
    in_TABLE IN VARCHAR2,
    AS
    V_TABLE VARCHAR2(10);
    BEGIN
    V_TABLE := 'st_' || in_TABLE; -- in_TABLE is 2-3 character string
    SELECT some_columns
    INTO some_variables
    FROM V_TABLE
    WHERE some_conditions...;
    END;
    =======================================
    I'm also using the passed table name to assign to variables in the Select and Where clauses. What I'm getting is an error that V_TABLE must be declared. When I hard code the table name, I don't get any errors, even though I'm also using the same method to assign values in the Select and Where clauses.
    Thanks,
    Ed Holloman

    You need to use dynamic SQL whenever you are swapping out object names (tables, columns).
    create or replace procedure sp_test
      (in_table in varchar2)
    is
      -- variables
    begin
      execute immediate 'select a, b, c from st_' || in_table || ' where x = :xval and y = :yval'
         into v_a, v_b, v_c using v_x, v_y;
    end;

  • How to pass Temp variable value instead of Table name in From clause.

    Hi,
    I have an requirement to pass the Temperorary variable value instead of Table name in FROM Clause in SQL.
    But I am strugglint to pass this variable value.
    E.g., a Varchar2(5) := 'aa';
    Select * from a;
    Here I come to mention a - 'aa'. But the SQL looks for 'a' as Table. But its should look into 'aa' as Table name.
    Kindly guide me.
    Thanks.

    SQL> declare
      a     varchar2 (5) := 'emp';
      v     varchar2 (100);
      cur   sys_refcursor;
    begin
      open cur for 'Select ename from ' || a;
      fetch cur into v;
      while cur%found
      loop
        dbms_output.put_line (v);
        fetch cur into v;
      end loop;
      close cur;
    end;
    JAMES
    SCOTT
    SMITH
    ALLEN
    WARD
    JONES
    MARTIN
    BLAKE
    CLARK
    KING
    TURNER
    ADAMS
    FORD
    MILLER
    PL/SQL procedure successfully completed.

  • Missing PRCTR from Number Range Table

    Hi There,
    I need to find out all the the available profit centre which not created yet ie no profit centre  available in CEPC from the number range table NRIV.
    I tried the FM number_get_next but nothing happened.
    Details given below:
    In the NRIV table I have got say following details :
    Object          From Number     To Number    etc     etc
    Y_PC          0000000001     0000000100
    Y_PC          0000000101     0000000150
    Y_PC          0000000160     0000000200
    Profit Centre Created Available in CEPC say
    In the no range 1 to 100
         0000000001
                    0000000002
                    0000000003 (Not created)
         0000000004
                    5 ,6 & 7 missing
         0000000008
    In the no range 101 to 150
         0000000101
                    0000000102
         0000000103
                    0000000104 (Not created)
         0000000105
                    6,7....upto 149...(Not created)
         0000000150
    Similarly in other ranges few nos missing
    My requirement is to read the NRIV table take all  from number and to number into an internal table  and for those nos find the  missing nos from the CEPC table .
    Appreciate your help.
    Regards.
    Sunanda

    Resolved by myself !!
    Cheers.

  • General ETL question - ETL from unknown number of tables ?

    AFAIK, ETL integrates data from a fixed number of sources/tables. Is it possible that ETL can integrate data from an unknown number of tables which might be added in the future, given that these tables might be of different types (customer, shipping, employee,
    accounting etc.) ? Are there any solutions in SSIS which handle these kinds of scenarios ?
    EDIT -
    Let A,B,C be tables. We can have the following ETL scenarios - A + B + C = 1 row or A + B + C = 3 rows
    I have the first one. Later, we can add tables D,E,F,G...etc all of which might be different from each other in terms of the data they contain.

    AFAIK, ETL integrates data from a fixed number of sources/tables. Is it possible that ETL can integrate data from an unknown number of tables which might be added in the future, given that these tables might be of different types (customer, shipping, employee,
    accounting etc.) ? Are there any solutions in SSIS which handle these kinds of scenarios ?
    EDIT -
    Let A,B,C be tables. We can have the following ETL scenarios - A + B + C = 1 row or A + B + C = 3 rows
    I have the first one. Later, we can add tables D,E,F,G...etc all of which might be different from each other in terms of the data they contain.
    Another Suggestion could be, which might not satisfy your reqt fully but would help you as for me once a new source comes in you need to study it fully before population the new source could be excel .txt sql oracle etc, so it goes like below
    a) Use a Master Child package configuration, so int this case your MASTER package calls table load for your table A B and c.
    b) Once a new load has to be added you would need to design a new package and add it to the solution.
    c) The master package would not need to be changed the trick here is:
    1. Use a foreach loop in the Master packge, this for each loop is driven from a table in DB, which has the deatils around the Desttable load; so lets say today it has values like:
    DestTable LoadedFrom
    TableD A
    TableD B
    TableD C
    Now once new tables have to added just add an entry to this table and the master package would need not be changed only a new package and table entry has to done
    Abhinav http://bishtabhinav.wordpress.com/
    Thanks. It seems that you are talking about something that can me merged or union-ed. A,B,C can be different types - customer, shipping, accounting info etc. I need to join them based on different criteria. Perhaps a
    table can store the joining criteria. Also, I need to select only some columns of each table added. So, I will need a table to store which columns are to be selected for a particular table. 
    I am not sure if your suggestion would apply here.

  • Table name in from clause

    Hi Gurus,
    Each day I am creating a table dynamically and the table name is stored in log table.
    End of the day I want to see that tables data(want to create a report based on that table).
    select * from (
    select table_name from my_log
    where created_on=sysdate and table_name like '%sunil%');
    As we know, it will not work in sql, and I dont want to use plsql.
    Is there any way to get my requirements only using sql.
    Thanks,
    Sunil

    Sunil Jena wrote:
    Each day I am creating a table dynamically and the table name is stored in log table.Not the best of options. If you have purchased the Partitioning Option, use that instead. If not - give serious consideration to getting it as it is worth every cent.
    End of the day I want to see that tables data(want to create a report based on that table).
    select * from (
    select table_name from my_log
    where created_on=sysdate and table_name like '%sunil%');Not possible like that.
    It can be done using a pipeline table functions. Which would be the wrong choice IMO.
    A better option would be a partitioned view. This feature has been introduced with Oracle 7.3 I think it was. It supports partition-like pruning and enables you to have a view on several tables, but only the relevant table being hit for the actual query.
    Here's an example on 11.2.0.2. Note how the CBO uses the filter condition NULL is not NULL to remove no-relevant tables from the query.
    SQL> declare
      2          tabName         varchar2(30);
      3          nameList        TStrings;
      4          pviewSql        varchar2(32767);
      5 
      6          procedure W( line varchar2 ) is
      7          begin
      8                  DBMS_OUTPUT.put_line( nvl(line,chr(10) ) );
      9          end;
    10 
    11          procedure ExecSQL( sqlStmnt varchar2 ) is
    12          begin
    13                  W( 'SQL> '||sqlStmnt );
    14                  W( '' );
    15                  execute immediate sqlStmnt;
    16          exception when OTHERS then
    17                  W( SQLERRM(SQLCODE) );
    18          end;
    19  begin
    20          --// need to create some sample tables - will grab dictionary objects from
    21          --// the following schemas to populate the sample tables
    22          nameList := new TStrings( 'XDB','SYS','BILLY','APEX_040100','FLOWS_FILES' );
    23 
    24          --// format of the sampe table, e.g. TAB_1
    25          tabName := 'TAB_%n';
    26 
    27          --// drop the sample table if exists
    28          for i in 1..nameList.Count loop
    29                  ExecSQL( 'drop table '||replace(tabName,'%n',i)||' purge' );
    30          end loop;
    31 
    32          --// create the sample tables
    33          for i in 1..nameList.Count loop
    34                  ExecSQL(
    35  'create table '||replace(tabName,'%n',i)||'(
    36          object_id primary key,
    37          object_owner not null check(object_owner='''||nameList(i)||'''),
    38          object_type not null,
    39          object_name not null
    40  )
    41  nologging as
    42  select
    43          object_id,
    44          owner,
    45          object_type,
    46          object_name
    47  from       all_objects
    48  where      owner = '''||nameList(i)||''''
    49                  );
    50          end loop;
    51 
    52          --// create the partition view
    53          pviewSql := 'create or replace view PVIEW_TAB as ';
    54          for i in 1..nameList.Count loop
    55                  pviewSQL := pviewSQL || 'select * from '||replace(tabName,'%n',i);
    56                  if i < nameList.Count then
    57                          pviewSQL := pviewSQL || ' union all ';
    58                  end if;
    59          end loop;
    60 
    61          ExecSQL( pviewSQL );
    62  end;
    63  /
    SQL> drop table TAB_1 purge
    SQL> drop table TAB_2 purge
    SQL> drop table TAB_3 purge
    SQL> drop table TAB_4 purge
    SQL> drop table TAB_5 purge
    SQL> create table TAB_1(
            object_id primary key,
            object_owner not null check(object_owner='XDB'),
            object_type not null,
            object_name not null
    nologging
    as
    select
            object_id,
            owner,
            object_type,
            object_name
    from    all_objects
    where   owner = 'XDB'
    SQL> create table TAB_2(
            object_id primary key,
            object_owner not null check(object_owner='SYS'),
            object_type not null,
            object_name not null
    nologging
    as
    select
            object_id,
            owner,
            object_type,
            object_name
    from    all_objects
    where   owner = 'SYS'
    SQL> create table TAB_3(
            object_id primary key,
            object_owner not null check(object_owner='BILLY'),
            object_type not null,
            object_name not null
    nologging
    as
    select
            object_id,
            owner,
            object_type,
            object_name
    from    all_objects
    where   owner = 'BILLY'
    SQL> create table TAB_4(
            object_id primary key,
            object_owner not null check(object_owner='APEX_040100'),
            object_type not null,
            object_name not null
    nologging
    as
    select
            object_id,
            owner,
            object_type,
            object_name
    from    all_objects
    where   owner = 'APEX_040100'
    SQL> create table TAB_5(
            object_id primary key,
            object_owner not null check(object_owner='FLOWS_FILES'),
            object_type not null,
            object_name not null
    nologging
    as
    select
            object_id,
            owner,
            object_type,
            object_name
    from    all_objects
    where   owner = 'FLOWS_FILES'
    SQL> create or replace view PVIEW_TAB as select * from TAB_1 union all select * from TAB_2 union all select * from TAB_3 union all select * from TAB_4 union all select * from TAB_5
    PL/SQL procedure successfully completed.
    SQL>
    SQL> set autotrace on explain
    SQL> --// example of using the partition view, but querying only a single table in it
    SQL> select count(*) from pview_tab where object_owner = 'BILLY' and object_type = 'TABLE';
      COUNT(*)
            27
    Execution Plan
    Plan hash value: 3160219530
    | Id  | Operation             | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT      |           |     1 |    28 |     3   (0)| 00:00:01 |
    |   1 |  SORT AGGREGATE       |           |     1 |    28 |            |          |
    |   2 |   VIEW                | PVIEW_TAB |    31 |   868 |     3   (0)| 00:00:01 |
    |   3 |    UNION-ALL          |           |       |       |            |          |
    |*  4 |     FILTER            |           |       |       |            |          |
    |*  5 |      TABLE ACCESS FULL| TAB_1     |     1 |    28 |     3   (0)| 00:00:01 |
    |*  6 |     FILTER            |           |       |       |            |          |
    |*  7 |      TABLE ACCESS FULL| TAB_2     |     2 |    56 |    51   (2)| 00:00:01 |
    |*  8 |     TABLE ACCESS FULL | TAB_3     |    27 |   756 |     3   (0)| 00:00:01 |
    |*  9 |     FILTER            |           |       |       |            |          |
    |* 10 |      TABLE ACCESS FULL| TAB_4     |     1 |    28 |     3   (0)| 00:00:01 |
    |* 11 |     FILTER            |           |       |       |            |          |
    |* 12 |      TABLE ACCESS FULL| TAB_5     |     1 |    28 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - filter(NULL IS NOT NULL)
       5 - filter("OBJECT_OWNER"='BILLY' AND "OBJECT_TYPE"='TABLE')
       6 - filter(NULL IS NOT NULL)
       7 - filter("OBJECT_OWNER"='BILLY' AND "OBJECT_TYPE"='TABLE')
       8 - filter("OBJECT_OWNER"='BILLY' AND "OBJECT_TYPE"='TABLE')
       9 - filter(NULL IS NOT NULL)
      10 - filter("OBJECT_OWNER"='BILLY' AND "OBJECT_TYPE"='TABLE')
      11 - filter(NULL IS NOT NULL)
      12 - filter("OBJECT_OWNER"='BILLY' AND "OBJECT_TYPE"='TABLE')
    Note
       - dynamic sampling used for this statement (level=2)
    SQL> select count(*) from pview_tab where object_owner = 'SYS' and object_type = 'TABLE';
      COUNT(*)
            33
    Execution Plan
    Plan hash value: 1404131350
    | Id  | Operation             | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT      |           |     1 |    28 |    51   (2)| 00:00:01 |
    |   1 |  SORT AGGREGATE       |           |     1 |    28 |            |          |
    |   2 |   VIEW                | PVIEW_TAB |    15 |   420 |    51   (2)| 00:00:01 |
    |   3 |    UNION-ALL          |           |       |       |            |          |
    |*  4 |     FILTER            |           |       |       |            |          |
    |*  5 |      TABLE ACCESS FULL| TAB_1     |     1 |    28 |     3   (0)| 00:00:01 |
    |*  6 |     TABLE ACCESS FULL | TAB_2     |    11 |   308 |    51   (2)| 00:00:01 |
    |*  7 |     FILTER            |           |       |       |            |          |
    |*  8 |      TABLE ACCESS FULL| TAB_3     |     1 |    28 |     3   (0)| 00:00:01 |
    |*  9 |     FILTER            |           |       |       |            |          |
    |* 10 |      TABLE ACCESS FULL| TAB_4     |     1 |    28 |     3   (0)| 00:00:01 |
    |* 11 |     FILTER            |           |       |       |            |          |
    |* 12 |      TABLE ACCESS FULL| TAB_5     |     1 |    28 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - filter(NULL IS NOT NULL)
       5 - filter("OBJECT_OWNER"='SYS' AND "OBJECT_TYPE"='TABLE')
       6 - filter("OBJECT_OWNER"='SYS' AND "OBJECT_TYPE"='TABLE')
       7 - filter(NULL IS NOT NULL)
       8 - filter("OBJECT_OWNER"='SYS' AND "OBJECT_TYPE"='TABLE')
       9 - filter(NULL IS NOT NULL)
      10 - filter("OBJECT_OWNER"='SYS' AND "OBJECT_TYPE"='TABLE')
      11 - filter(NULL IS NOT NULL)
      12 - filter("OBJECT_OWNER"='SYS' AND "OBJECT_TYPE"='TABLE')
    Note
       - dynamic sampling used for this statement (level=2)
    SQL> select count(*) from pview_tab where object_type = 'TABLE';
      COUNT(*)
            78
    Execution Plan
    Plan hash value: 1006798202
    | Id  | Operation            | Name      | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT     |           |     1 |    11 |    62   (2)| 00:00:01 |
    |   1 |  SORT AGGREGATE      |           |     1 |    11 |            |          |
    |   2 |   VIEW               | PVIEW_TAB |    57 |   627 |    62   (2)| 00:00:01 |
    |   3 |    UNION-ALL         |           |       |       |            |          |
    |*  4 |     TABLE ACCESS FULL| TAB_1     |    17 |   187 |     3   (0)| 00:00:01 |
    |*  5 |     TABLE ACCESS FULL| TAB_2     |    11 |   121 |    51   (2)| 00:00:01 |
    |*  6 |     TABLE ACCESS FULL| TAB_3     |    27 |   297 |     3   (0)| 00:00:01 |
    |*  7 |     TABLE ACCESS FULL| TAB_4     |     1 |    11 |     3   (0)| 00:00:01 |
    |*  8 |     TABLE ACCESS FULL| TAB_5     |     1 |    11 |     2   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - filter("OBJECT_TYPE"='TABLE')
       5 - filter("OBJECT_TYPE"='TABLE')
       6 - filter("OBJECT_TYPE"='TABLE')
       7 - filter("OBJECT_TYPE"='TABLE')
       8 - filter("OBJECT_TYPE"='TABLE')
    Note
       - dynamic sampling used for this statement (level=2)
    SQL> set autotrace offPartition views are no longer actively supported. It could be removed in future Oracle versions. However, it is a useful and existing feature, that is worth considering in some cases.

  • Pass Pl/sql table into USING clause in EXECUTE IMMEDIATE statment

    Getting error when I try to pass the PL/SQL table into USING clause in EXECUTE IMMEDIATE statment:
    Declare
    result NUMBER;
    TYPE values_tab IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
    lv_tab values_tab;
    lv_exp varchar2(300);
    lv_exec varchar2(300);
    BEGIN
    lv_tab(1) := 5;
    lv_tab(2) := 48;
    lv_tab(3) := 7;
    lv_tab(4) := 6;
    lv_exp := ':b1+:b2+(:b3*:b4)';
    lv_exec := 'SELECT '||lv_exp ||' FROM DUAL';
    EXECUTE IMMEDIATE
    lv_exec
    INTO
    result
    USING
    lv_tab;
    DBMS_OUTPUT.PUT_LINE(result);
    END;
    Error at line 1
    ORA-06550: line 20, column 12:
    PLS-00457: expressions have to be of SQL types
    ORA-06550: line 15, column 8:
    PL/SQL: Statement ignored
    I am trying to evaluate the expression ":b1+:b2+(:b3*:b4)" which is stored in table. This table has different expressions (around 300 expressions). I want to use the bind variables in expression because each expression evaluated thousand of time may be more in some case. If I don't use bind variable then it fill shared pool.
    Is there any way I can pass the USING (IN) parameters dynamically instead of writing "USING lv_tab(1), lv_tab(2), lv_tab(3), lv_tab(4)"? As number of input parameters change depend on the expression in the table.
    If not possible please suggest any other ideas/approches
    Please help..
    Edited by: satnam on Jun 11, 2009 11:50 AM

    Well, you keep changing reqs faster I can keep up. Anyway, assuming N-th bind variable (left-to-right) corresponds to collection N-th element:
    Declare
        result NUMBER;
        lv_tab values_tab := values_tab();
        lv_exp varchar2(300);
        lv_exec varchar2(300);
        lv_i number := 0;
    BEGIN
        lv_tab.extend(4);
        lv_tab(1) := 5;
        lv_tab(2) := 48;
        lv_tab(3) := 7;
        lv_tab(4) := 6;
        lv_exp := ':5000135+:5403456+(:5900111*:5200456)';
        lv_exec := lv_exp;
        While regexp_like(lv_exec,':\d+') loop
          lv_i := lv_i + 1;
          lv_exec := REGEXP_REPLACE(lv_exec,':\d+',':b(' || lv_i || ')',1,1);
        end loop;
        lv_exec := 'BEGIN :a := ' || lv_exec || '; END;';
    DBMS_OUTPUT.PUT_LINE(lv_exec);
    EXECUTE IMMEDIATE lv_exec USING OUT result,IN lv_tab;
    DBMS_OUTPUT.PUT_LINE(result);
    END;
    BEGIN :a := :b(1)+:b(2)+(:b(3)*:b(4)); END;
    95
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Query data source type = procedure or from clause

    1)I have a form where a block is based on a from clause. In the source name I entered a simple sql statement.
    Isn't the items suppose to show without any other action or
    WHAT ELSE DO I NEED TO DO IN ORDER TO SEE THE BLOCK ITEMS EQUIVALENT TO THE COLUMNS IN THE QUERY?
    2) I have a form where a block is based on a procedure.
    First I created a package in a program unit with the procedures query_procedure, insert_procedure, update_procedure, delete_procedure and lock_procedure.
    Then I set the query data source name to the package query_procedure. The columns and arguments were automatically filled by Forms - they are fine as well.
    Forms automatically created the block triggers insert-procedure,delete-procedure, update-procedure and lock-procedure.
    Everything seems to be fine but when I run the form and execute the query I get frm 40505 - unable to perform query.
    What am i doing wrong?
    This is the package:
    PACKAGE pkgdeptemp IS
    type dept_emp is record (
    empno number(4),
    ename varchar2(10),
    job varchar2(9),
    hiredate date,
    sal number(7,2),
    deptno number(2),
    dname varchar2(14));
    success constant number :=0;
    type dept_emp_ref is ref cursor return dept_emp;
    type dept_emp_tab is table of dept_emp index by binary_integer;
    procedure query_procedure (resultset in out dept_emp_ref, p_empno in number);
    procedure lock_procedure (dmlset in out dept_emp_tab);
    procedure insert_procedure (dmlset in out dept_emp_tab);
    procedure update_procedure (dmlset in out dept_emp_tab);
    procedure delete_procedure (dmlset in out dept_emp_tab);
    END;
    PACKAGE BODY pkgdeptemp IS
    function get_success return number is
         begin
              return(success);
         end;
    procedure query_procedure (resultset in out dept_emp_ref, p_empno in number) is
    begin
         open resultset for
              select e.empno, e.ename, e.job, e.hiredate, e.sal, e.deptno, d.dname
              from emp e, dept d
              where e.deptno = d.deptno
              and e.empno = nvl(p_empno, e.empno);
    end query_procedure;
    procedure lock_procedure(dmlset in out dept_emp_tab) is
         tempout number(4);
    begin
         for i in 1..dmlset.count loop
              select empno
              into tempout
              from emp
              where empno = dmlset(i).empno
              for update;
         end loop;
    end lock_procedure;
    procedure insert_procedure (dmlset in out dept_emp_tab) is
         cursor c_dept (i binary_integer) is
         select deptno
         from dept
         where deptno = dmlset(i).deptno;
         tempout number(4);
    begin
         for i in 1..dmlset.count loop
              open c_dept(i);
              fetch c_dept into tempout;
              if c_dept%notfound then
                   insert into dept(deptno,dname)
                   values(dmlset(i).deptno, dmlset(i).dname);
              end if;
              close c_dept;
              insert into emp (empno,ename,job,hiredate,sal,deptno)
              values (dmlset(i).empno, dmlset(i).ename, dmlset(i).job, dmlset(i).hiredate, dmlset(i).sal, dmlset(i).deptno);
         end loop;
    end insert_procedure;
    procedure update_procedure (dmlset in out dept_emp_tab) is
         cursor c_dept (i binary_integer) is
         select deptno
         from dept
         where deptno = dmlset(i).deptno;
         tempout number(4);
    begin
         for i in 1..dmlset.count loop
              open c_dept(i);
              fetch c_dept into tempout;
              if c_dept%notfound then
                   insert into dept(deptno,dname)
                   values(dmlset(i).deptno, dmlset(i).dname);
              else
              update dept
              set deptno=dmlset(i).deptno,
              dname=dmlset(i).dname;
              end if;
              close c_dept;
         update emp
              set empno=dmlset(i).empno,
              ename=dmlset(i).ename,
              job=dmlset(i).job,
              hiredate=dmlset(i).hiredate,
              sal=dmlset(i).sal,
              deptno=dmlset(i).deptno;
         end loop;
    end update_procedure;
    procedure delete_procedure (dmlset in out dept_emp_tab) is
    begin
         for i in 1..dmlset.count loop
              delete from emp where empno = dmlset(i).empno;
         end loop;
    end delete_procedure;
    END;

    for ur q1:
    create the text items manually in the layout editor or in the obj navigator then specify there properties manually in the the pallette.
    database item = yes
    column name = field name in ur select statement
    for q2:
    try running the form again and press F8 then if an error occur press F1 or shift F1 to show the error in ur code.
    i suspect u forgot to specify a value for the in parameter the reason why u get an error that is specify the actual parameter for ur in argument then press F8.
    enjoy!

Maybe you are looking for

  • Visualhub start conversion in applescript

    Hi, I have set up an applescript but Im stuck at this point. I have set up a folder action so that when a new file (video) is added to a particular folder it runs this script which opens Visualhub, selects the new item and runs a standard conversion.

  • Fiscal year variant Z1 is not maintained for calendar year 2012 when loadin

    Dear Experts, We are working on BI7.0 extracting data from ECC 6.0. I am trying to load data from 0HR_PY_PP_1 which is a Self DataSource in our BW System (extracts data from 0EMPLOYEE and 0PERSON) to load into ZPA_C50 which is a copy of BCT InfoCube

  • How do i unlock my ipod

    How do I lock an ipod? We found an ipod and we can't tell if it is mine are not because it is locked. It says "ipod disabled, connect to itunes".

  • Need help with IQ02 - using a FM do update a value in this transaction

    Hi, I am trying to change the Aquisition value (as in transaction  IQ02) using either of following FM: ITOB_SERIALNO_MODIFY_SINGLE SERIALNUMBER_LIST_UPDATE However the changed value of field (ANSWT) is not getting reflected in database. I tried ABAP4

  • Downloaded TV Episode No Sound, Other Episodes OK

    Hello ... I have downloaded UNDER THE DOME S2 Episode 11 BLACK ICE. There is NO AUDIO I have downloaded it through APPLE TV, my iPAD, my MacBook .... All platforms NO AUDIO ... Now what? Clearly it's a problem with this episdode since all others work