Skip to content
Advertisement

Converting column data into row in pl/sql

Hi When i went for an interview they asked me this question.

Thanks in advance, Sandhya.

Advertisement

Answer

I presume that NAME column’s datatype should have been VARCHAR2, not CHAR.

Anyway, another option (similar to Tejash’s LISTAGG) which uses XMLAGG and is safer if the result is larger than 4000 characters.


Or, as you tagged the question with PL/SQL tag, then an anonymous PL/SQL block might look like this:


Or – similarly – a function:


Or, a procedure with an OUT parameter:


As you can see, quite a few options; use the one that most suits your needs.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement