Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: PLSQL Question

Re: PLSQL Question

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Mon, 10 Jul 2006 19:27:32 +0200
Message-ID: <ec35b29mq9057qqf3a2afde0aao2jnjn3b@4ax.com>


On 10 Jul 2006 08:20:17 -0700, "ORA-DBA" <art_at_chicagorsvp.com> wrote:

>
>Hi All,
>
>Some developers here have tried to come up with a procedure where they
>can pass a table name to a functon, and a SELECT statement will be
>returned with all the column names, thus eliminating the need for do a
>SELECT *........
>
> CURSOR tab_cols IS
> SELECT column_name
> FROM dba_tab_columns
> WHERE table_name = 'RECRUIT';
>
>BEGIN
> FOR v_tab_cols IN tab_cols LOOP
> IF v_sql IS NULL THEN
> v_sql := v_tab_cols.column_name;
> ELSE
> v_sql := v_sql || ', ' || v_tab_cols.column_name;
> END IF;
> END LOOP;
>
>Ok great, now they have the select statement, I'm not sure how it can
>be used in PLSQL. I mean, if you use it in a CURSOR or an EXECUTE
>IMMEDIATE, do you not need an INTO clause??
>
>Just looking for some ideas here.....
>
>Thanks in advance.

The best idea is to use the DBMS_METADATA package that is supplied by Oracle for this purpose.
Your 'developers' are now trying to reinvent the wheel. The DBMS_METADATA package is documented in the Oracle Supplied PL/SQL packages manual at http://tahiti.oracle.com

--
Sybrand Bakker, Senior Oracle DBA
Received on Mon Jul 10 2006 - 12:27:32 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US