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
What is lookup table in sql?
how can we destroy the session, how can we unset the variable of a session? : Sql dba
What is the purpose of a sql?
How can we solve sql error: ora-00904: invalid identifier?
Is it important to partition hard disk?
table structure: ---------------- col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10 01-mar-2012 11:12:46 01-mar-2012 11:11:23 Write a query to display the result as shown below: col1 col2 ----- ----- 01-mar-2012 11:12:46 01-mar-2012 11:12:10
How to get unique records from a table?
What is primary key and unique key?
What are inner and outer joins examples of both?
What is offset in sql query?
What does inner join mean?
Explain lock escalation? : Transact sql
What is sql scripting?
how to escape special characters in sql statements? : Sql dba
what are the advantages a stored procedure? : Sql dba