Обсуждение: apostrophes and psql variables
Hello!
Is there any way to have psql variable in apostrophes?
The idea is to do something like this
\set var 'some value'
insert into aaa values(:var)
after substisution it should as simple as
insert into aaa values('some value')
I've tried all reasonable quotings
I was able to make up but no any luck.
Thanks.
--
Best regards
Ilja Golshtein
On Thu, Aug 17, 2006 at 05:05:00PM +0400, Ilja Golshtein wrote:
> Is there any way to have psql variable in apostrophes?
>
> The idea is to do something like this
>
> \set var 'some value'
> insert into aaa values(:var)
test=> \set var '\'some value\''
test=> insert into aaa values (:var);
INSERT 0 1
test=> select * from aaa;
val
------------
some value
(1 row)
--
Michael Fuhr
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
You must have missed one, because:
root=# \set tv1 '\'testval\''
root=# insert into test values(:tv1);
INSERT 0 1
root=#
Ilja Golshtein wrote:
> Hello!
>
> Is there any way to have psql variable in apostrophes?
>
> The idea is to do something like this
>
> \set var 'some value'
> insert into aaa values(:var)
>
> after substisution it should as simple as
> insert into aaa values('some value')
>
> I've tried all reasonable quotings
> I was able to make up but no any luck.
>
> Thanks.
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iQEVAwUBROjIerEDZDQ16UzTAQIVLAf/WFZVTRyc9s4tTh1BDel1OOOmJgak2ebJ
wYynHWxh2lrudyROybLS3Btbs98jnRsWZC7yNXCugkfDjZ7+n/paPFXcyCZIFqEr
akfHZXfRtkphD8IFrFCCsMIn68bU39CY+f/JtvyO1uIeSylolFDSfjOEh8jdPD6e
NciBURYj+q51Ugna63ym55zKmgSzISqdiDKzArtsfs7hYpzPo+8A4r/Ig7J6GsI9
3DON02eNaryYKdAdSJsnJWzLmhsgfp9oNI0X3V/fIcBV5w1SKgp/BsPYb/D7KbMI
XRmCglWQq8K4QzWjdaptLHbfuwmjRUuNMvzGs33VSZrjJywqqFcVcQ==
=yf0V
-----END PGP SIGNATURE-----