Table name passed in as a parameter

Is it possible to determine a tablename for a query dynamically?
For instance:
Select *
From :parameter

Yes. How you construct the statement depends on where you are using the statement. Is this a sql script, procedure, What?
Is it possible to determine a tablename for a query dynamically?
For instance:
Select *
From :parameter

Similar Messages

  • Define variable a ROWTYPE based on a table name passed as a parameter

    I am trying to write a procedure that processes rows for tables of differing structures. Table_name is passed as an IN parameter to the procedure. I define a cursor within the function that is defined by a SELECT * FROM table_name. I also need to define two variables, l_this_row and l_prev_row. I need to define them as table_name%ROWTYPE. Of course, table_name is a VARCHAR2 that contains the name of a table, whereas Oracle is expecting an actual table name in the declaration. How can I define these variables to make something like the code shown below compile and work properly? I am using Oracle 10gR2.
    DEFINE PROCEDURE foo(table_name IN VARCHAR2) IS
    l_this_row table_name%ROWTYPE;
    l_prev_row table_name%ROWTYPE;
    l_cursor SYSREFCURSOR;
    BEGIN
    OPEN l_cursor FOR
    'SELECT * FROM '
    || table_name
    || ' ORDER BY '
    || get_pk_col_name_for_table(table_name)
    || ', version_num'; --version_num is guaranteed to be a valid column name in every table, although the other column names vary in name, quantity, and type per table.
    LOOP
    FETCH l_cursor INTO l_this_record;
    EXIT WHEN l_cursor%NOTFOUND;
    -- dynamic comparison of l_this_record and l_prev_record and conditional processing based on the comparison occurs here
    l_prev_record := l_this_record;
    END LOOP;
    END;

    Billy  Verreynne  wrote:
    Well, one method is to keep the SQL projection consistent across the number of dynamic SQLs being dealt with. With the projection being consistent, your code does not need to guess what the row structure the column returns.Unfortunately, what I need to compare is almost everything except the primary keys. So one table might contain addresses and another might contain invoice headers. There's no way to get them into the same structure.
    Billy  Verreynne  wrote:
    This approach can also be done in a generic fashion - dealing with an arbitrary number of columns per row. This dynamic structure is more flexible, but also increases the complexity of the code that has to deal with this. For example:
    create or replace type TStrings is table of varchar2(4000);Now SQLs can be created to pass any number of columns to the code to process:
    select TStrings( empid, ename, jobid, date_employed, date_of_birth ) from emp order by empidThe code then uses the Count method of the TStrings type to determine the number of columns passed and processes that.Then the problem becomes having to specify all the column names. I need to figure them out dynamically, as in "SELECT column_name FROM user_tab_cols WHERE column_name NOT IN ('ID', 'PREV_ID', 'NEXT_ID')". It would, of course, be best if I didn't have to populate each array element with an individual SELECT in its own EXECUTE IMMEDIATE statement. That would certainly slow things down. If I were trying to write this using ADO.NET, I could reference something like table_name(row_index).columns(ix) without having to know any of the column names, and I could exclude columns by name using a reference like table_name.columns(column_index).name. (I don't recall the exact syntax, but it is something reasonably close to that.) But PL/SQL doesn't seem to have anything close to this.
    Ideally, I want to get it to where I can do something like this in a private function:
    FOR ix IN 1..TStrings.Count LOOP
       IF this_row(ix) <> last_row(ix) THEN
          RETURN FALSE;
       END IF;
    END LOOP;
    RETURN TRUE;
    Billy  Verreynne  wrote:Last comment. I have to echo what the others said. This is not optimal. Dealing with variant/dynamic structures and processing rows using PL/SQL (in a slow-by-slow fashion) does not scale well. Scalability and performance comes from processing data sets using SQL.I completely understand. I'm a big fan of replacing a lot of code with one SQL statement, but that just won't work for this problem.

  • Retrieve data from oracle table, table name passed in runtime into JSP

    Hello All,
    I am new to JSP, i have a requirement,
    I need to retrieve data from oracle table, here table is passed at random. how to get the data displayed in JSP page.
    can any one help me in that
    thanks

    1) Learn SQL.
    2) Learn Java.
    3) Learn JDBC.
    4) Learn DAO.
    5) Learn HTTP.
    6) Learn HTML.
    7) Learn JSP/Servlet.
    8) Learn JSTL.
    9) Apply learned things and develop.
    Whenever you stucks, please come back and post the specific coding/technical problem here.

  • Assign internal table name passed through routines

    Dear experts,
    How can i pass the name of P_TAB in from fieldcat_init ?.
    i call the method of an object(ob) of class .
    If i call debugger on p_tab in form fieldcat_init ,i can see the data.
    But how to assign it
      wa_fieldcat-tabname      =  P_TAB.
    I tried this but gives me dump.
    CALL METHOD OB->printalv( exporting alv_data = t_excel ).
    method printalv.
    perform printing tables alv_data.
    endmethod.
    form printing tables p_tab like t_excel.
    #  PERFORM fieldcat_init tables p_tab USING gt_fieldcat .
      PERFORM eventtab_build USING gt_events[].
      PERFORM comment_build  USING gt_list_top_of_page[].
      PERFORM disp_rep tables p_tab.
    endform.
    FORM fieldcat_init tables p_tab USING  p_gt_fieldcat .
      CLEAR wa_fieldcat.
      wa_fieldcat-fieldname    = 'MATNR'.
      wa_fieldcat-tabname      =  P_TAB.
      wa_fieldcat-seltext_m    = text-001  .
      wa_fieldcat-outputlen = 18.
      wa_fieldcat-emphasize    = 'C410'.
      APPEND wa_fieldcat TO it_fieldcat.
    ENDFORM.
    Line with # needs clarification.
    Edited by: aditya  sharma on Jul 22, 2010 9:49 AM

    Hi Aditya,
    You described your "p_tab" in TABLES section
    describe your form like that :
    FORM fieldcat_init  USING  p_tab  p_gt_fieldcat .
    ENDFORM.
    and give the name of your table to this subroutine
    not the table itself :
    PERFORM fieldcat_init USING 'ITAB' p_gt_fieldcat.
    wrong :  PERFORM fieldcat_init USING ITAB p_gt_fieldcat.
    I hope it helps.

  • Table name as paramter to PreparedStatement?

    Can a table name be provided as a parameter to a Prepared Statement? We are using Oracle 10 and have data stored in different schemas. The tables in each schema are identical, but depending on the customer querying the database we need to view the data in one schema or another. Follows is the code we are using:
    Connection con = session.connection();           
    PreparedStatement stmt = con.prepareStatement("select * from ?");
    stmt.setString(1, customerSchema+".visit");
    ResultSet rs = stmt.executeQuery();and then we get the exception:
    ORA-00903: invalid table name
    Is what I am trying to do possible without reverting to changing the Prepared Statement call to:
    PreparedStatement stmt = con.prepareStatement("select * from " + customerSchema+ ".visit");The reason I would avoid the above code, is because we want to use Hibernate and use the mapping file for SQL statement, but the problem I have is SQL/JDBC focused, since Hibernate can't do something that JDBC can't do.
    BTW I am dealing with a legacy database, so while it would be nice to correct the database design, there is too much already in place to do so at this time.

    I am dealing with a system where each each client is allocated a separate schema (the data is not private to the customer, so no ethics issues here). We now need to create an admin tool that can create reports, grabbing the data from the various schemas. I was hopping to be able to have an admin user that can access all the schemas, without having to list all the login names and passwords somewhere. In doing so I would be able to query each table of a given type in the various tables. So if I have a table called 'MyTable', then we would have:
    SELECT * from mySchemaA.myTable
    SELECT * from mySchemaB.myTable
    etc
    While we can argue over what was done in the past over the way the database was set up, the truth its already there and we have to deal with the result.
    Currently the two alternative solutions I am looking at are:
    - separate JNDI entries, in the application server, that the application needs to know about
    - modifying the parameters in code prior to creating the PreparedStatement

  • Passing TABLE NAME as parameter is possible or not?

    I want develop a small/simple report like this
    TABLE NAME :
    WHERE :
    ORDER BY :
    QUERY ROWS
    In the above model i want to pass all the three (TABLE NAME,WHERE and ORDER BY) as a parameter.
    My doubt, is that possible to pass TABLE NAME as a parameter? If so!
    When i enter any TABLE NAME it has to fetch me out the records of that table (Based on WHERE condition and ORDER BY).
    Is that possible to do?
    Need some help!
    Edited by: Muthukumar Seshadri on Aug 10, 2012 6:19 PM

    Yes, it is possible with lexical parameters. Look in the help for examples:
    SELECT Clause
    SELECT &P_ENAME NAME, &P_EMPNO ENO, &P_JOB ROLE  FROM EMP
    P_ENAME, P_EMPNO, and P_JOB can be used to change the columns selected at runtime.  For example, you could enter DEPTNO as the value for P_EMPNO on the Runtime Parameter Form. 
    Note that in this case, you should use aliases for your columns.  Otherwise, if you change the columns selected at runtime, the column names in the SELECT list will not match the Report Builder columns and the report will not run.
    FROM Clause
    SELECT ORDID, TOTAL FROM &ATABLE
    ATABLE can be used to change the table from which columns are selected at runtime.  For example, you could enter ORD for ATABLE at runtime. 
    If you dynamically change the table name in this way, you may also want to use lexical references for the SELECT clause (look at the previous example) in case the column names differ between tables.
    WHERE Clause
    SELECT ORDID, TOTAL FROM ORD WHERE &CUST
    ORDER BY Clause
    SELECT ORDID, SHIPDATE, ORDERDATE, TOTAL  FROM ORD ORDER BY &SORT You have to be really careful with this approach. Dynamic SQL may cause serious performance problems.
    Edited by: InoL on Aug 10, 2012 10:06 AM

  • Pass table name as a parameter to function

    Is there a way to pass table name as a parameter to functions? Then update the table in the function.
    Thanks a lot.
    Jiaxin

    Hi, Harm,
    Thank you very much for your suggestion and example. But to get my program work, i need to realise code like follows:
    CREATE OR REPLACE FUNCTION delstu_func(stuno char) RETURN NUMBER AS
    BEGIN
    EXECUTE IMMEDIATE 'DELETE FROM student s' ||
    'WHERE' || 's.student_number' || '=' || stuno;
    LOOP
    DBMS_OUTPUT.PUT_LINE('record deleted');
    END LOOP;
    END;
    SELECT delstu_func('s11') FROM STUDENT;
    The intention is to check if such a function can perform operations such as update, delete and insert on occurence of certain values. When executing the above statement, the system returns an error message:
    ERROR at line 1:
    ORA-00933: SQL command not properly ended
    ORA-06512: at "SCMJD1.DELSTU_FUNC", line 3
    Could you tell me where is wrong?
    Jiaxin

  • Pass table name as parameter in prepared Statement

    Can I pass table name as parameter in prepared Statement
    for example
    select * from ? where name =?
    when i use setString method for passing parameters this method append single colon before and after of this parameter but table name should be send with out colon as SQL Spec.
    I have another way to make sql query in programing but i have a case where i have limitation of that thing so please tell me is it possible with prepared Statment SetXXx methods or not ?
    Thanks
    Haroon Idrees.

    haroonob wrote:
    I know ? is use for data only my question is this way to pass table name as parameterI assume you mean "how can I do it?" As I have already answered "is this the way?" with no.
    Well, I would say (ugly as it is) String concatenation, or stored procedures.

  • How to pass parameter for table name in  form6i.

    Hi ,
    I am facing the problem to pass parameter for table name in form6i.
    If any solution please infirm me earliest to my mail id.
    ([email protected])
    example:
    begin
    select ename into :ename
    from :tab_name
    where empno =7788;
    end;
    It gives error as bad bind variable 'tab_name'
    *** where :ename and :tab_name are form fields
    Thanking you,
    Balasaheb

    object name not taken as table --> what do u mean by
    this?
    Please be more clear..
    Regards
    PriyaI have two block. First block I am displaying all the table using user_objects table. Another block I want display, user which table selected, corresponding table all the records.

  • Passing table name as a parameter

    Hi:
    I have a question regarding passing part of a table name to crystal. I have table getting created everyday and the dynamic part being Table_<date in yymmdd format>, for e.g. - Table_20140225 for table created on 02/25/2014
    I have written query like "select * form Table_{@DT}". This used to work in Crystal 11.5.8.826. but recently we upgraded to 12.2.0.290. In this version of Crystal it is not working and giving me error "com.crystaldecisions.sdk.occa.report.lib.ReportSDKServerException: Missing parameter values.---- Error code:-2147217394 Error code name:missingParameterValueError".
    Can you please suggest to get around this problem. Running a stored procedure with REFCURSOR is not an option.
    i tried another solution, where i just wrote a stored procedure to do a insert into a table handling the dynamic table in stored procedure. but to my surprise, the stored procedure doesn't execute all the time.
    Any help on this is much appreciated...

    Please see if SP 6 helps. You are on SP 2 at this time.
    https://share.sap.com/a:328ro3/MyAttachments/521c18ac-d7fd-4a58-a2dc-9d40d1951975/
    - Ludek
    Senior Support Engineer AGS Product Support, Global Support Center Canada
    Follow us on Twitter

  • Help passing table name as parameter to a procedure

    Hello,
    i'm trying to write a procedure that takes a table name as input and uses a cursor to select a column,count(1) from the passed table to the cursor. The procedure i've come up with is as follows,
    CREATE OR REPLACE
    PROCEDURE excur(
        p_tbl user_tables.table_name%type )
    AS
      type rc is ref cursor;
      c rc;
      res BOOLEAN;
    BEGIN
      open c for 'SELECT columnA,COUNT(1) FROM'|| p_tbl||';';
      close c;
    END excur;When i try to execute it, an error pops up informing that a table cannot be used in this context. As in i cannot pass a table name as an argument to a procedure. Kindly guide as to how to solve this situation.

    vishm8 wrote:
    Hello,
    i'm trying to write a procedure that takes a table name as input and uses a cursor to select a column,count(1) from the passed table to the cursor. The procedure i've come up with is as follows,
    CREATE OR REPLACE
    PROCEDURE excur(
    p_tbl user_tables.table_name%type )
    AS
    type rc is ref cursor;
    c rc;
    res BOOLEAN;
    BEGIN
    open c for 'SELECT columnA,COUNT(1) FROM'|| p_tbl||';';
    close c;
    END excur;When i try to execute it, an error pops up informing that a table cannot be used in this context. As in i cannot pass a table name as an argument to a procedure. Kindly guide as to how to solve this situation.Generally speaking, Dynamic code is a bad idea for a staggering number of reasons.
    That aside, what do you want to return? You're selecting a column and applying an aggregate function (count) but you're not grouping, that doesn't usually work out too well.
    TUBBY_TUBBZ?select owner, count(*) from all_objects;
    select owner, count(*) from all_objects
    ERROR at line 1:
    ORA-00937: not a single-group group functionWhy do you perceive the need to be able to take in ANY table name, can't you design an application where table names are known at compile time and not run time?

  • Passing Table name as parameter to proc.

    Hi,
    I need to know how to pass a table name to a oracle procedure.
    In that procedure I will put that table name in a variable and then I will make operations on that table like DELETE, UPDATE and INSERT.
    Kinldy give me the solution for the above problem as soon as possible..
    Thanks & regards,
    Kiran

    You shouldn't do it, but if you do, you can use something like this:
    Anton
    create or replace type my_parm as object
      ( name varchar2(30)
      , val  anydata
    create or replace type my_parms as table of my_parm
    create table t1( c1 number, c2 varchar2(10), c3 date )
    create or replace procedure doital( p_action in varchar2, p_tab in varchar2, parms in my_parms )
    is
      p_stmt1 varchar2(32000);
      p_stmt2 varchar2(32000);
      ind pls_integer;
      curs integer;
      dummy integer;
      t_a anytype;
      t_v varchar2(32000);
      t_n number;
      t_d date;
    begin
      curs := dbms_sql.open_cursor;
      if upper( p_action ) = 'I'
      then
        ind := parms.first;
        loop
          exit when ind is null;
          p_stmt1 := p_stmt1 || ', ' || parms( ind ).name;
          p_stmt2 := p_stmt2 || ', :b' || to_char( ind );
          ind := parms.next( ind );
        end loop;
        p_stmt1 := 'insert into ' || p_tab || ' (' || substr( p_stmt1, 2 ) || ' ) values (' || substr( p_stmt2, 2 ) || ' )';
        dbms_sql.parse( curs, p_stmt1, dbms_sql.native );
        ind := parms.first;
        loop
          exit when ind is null;
          case parms( ind ).val.GetType( t_a )
            when dbms_types.typecode_varchar2
            then
              dummy := parms( ind ).val.GetVarchar2( t_v );
              dbms_sql.bind_variable( curs, ':b' || to_char( ind ), t_v );
            when dbms_types.typecode_number
            then
              dummy := parms( ind ).val.GetNumber( t_n );
              dbms_sql.bind_variable( curs, ':b' || to_char( ind ), t_n );
            when dbms_types.typecode_date
            then
              dummy := parms( ind ).val.GetDate( t_d );
              dbms_sql.bind_variable( curs, ':b' || to_char( ind ), t_d );
          end case;
          ind := parms.next( ind );
        end loop;
      end if;
      dummy := dbms_sql.execute( curs );
      dbms_sql.close_cursor( curs );
    end;
    begin
      doital( 'I', 't1', my_parms( my_parm( 'c2', anydata.ConvertVarchar2( 'testje' ) )
                                 , my_parm( 'c1', anydata.ConvertNumber( 3 ) )
                                 , my_parm( 'c3', anydata.ConvertDate( sysdate ) )
      doital( 'I', 't1', my_parms( my_parm( 'c1', anydata.ConvertNumber( 77 ) )
                                 , my_parm( 'c2', anydata.ConvertVarchar2( 'goedzo' ) )
                                 , my_parm( 'c3', anydata.ConvertDate( sysdate - 5 ) )
    end;
    /

  • Pass parameter name as table name

    I tried to append a parameter name (area) to the name of the table through a stored procedure. As we're using CIS, the @area reference doesn't work -- instead we use ?. The SP is simple:
    declare @sql nvarchar(2000)
    set @sql = 'select 1,2,3 from table_'+@area+'where <condition 1>'
    execute sp_execute @sql
    Executing this SP shows up a long list of errors.
    Any help is deeply appreciated.
      

    Post the actual and complete procedure and not just the part you think is relevant.
    Post at least some of the complete and actual error messages you have received.
    Lastly I will assume that your code has been edited for posting.  Assuming you did not add any additional errors during this editing, then perhaps you simply need to add a space between the table name and your where clause. In other words, change
    from table_'+@area+'where <condition 1>'
    to
    from table_'+@area+' where <condition 1>'
    And as always, it would help you and your readers to post the actual string that you are attempting to execute.  Simple logic errors in assembling your string are difficult to diagnose when you don't actually "see" the executed statement. 

  • Dynamic SQL : passing table name as parameter

    Hi
    I have a SQL query (a store procedure )  that i want to convert to PLSQL
    This is a part of my SQL query that i am trying to to find a solution for it, because i cant convert it to oracle :
    DECLARE lookupTableRow CURSOR FOR
      SELECT TableName FROM SYS_LookUpTable
      OPEN lookupTableRow
      FETCH NEXT FROM lookupTableRow INTO @tableName
      WHILE @@FETCH_STATUS=0
      BEGIN
      SET @sql='SELECT * FROM '+@tableName
    EXECUTE sp_executesql @sql
      IF @counter=0
      BEGIN
      INSERT INTO T_TABLE_MAPPING VALUES('P_MAIN_METADATA', 'Table', @tableName)
      END
      ELSE
      BEGIN
      INSERT INTO T_TABLE_MAPPING VALUES('P_MAIN_METADATA', 'Table'+CONVERT(NVARCHAR(10),@counter), @tableName)
      END
      SET @counter=@counter+1
      FETCH NEXT FROM lookupTableRow INTO @tableName
      END
      CLOSE lookupTableRow
      DEALLOCATE lookupTableRow
    As i understand i can't use ORACLE dynamic sql (execute immediate) when the table name is a parameter
    Furthermore when i execute this dynamic query in my SQL store procedure each SELECT statement return me as a result the relevant table rows , those result are different in each loop .
    So i cant do this too with ORACLE dynamic sql .
    Please advice for any solution
    * how can i use dynamic sql with table name as parameter ?
    * how can i use a "dynamic" cursor, in order to be able to display the dynamic results ?
    Thanks for the advice

    Hi,
    b003cf5e-e55d-4ff1-bdd2-f088a662d9f7 wrote:
    Hi
    I have a SQL query (a store procedure )  that i want to convert to PLSQL
    This is a part of my SQL query that i am trying to to find a solution for it, because i cant convert it to oracle :
    DECLARE lookupTableRow CURSOR FOR
      SELECT TableName FROM SYS_LookUpTable
      OPEN lookupTableRow
      FETCH NEXT FROM lookupTableRow INTO @tableName
      WHILE @@FETCH_STATUS=0
      BEGIN
      SET @sql='SELECT * FROM '+@tableName
    EXECUTE sp_executesql @sql
      IF @counter=0
      BEGIN
      INSERT INTO T_TABLE_MAPPING VALUES('P_MAIN_METADATA', 'Table', @tableName)
      END
      ELSE
      BEGIN
      INSERT INTO T_TABLE_MAPPING VALUES('P_MAIN_METADATA', 'Table'+CONVERT(NVARCHAR(10),@counter), @tableName)
      END
      SET @counter=@counter+1
      FETCH NEXT FROM lookupTableRow INTO @tableName
      END
      CLOSE lookupTableRow
      DEALLOCATE lookupTableRow
    As i understand i can't use ORACLE dynamic sql (execute immediate) when the table name is a parameter
    Furthermore when i execute this dynamic query in my SQL store procedure each SELECT statement return me as a result the relevant table rows , those result are different in each loop .
    So i cant do this too with ORACLE dynamic sql .
    Please advice for any solution
    * how can i use dynamic sql with table name as parameter ?
    * how can i use a "dynamic" cursor, in order to be able to display the dynamic results ?
    Thanks for the advice
    I have a SQL query (a store procedure )  that i want to convert to PLSQL
    I doesn't help when you use one term to mean another thing.
    SQL is a language used in both Oracle and other products, such as Microsoft's SQL Server. I don't know much about SQL Server, but Oracle (at least) doesn't support stored procedures in SQL itself; they have to be coded in some other language, such as PL/SQL.  
    As i understand i can't use ORACLE dynamic sql (execute immediate) when the table name is a parameter
    If the table name is a parameter (or only known at run-time for any reason), that's exactly the kind of situation where you MUST use dynamic SQL.
    The number of columns that a query produces (and their datatypes) is fixed when you compile a query, whether that query is dynamic or not.  If you have multiple queries, that produce result sets with different numbers of columns, then you can't combine them into a single query.  The best you can do with one query is to add NULL columns to some of the queries so they all produce the same number of columns.
    If you're just displaying the results, there might not be any reason to combine separate result sets.  Just display one result set after another.
    Whenever you have a question, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • Table name as parameter to function

    Hi all,
    can anybody help me on the below issue..
    i have a function like this:
    **create or replace**
    **function "IL_SUM_AVG_FN" return number is**
    **cursor c1 is**
    **     select     sum_avg_val value**
    **     from     wel_10_tab**
    **     where     type='1';**
    **v_sum number;**
    **v_count number;**
    **BEGIN**
    **     v_sum:=0;**
    **     v_count:=0;**
    **     for i in c1 loop**
    **          if v_count=0 then**
    **               v_sum:=i.value;**
    **          else**
    **               v_sum:=abs(i.value+v_sum);**
    **          end if;**
    **          v_count:=v_count+1;**
    **     end loop;**
    **     return v_sum;**
    **END;**
    now my requirement is like..i want to pass a value as parameter to the function..say i will pass 10 or11 or 12
    then it should change the table name in the cursor according to the parameter.i.e
    if the parameter is 10 it should be: select sum_avg_val value from wel_10_tab where type='1';
    if the parameter is 11 it should be: select sum_avg_val value from wel_11_tab where type='1';
    if the parameter is 12 it should be: select sum_avg_val value from wel_12_tab where type='1';
    parameter has only these three possible values..
    how to achieve this?
    please help..

    Hi,
    you can do without execute immediate and one cursor is sufficient, if you use open cursor for ...:
    set serveroutput on;
    drop table TestTab1;
    drop table TestTab2;
    create table TestTab1 (
         val number
    create table TestTab2 as (select * from TestTab1 where 0 = 1);
    create or replace procedure TestProc (
         TableName in varchar2)
    is
         rec TestTab1%rowtype;
         cur sys_refcursor;
         curStr varchar2(1024) := 'select * from ' || TableName;
    begin
         open cur for curStr;
         loop
              fetch cur into rec;
              exit when cur%notfound;
              dbms_output.put_line ('value = ' || rec.val);
         end loop;
    end;
    insert into TestTab1 (val) values (1);
    insert into TestTab1 (val) values (2);
    insert into TestTab1 (val) values (3);
    insert into TestTab1 (val) values (4);
    insert into TestTab2 (val) values (101);
    insert into TestTab2 (val) values (102);
    insert into TestTab2 (val) values (103);
    insert into TestTab2 (val) values (104);
    begin TestProc('TestTab1'); end;
    begin TestProc('TestTab2'); end;
    /regards,
    Frank
    Edited by: user8704911 on Jul 11, 2011 10:35 PM
    Edited by: user8704911 on Jul 11, 2011 10:36 PM

Maybe you are looking for

  • My WiFi pick up the signal, but I can't do anything with internet.

    I was browser the web the other day, and all the sudden everything stop loading, and after that I can't go to any site. any more. but as I check of the log, I doesn't see any problem. and I can tell the system do pick up the signal, but I just can't

  • Help needed in this code

    Hi guys, I need help in debugging this code I made, which is a GUI minesweeper. Its extremely buggy...I particularly need help fixing the actionListener part of the code as everytime I press a button on the GUI, an exception occurs. help please! pack

  • Restoring ITunes Music from a backup copy on a external Drive

    HI My Computer crashed I had to reinstall Windows I back-up my itunes music onto a external Hard driveb 30 gigs worth. I just copied the itunes music to a external drive. How can I restore all that music? I Downloaed Itunes and have a empty libary An

  • I found an iPad.  How do I get it back to the owner?

    I found an iPad along the side of the road.  It's cracked unfortunately, but still works.  It has a passcode, so all I have is teh serial number.  Apple Chat directed me to the Reporting a Lost or Stolen Apple Product, but that has no way to register

  • My zen 20gb is dead, any suggesti

    hi, my zen wont turn on and wont charge, when its connected to the charger it gets hot. i tried the reset but nothing happens, a few times the creative screen came on then turned off, the last time when i pulled the charger out a bar code appeared ac