LISTAGG function:
Ø LISTAGG
function used to concatenate multiple row of a string into a single row.
Syntax:
Example:
Output:
Example: 1 LISTAGG function
Output:
Example: 2
Output:
Explanation:
v LISTAGG
is the keyword
v Ename
column name of the emp table
v ;
is the separator (User can change the separator whatever developer needs)
v WITHIN
GROUP (order by clm_name) default through the syntax
v Emp
table_name.
Disadvantages:
Ø The
problem of using LISTAGG function is, if we trying to concatenate more than
4000 characters it’s thrown the exception.
Example:
Note: HZ_Parties table have above 4000 characters string in
the table so oracle will throw the error.
The output report will be,
Solution:
Explanation:
Ø ON OVERFLOW
TRUNCATE or ON
OVERFLOW ERROR is used to truncate the values.
No comments:
Post a Comment