pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Quote_literal()
3+ messages / 2 participants
[nested] [flat]

* Quote_literal()
@ 2005-11-30 21:20  James M Doherty <jim@jdoherty.net>
  0 siblings, 1 reply; 3+ messages in thread

From: James M Doherty @ 2005-11-30 21:20 UTC (permalink / raw)
  To: pgsql-sql

 declare 
	SQL     text;
      NSQL    text;

SQL := ''10/3/2009'';

NSQL := quote_literal(SQL);

The result is '10/3/2009   with no closing quote.

Jim
 
James M Doherty
Principal
 <file://C:\Documents and Settings\jmd\Application
Data\Microsoft\Signatures\odoherty_crest.jpg> 
JMD CONSULTING
411 Thunderbay Dr
Georgetown, TX 78626
A reputation is something others give you HONOR is something you give
yourself!




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Quote_literal()
@ 2005-11-30 22:27  Tom Lane <tgl@sss.pgh.pa.us>
  parent: James M Doherty <jim@jdoherty.net>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2005-11-30 22:27 UTC (permalink / raw)
  To: James M Doherty <jim@jdoherty.net>; +Cc: pgsql-sql

"James M Doherty" <jim@jdoherty.net> writes:
>  declare 
> 	SQL     text;
>       NSQL    text;

> SQL := ''10/3/2009'';

> NSQL := quote_literal(SQL);

> The result is '10/3/2009   with no closing quote.

Works for me:

regression=# create function foo() returns text as '
regression'# declare SQL     text;
regression'#         NSQL    text;
regression'# begin
regression'#   SQL := ''10/3/2009'';
regression'#   NSQL := quote_literal(SQL);
regression'#   return NSQL;
regression'# end' language plpgsql;
CREATE FUNCTION
regression=# select foo();
     foo
-------------
 '10/3/2009'
(1 row)


Again, I suggest giving a *complete* example, because you are obviously
not looking in the right place for your problem.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Quote_literal()
@ 2005-12-03 13:57  James M Doherty <jim@jdoherty.net>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: James M Doherty @ 2005-12-03 13:57 UTC (permalink / raw)
  To: 'Tom Lane' <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql

Tom,

I found the problem. It seems that a function I was calling
date_add_days(date,int)
Returned for some reason a text date + [some unprintable garbage] two
characters worth
This in turn caused the quote_literal() to fail by returning only the
initial single quote.

I resolved the problem by replacing the date_add_days() function with
date_pli() [comes with 8.1],
After doing this my problem disappeared. I am still investigating what the
cause of of the
Failure in date_add_days() was [part of my 'c' library that I ported from
gnumeric. I suspect
A memory leak [lack of pfree] in the one of the functions.

Any way thanks for taking the time to look at my issue.

Jim 


James M Doherty
Principal

JMD CONSULTING
411 Thunderbay Dr
Georgetown, TX 78626
A reputation is something others give you HONOR is something you give
yourself!

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us] 
Sent: Wednesday, November 30, 2005 4:28 PM
To: James M Doherty
Cc: pgsql-sql@postgresql.org
Subject: Re: [SQL] Quote_literal() 

"James M Doherty" <jim@jdoherty.net> writes:
>  declare 
> 	SQL     text;
>       NSQL    text;

> SQL := ''10/3/2009'';

> NSQL := quote_literal(SQL);

> The result is '10/3/2009   with no closing quote.

Works for me:

regression=# create function foo() returns text as '
regression'# declare SQL     text;
regression'#         NSQL    text;
regression'# begin
regression'#   SQL := ''10/3/2009'';
regression'#   NSQL := quote_literal(SQL);
regression'#   return NSQL;
regression'# end' language plpgsql;
CREATE FUNCTION
regression=# select foo();
     foo
-------------
 '10/3/2009'
(1 row)


Again, I suggest giving a *complete* example, because you are obviously not
looking in the right place for your problem.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2005-12-03 13:57 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-11-30 21:20 Quote_literal() James M Doherty <jim@jdoherty.net>
2005-11-30 22:27 ` Tom Lane <tgl@sss.pgh.pa.us>
2005-12-03 13:57   ` James M Doherty <jim@jdoherty.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox