Column alias having special character
Posted in 2014
User wanted to use special characters (dots) in column aliases in Informix queries, like `SELECT a.col1 AS a.col1`. The syntax error occurs because dots aren't allowed in unquoted aliases. Solution: wrap aliases in double quotes (`SELECT a.col1 AS "a.col1"`), but this requires setting DELIMIDENT environment variable to 'y', which the user wanted to avoid due to potential conflicts.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Hi,
I have a requirement of using special character to column alias, this query
will be executed from application written in ESQL/C and DB version is Informix
12.10 /11.70
SELECT a.col1 AS a.col1 ,b.col2 AS b.col2 from tab1 a , tab2 b
where a.col1= b.col2
In above example, I have used dot (.) and when I run this query it gives
Syntax error.
Please suggest if we can achieve this .
Thanks
Pradeep
Correct Syntax
SELECT a.col1 col1 ,b.col2 col2 from tab1 a , tab2 b
where a.col1= b.col2
Thanks,,
Amitava
"PRADEEP KUMAR" <pkyadav1@hotmail.com>
Sent by: ids-bounces@iiug.org
05/08/2014 12:19 PM
Please respond to
ids@iiug.org
To
ids@iiug.org,
cc
Subject
Column alias having special character [32961]
Hi,
I have a requirement of using special character to column alias, this
query
will be executed from application written in ESQL/C and DB version is
Informix
12.10 /11.70
SELECT a.col1 AS a.col1 ,b.col2 AS b.col2 from tab1 a , tab2 b
where a.col1= b.col2
In above example, I have used dot (.) and when I run this query it gives
Syntax error.
Please suggest if we can achieve this .
Thanks
Pradeep
*******************************************************************************
Forum Note: Use "Reply" to post a response in the discussion forum.
Hi Amitava , Thanks for your response. In fact the requirement is to keep the table alias ( a.col) also in AS clause . Thanks Pradeep
in that case SELECT a.col1 "a.col1" ,b.col2 "b.col2" from tab1 a , tab2 b where a.col1= b.col2 Thanks,, Amitava Chakraborty ISA Leader - IBM Informix , DB2-SAP , IM-ASL IBM India PVT LTD. Plot No 1&2, Block - G, 2nd Floor , The Mira Corporation Suites, Old Ishwar Nagar, Mathura Rd. New Delhi 110065 ------------------------------------------- Ph : Extn : 91-11-46592644(O) / 91-129-4033409(H) Mobile : +919958995870 Fax : 91-11-26921061 E - id : amitacha@in.ibm.com "PRADEEP KUMAR" <pkyadav1@hotmail.com> Sent by: ids-bounces@iiug.org 05/08/2014 12:43 PM Please respond to ids@iiug.org To ids@iiug.org, cc Subject Re: Column alias having special character [32963] Hi Amitava , Thanks for your response. In fact the requirement is to keep the table alias ( a.col) also in AS clause .. Thanks Pradeep ******************************************************************************* Forum Note: Use "Reply" to post a response in the discussion forum.
Hi Amitava We can use double quotes (") for SQL identfier when environment varibale DELIMIDENT is set to y. In our case, we are not setting it any value which means it's default value ( n). We don't want to introduce this environment varibale as we don't know what other SQL/codes we have used double quotes to delimit character string. Informix doc reference : http://pic.dhe.ibm.com/infocenter/idshelp/v117/index.jsp?topic=%2Fcom.ibm.sqlr.d oc%2Fids_sqr_233.htm Let me know if we have any other way to achieve this fucntionality. Thanks so much ! Pradeep
You cannot do this AFAIK.
Art
Art S. Kagel, Principal Consultant
ASK Database Management
Blog: http://informix-myview.blogspot.com/
Disclaimer: Please keep in mind that my own opinions are my own opinions
and do not reflect on the IIUG, nor any other organization with which I am
associated either explicitly, implicitly, or by inference. Neither do
those opinions reflect those of other individuals affiliated with any
entity with which I am affiliated nor those of the entities themselves.
On Thu, May 8, 2014 at 2:49 AM, PRADEEP KUMAR <pkyadav1@hotmail.com> wrote:
> Hi,
> I have a requirement of using special character to column alias, this query
> will be executed from application written in ESQL/C and DB version is
> Informix
> 12.10 /11.70
>
> SELECT a.col1 AS a.col1 ,b.col2 AS b.col2 from tab1 a , tab2 b
> where a.col1= b.col2>
> In above example, I have used dot (.) and when I run this query it gives
> Syntax error.
> Please suggest if we can achieve this .
>
> Thanks
> Pradeep
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--089e012292d899834204f8e0e3b3