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: 64109
Registered: March 2007
Location: Nanterre, France, http://...
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: Mon Dec 05 08:46:55 CST 2016

Total time taken to generate the page: 0.15152 seconds