Re: Need to dynamically generate a SQL SELECT which excludes NULL columns

From: Tom Urbanowicz <tsu_at_landacorp.com>
Date: 21 Jul 2003 10:39:22 -0700
Message-ID: <6d63e629.0307210939.704e70d_at_posting.google.com>


To clarify, if only 3 columns in a record are populated (in a table w/ 100 columns), I don't want a query to retrieve 97 NULLs with 97 column headings. Instead, I need SQL (or PL/SQL) that:

  1. Identifies which columns in the table are populated for a specific record.
  2. Creates a SELECT statement using only those populated columns in the list of columns.

I would be able to identify the columns in SQL*Plus, because I would have the headings on. For example, the generated SQL and the result set would be:

   set heading on
   SQL> select COL1, COL8, COL93

     2      from MYTEST 
     3      where COL1='35';

         COL1       COL8 COL93
   ---------- ---------- ---------
           35         44 21-JUL-03


Thanks for your insights.

aruneeshsalhotr <member32378_at_dbforums.com> wrote in message news:<3093279.1057793822_at_dbforums.com>...
> It certainly is possibly what you are trying to do.
> But how would you know what columns the result is refering to.
> I mean if the query retruns col1, col2 and col93, how would u know what
> columns are we talking about.
>
> Though I dont understand the purpose of this query, but I could give
> it a shot.
Received on Mon Jul 21 2003 - 19:39:22 CEST

Original text of this message