Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

format column headers during concat,oracle

I need to format column headers in the output of sql while using concat Eg:

SELECT '' || to_char(sysdate,'ddmmyyyy') as DATE || ',' || ENO|| ',' || NAME|| ''  
FROM EMP;

would retrieve me

ORA-00923: FROM keyword not found where expected.

Need the output as:

DATE   ENO   NAME
-----------------
251013 7560  RAM
251013 7561  ROSS

This format works

SELECT to_char(sysdate,'ddmmyyyy') || ',' || ENO || ',' || NAME as "DATE,ENO,NAME" 
FROM EMP

but I have an issue with

ORA-00972: identifier is too long

when the length of column names inside as "" exceeds 30 characters

Eg:

SELECT to_char(sysdate,'ddmmyyyy') || ',' || ENO || ',' || NAME ||
       ',' || EMPLOYEE_IDENTIFICATION_NUMBER as "DATE,ENO,NAME,EMPLOYEE_IDENTIFICATION_NUMBER" 
FROM EMP;
like image 924
user2996364 Avatar asked Mar 27 '26 16:03

user2996364


1 Answers

To achieve this output you have to build your query like this SELECT to_char(sysdate,'ddmmyyyy') || ',' || ENO || ',' || NAME as "DATE,ENO,NAME" FROM EMP

like image 63
deterministicFail Avatar answered Mar 30 '26 06:03

deterministicFail



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!