Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

find value in table (don't know column name yet)

2621671Sep 17 2014 — edited Sep 17 2014

Hi all,

My need is to find value in table (don't know column name yet).

Trying to use column list and loop.

Honestly I'm afraid I can't write proper code to find COLUMN VALUE (2581365), because my code works fine only to find COLUMN NAME (dealid).

Please help me to find COLUMN VALUE.

declare

l_cnt number;

begin

for i in (

            select column_name from ALL_TAB_COLUMNS where owner = 'CREATOR' AND TABLE_NAME LIKE UPPER('%dbt_reserve%')

         )

loop

select count(1) into l_cnt

From CREATOR.dbt_reserve t

where arcdate between date '2013-09-30' - 60 and date '2013-09-30' + 60

and ISAPPROVED=1

and upper(i.column_name) = upper('dealid'); --to_char(2581365) ;

if l_cnt > 0 then

raise_application_error(-20001, l_cnt || ' ' || i.column_name);

end if;

end loop;

end;

Oracle 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 15 2014
Added on Sep 17 2014
4 comments
2,385 views