|
|
sybperl-l Archive
Up Prev Next
From: phil_groce at cmcsmart dot com (Phil Groce)
Subject: Re: single quotes in text datatypes
Date: Apr 16 1998 4:05PM
At 04:47 PM 4/16/98 +0200, you wrote:
>Hi,
>
>Hope this is an easy one for my first posting:
>
>How do I insert a TEXT datatype containing a '?
To escape literal quotes in text use two single quotes -- i.e., two
apostrophes in a row ('', as distinct from a double quote, " -- hope that's
clearer on your machine than mine.) This is similar to the way languages
like perl use a backslash to escape literals that might otherwise be
interpreted (print "These \"quotes\" are escaped"), but as far as I know,
it only covers quotation marks.
Example:
create table test (
test_string varchar(100)
)
go
insert into test values ('The rabbit said ''Hey, Rabbits don''t talk!'' and
vanished')
go
What will get inserted is:
The rabbit said 'Hey, Rabbits don't talk!' and vanished
>The Que Sybase book I've got says "TEXT and IMAGE" types are the same, yet
>our server cries when I try to feed it 0x..... expecting a TEXT type. It
>also cries when I try to feed it 'The quick brown fox jumps over the lazy
>dog's tail.'
I haven't had to do any of the hex decoding with text types that you'd have
to do with image types -- feed it strings, and it will spit them back at
you. (Their internals are identical, though, AFAIK -- they each whole pages
of storage space at a time for theoretically unlimited size, so if space is
a consideration and you can get away with it, use char or varchar).
>Many TIA,
>David.
>SOL Bors.
phil
|