SQL query
Last Post 29 Mar 2013 01:04 PM by B.Hauser. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
mukesh kumar
New Member
New Member
Posts:14

--
29 Mar 2013 11:51 AM

I have seen one select statement in DB2 SQL PL today.

It was something like this

set abc='select   ''ACTIVE''   ,name from xyz  group by ''ACTIVE",name'

 

here  "........."  around ACTIVE is --->pair of  2 single quotes

what  it does?

 

Thanks in advance

Rocky Marquiss
Senior Member
Senior Member
Posts:2906

--
29 Mar 2013 12:00 PM
It puts the text "ACTIVE" in the results. Often used to insert records into a table where you have to force a value for a status field...

The reason you have 2 single quotes is it is in a string - and to put a single quote within a string you need 2 single quotes... the end result of above abc is select 'ACTIVE' ,name from xyz group by 'ACTIVE', name

B.Hauser
Veteran Member
Veteran Member
Posts:2043

--
29 Mar 2013 01:04 PM
The double quotes are used for column names that are case sensitive or contain characters that are norrmally allowed for column names or column names that match SQL reserved words.
Single quotes are used for constant values.

Birgitta
You are not authorized to post a reply.

Acceptable Use Policy