ex: take one schema in that t1,t2,.....tn tables and you
don't no the table name also.
write a procedure if enter columns name then display the
maching columns .otherwise display the unmatch columns.



ex: take one schema in that t1,t2,.....tn tables and you don't no the table name also. write ..

Answer / rajesh venati

create or replace procedure pro(cname in varchar2)
is
n number:=0;
cursor ecur is select column_name from user_tab_columns;
begin
for i in ecur loop
if i.column_name=cname then
n:=n+1;
end if;
end loop;
if n>=1 then
dbms_output.put_line('column matched');
else
dbms_output.put_line('column unmatched');
end if;
end;
-----------------------------------------------------
SQL> exec pro('EMPNO');
column matched

PL/SQL procedure successfully completed.

SQL> EXEC PRO('RAJESH');
column unmatched

PL/SQL procedure successfully completed.

SQL> EXEC PRO('DEPTNO');
column matched

PL/SQL procedure successfully completed.

SQL> EXEC PRO('HISAL');
column matched

PL/SQL procedure successfully completed.

Is This Answer Correct ?    6 Yes 1 No

Post New Answer

More SQL PLSQL Interview Questions

How many sql commands are there?

0 Answers  


i have a table eno dno sal 1 10 200 2 10 150 3 10 100 4 20 75 5 20 100 i want to get sal which is less than the avg sal of thri dept. eno dno sal 2 10 150 3 10 100 4 20 75

12 Answers   IBM,


who introduced sql?

0 Answers  


What is the primary key?

0 Answers  


What is a common use of group by in sql?

0 Answers  






What is pivot table in sql?

0 Answers  


How do you optimize a stored procedure in sql?

0 Answers  


What are all different types of collation sensitivity?

0 Answers  


Where are my tempfiles, I don't see them in v$datafile or dba_data_file?

0 Answers  


I have following column in the table. col1 1 a b c 2 3 d and I want to display it as num chars 1 a 2 b 3 c 4 d numbers in one column and letters in another column.

1 Answers   IBM, Saama Tech,


what are the limitations of mysql in comparison of oracle? Mysql vs. Oracle. : Sql dba

0 Answers  


Write a query to get 2nd maximum salary in an employee table ?

69 Answers   Accenture, BirlaSoft, Letse, Logica CMG, Qwest, Rheal Software, Saagam, Semantic Space, Tailor Solution, TCS, TinyERP,


Categories