Re: Select from a today_table_name

From: quasi <quasi_at_kc4.so-net.ne.jp>
Date: 17 Sep 2002 08:10:35 -0700
Message-ID: <ccaf80ba.0209170710.8666990_at_posting.google.com>


> How have I to do to make a Select from a tabla that its name is today
> date. I need to put this in a stored procedure.
>
> It's not possible to use a function in from.
> SELECT 'TABLE_' || TO_CHAR(SYSDATE,'YYYYMMDD') into cot From DUAL

if you want to change sql's table name, you must use dynamic sql, i mean, dbms_sql package.

  1. open cursor(dbms_sql.open_cursor)
  2. generate sql statement as VARCHAR2 and parse(dbms_sql.parse)
  3. define columns to get data(dbms_sql.define_column)
  4. execute(dbms_sql.execute)
  5. fetch(dbms_sql.fetch_rows)
  6. close cursor(dbms_sql.close_cursor)

quasi(PL/SQL Developer, Java Developer, and DBA) Received on Tue Sep 17 2002 - 17:10:35 CEST

Original text of this message