Hi,
I wanted to list the all columns of a emp table .
The output should be comma seperated and list of column should come in brakets like (enam,sal,jdate ,job). The below code gives me proper result.
But I am facing problem with last column name .It comes with coma and then braket . I dont want that comma with last column name .
Can u tell me how to achieve that .
Please refer below code ..
Thanks in advance
Output is as below
(
ENAME,
SAL,
JDATE,
JOB,
)
I wanted output as
(
ENAME,
SAL,
JDATE,
JOB
)
(job with no comma)
I wanted to list the all columns of a emp table .
The output should be comma seperated and list of column should come in brakets like (enam,sal,jdate ,job). The below code gives me proper result.
But I am facing problem with last column name .It comes with coma and then braket . I dont want that comma with last column name .
Can u tell me how to achieve that .
Please refer below code ..
Thanks in advance
Code:
Declare
CURSOR c1
IS
SELECT column_name
FROM cols WHERE table_name='EMP';
BEGIN
dbms_output.put_line('(');
FOR r1 IN c1
LOOP
dbms_output.put_line(r1.column_name||',');
END LOOP;
dbms_output.put_line(')');
END ;
/
(
ENAME,
SAL,
JDATE,
JOB,
)
I wanted output as
(
ENAME,
SAL,
JDATE,
JOB
)
(job with no comma)
Comment