ename empno deptno
amar 1 10
akbar 2 20
anthonny 3 30
jonathan 4 40
write a procedure to dispaly the column values ina row
separated by a
deleimiter
eg - input - select ename from emp '|' output -
amar|akbar|anthony|jonathan
input - select empno from emp '@' o/p - 1@2@3@4
input - select deptno from emp '/' o/p -
10/20/30/40
Pls answer this questn.
Answer Posted / tina
create a function
--concat column values
create or replace function conactfunc (query_1 in varchar2)
return varchar2
is
v_return varchar2(4000);
v_query_concat varchar2(4000);
cur sys_refcursor;
begin
open cur for query_1;
loop
fetch cur into v_query_concat;
EXIT WHEN cur%NOTFOUND;
if v_return is null then
v_return := v_query_concat;
else
v_return := v_return || '@' || v_query_concat;
end if;
end loop;
return v_return;
end;
show_err;
and then call it
select hr.conactfunc('select region_name from regions') from dual;
O/P
Europe@Americas@Asia@Middle East and Africa
| Is This Answer Correct ? | 3 Yes | 0 No |
Post New Answer View All Answers
what is data manipulation language? : Sql dba
How to change a value of the field ‘salary’ as 7500 for an employee_name ‘john’ in a table employee_details?
what is primary key? : Sql dba
What is the size of partition table?
How do I install microsoft sql?
Can a foreign key have a different name?
What is varchar sql?
How can you select unique records from a table?
Is left join and outer join same?
How to fetch values from testtable1 that are not in testtable2 without using not keyword?
Is primary key clustered or nonclustered?
What is posting?
How to start the command-line sql*plus?
What are pl/sql cursors?
How is a process of pl/sql compiled?