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.

Answer Posted / 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       View All Answers


Please Help Members By Posting Answers For Below Questions

What is dynamic sql in pl sql?

507


how would you get the current date in mysql? : Sql dba

560


Is sqlite thread safe?

615


What is a table?

573


what does myisamchk do? : Sql dba

567






Differentiate pl/sql and sql?

569


explain the difference between bool, tinyint and bit. : Sql dba

538


What is the purpose of cursors in pl/sql?

654


Is stored procedure faster than query?

572


what are tables and fields? : Sql dba

586


Is sql developer case sensitive?

532


Can a table have no primary key?

565


Why do we create stored procedures & functions in pl/sql and how are they different?

515


What are three advantages to using sql?

564


how to create a new view in mysql? : Sql dba

510