Home » SQL & PL/SQL » SQL & PL/SQL » 'ytd'||To_char(sysdate,'yyyy') in alias (oracle 10g)
'ytd'||To_char(sysdate,'yyyy') in alias [message #431060] Sat, 14 November 2009 02:50 Go to next message
seyed456
Messages: 220
Registered: May 2008
Location: south india .
Senior Member

I wants the string and to_char(sysdate,'yyyy')..

i tried like this..am getting an error
SELECT NAME AS 'ytd'||TO_CHAR(SYSDATE,'YYYY')
FROM CTYPES


error
ORA-00923: FROM keyword not found where expected


How can i achieve this ?..

thanks in advamnce
Re: 'ytd'||To_char(sysdate,'yyyy') in alias [message #431061 is a reply to message #431060] Sat, 14 November 2009 02:59 Go to previous message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Alias must be a constant.
You cannot achieve it in one statement.

Here's an example of what you can do:
SQL> col nm new_value nm
SQL> select 'ytd'||TO_CHAR(SYSDATE,'YYYY') nm from dual;
NM
-------
ytd2009

1 row selected.

SQL> col &nm format a8
SQL> select dummy &nm from dual;
YTD2009
--------
X

1 row selected.

Regards
Michel

[Updated on: Sat, 14 November 2009 02:59]

Report message to a moderator

Previous Topic: GMT to EST or EDT
Next Topic: Invalid number exception returned by Store Procedure (merged)
Goto Forum:
  


Current Time: Fri Dec 06 02:24:40 CST 2024