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!

Can i compare datatype of a column in if condition?

kalyan vedagiriJan 2 2019 — edited Jan 2 2019

Hello,

I have a table with the following structure

column name      datatype

name                    varchar2(10)

address                varchar2(10)

age                       number

although the following code is wrong i am pasting it here so that you can understand what i clearly want..

if (field%type== varchar2()) then

execute immediate ' select field from emp into result1;

for i in 1..result1.count loop

dbms_output.put_line(result1(i));

elsif  (field%type==number) then

execute immediate ' select field from emp into result2;

for i in 1..result2.count loop

dbms_output.put_line(result2(i));

end loop;

endif;

end;

lets think here 'field (used in if condition)  'is some dynamic column name .now i want to store the results in result 1 and result 2 based on datatypes of column.. how is this possible?

This post has been answered by Frank Kulash on Jan 2 2019
Jump to Answer
Comments
Post Details
Added on Jan 2 2019
8 comments
379 views