table :-
city name country code
abc 11
bcd 22
cde 232
def 33

write a procedure , so that when we give a phone no. eg -
1123456789 -
o/p sud be city name = abc

if phone no. - 2322345897 , o/p sud be =cde

note - bcd and cde city name sud be diff. as dey diff only
with th last no.

Pls ans. this questnion.



table :- city name country code abc 11 bcd 22 cde ..

Answer / pravellika

create or replace procedure check1 (num number)
is
cursor c1(id number) is select b.a,b.city,b.code from (
select instr(id,code,1,1) as a,city,code from t1 )b
where b.a=1;
v_id number;
v_code NUMBER;
v_city VARCHAR2(100);
begin
open c1(num);
loop
fetch c1 into v_id,v_city,v_code;
exit when c1%notfound;
dbms_output.put_line(v_city||' '||v_code);
end loop;
close c1;
end;

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

Write the sql query using dual table for below output? 1 L R --- --- ---- 1 1 1 1 2 1 1 3 1 1 1 2 1 2 2 1 3 2 1 1 3 1 2 3 1 3 3 Write a query using only Dual table with out writing any pl/sql program.

3 Answers   JPMorgan Chase,


Can unique keys be null?

0 Answers  


What is sql keyword?

0 Answers  


how to give permission to users that users can update/insert/delete on a row of table on timeing 10am to 6pm only?

4 Answers   TCS,


How insert into statements in sql?

0 Answers  






What is recursive stored procedure?

0 Answers  


How do you explain an index?

0 Answers  


How do I audit the sql sent to the server?

0 Answers  


Is join an inner join?

0 Answers  


Why do we use view in sql?

0 Answers  


Difference between aggregate function and analytical function?

3 Answers   Metric Stream,


What is an index and types of indexes. How many number of indexes can be used per table ?

12 Answers   Accenture, BirlaSoft, Cognizant, CTS, Symphony,


Categories