Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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.

Answers were Sorted based on User's Feedback



ename empno deptno amar 1 10 akbar 2 20 anthonny ..

Answer / 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

ename empno deptno amar 1 10 akbar 2 20 anthonny ..

Answer / sujatha nulu

Hi,
We have well advanced concepts in Oracle to achieve this.
LISTAGG analytical function can be used for this.

If its ename to be concatenated yet separated by delimiter,
use this way;

SELECT LISTAGG(ename,'|')
WITH IN GROUP (ORDER BY DEPTNO)
FROM EMPLOYEES
GROUP BY DEPTNO
ORDER BY DEPTNO;

You can write a procedure and pass column, delimiter as
parameters.

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What plvcmt and plvrb does in pl/sql?

0 Answers  


What is minus?

0 Answers  


Difference between inline query and stored procedure?

4 Answers   Bharat, Microsoft,


Give me some examples of predefined exceptions.

3 Answers  


How do I create a sql script?

0 Answers  


What is the purpose of primary key?

0 Answers  


can i create trigger on synonym is it possible or not please help me

4 Answers   CGI,


How do you update a value in sql?

0 Answers  


How do we tune the code?

2 Answers  


What is keys and its types?

0 Answers  


What is the difference between the implicit and explicit cursors?

0 Answers  


Write an sql query to select all records from the table?

0 Answers  


Categories