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>
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.
- open cursor(dbms_sql.open_cursor)
- generate sql statement as VARCHAR2 and parse(dbms_sql.parse)
- define columns to get data(dbms_sql.define_column)
- execute(dbms_sql.execute)
- fetch(dbms_sql.fetch_rows)
- close cursor(dbms_sql.close_cursor)
quasi(PL/SQL Developer, Java Developer, and DBA) Received on Tue Sep 17 2002 - 17:10:35 CEST