Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: simple PL/SQL syntax question.

Re: simple PL/SQL syntax question.

From: Steve Cosner <stevec_at_zimmer.csufresno.edu>
Date: 1997/12/24
Message-ID: <882982796.1775501323@dejanews.com>#1/1

In article <01bd0f02$0030eec0$af01010a_at_msppc060.retek.com>,   "Rich Davies" <Richard_Davies_at_retek.com> wrote:
>
> Can someone explain why this works, please?
>
> I want to set the value of one local string variable in PL/SQl to:
>
> USER_ID = 'another_local_string'
>
> including the single ticks. Through trial and error I've found the
> following assignment statement works.
>
> a_local_string := 'USER_ID = ''' || another_local_string || '''' ;
>
> In case this is hard to read with your typeface, that is: one single tick
> at the beginning, three single ticks in the middle, and four single ticks
> at the end.
>
> Does this make sense to anyone? If so please enlighten me. Thanks in
> advance.

Your "single tick" is the apostrophe character, also known as a single quote. Since the apostrophe is the literal string delimiter, in order to actually include an apostrophe in a literal string, you type a pair of them. So in the end of your example above, you have '''', which is the pair in the center required to represent one apostrophe, surrounded by the beginning and ending apostrophes needed to start and end the literal string.

You can also represent an embedded apostrophe using the chr(39) function.  In this case, your example would look like this: a_local_string := 'USER_ID = '||chr(39)|| another_local_string ||chr(39);

But using the chr() function is system dependent. On Oracle on an IBM mainframe, you would need the EBCDIC (rather than ASCII) apostrophe: chr(125).

HTH
Steve Cosner



http://members.aol.com/stevec5088
-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet
Received on Wed Dec 24 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US