Thread: string fields helps

string fields helps

From
marcelo Cortez
Date:
Folks

  I need to save data on rtf format but , postgres
refuses to storage for backslah or character's
problem's   any idea or vice are welcomed       best
regards
 mdc

pd: sample off data to save ( from postgres log)

"
 UPDATE plbrecord SET documentation =
'{\rtf1\ansi\deff0{\fonttbl{\f0\fnil Tahoma;}}
        \viewkind4\uc1\pard\lang1033\f0\fs16
        \par }
        ', version_ = 4 WHERE (plbrecord.id_ = 8 AND
plbrecord.version_ = 3 AND plbrecord.inst_class_ =
'EntityDataWindow')
LOG:  statement: COMMIT1
LOG:  statement: BEGIN
LOG:  statement: UPDATE plbrecord SET documentation =
'{\rtf1\ansi\deff0{\fonttbl{\f0\fnil Tahoma;}}
        \viewkind4\uc1\pard\lang1033\f0\fs16   SELECT
"PARAMETROS"."PARAMETRO",
        \par
substr(to_char("PARAMETROS"."F_VAL_PARAM",
''YYYY/MM/DD''), 1,10),
        \par
substr(to_char("PARAMETROS"."F_ANUL_PARAM",''YYYY/MM/DD''),
1,10),
        \par          "PARAMETROS"."VALOR1",
        \par          "PARAMETROS"."VALOR2"
        \par     FROM "PARAMETROS"
        \par " )
        \par
        \par }
        ', version_ = 5 WHERE (plbrecord.id_ = 8 AND
plbrecord.version_ = 4 AND plbrecord.inst_class_ =
'EntityDataWindow')
LOG:  statement: COMMIT
LOG:  statement: BEGIN
LOG:  statement: UPDATE plbrecord SET documentation =
'{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0
Tahoma;}{\f1\fnil Tahoma;}}
        \viewkind4\uc1\pard\lang1033\f0\fs18   SELECT
"PARAMETROS"."PARAMETRO",
        \par
substr(to_char("PARAMETROS"."F_VAL_PARAM",
''YYYY/MM/DD''), 1,10),
        \par
substr(to_char("PARAMETROS"."F_ANUL_PARAM",''YYYY/MM/DD''),
1,10),
        \par          "PARAMETROS"."VALOR1",
        \par          "PARAMETROS"."VALOR2"
        \par     FROM "PARAMETROS"
        \par " )
        \par \f1\fs16
        \par }
"


      __________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas


Re: string fields helps

From
Bill Moran
Date:
marcelo Cortez <jmdc_marcelo@yahoo.com.ar> wrote:
>
> Folks
>
>   I need to save data on rtf format but , postgres
> refuses to storage for backslah or character's
> problem's   any idea or vice are welcomed       best
> regards
>  mdc

You need to escape the data before you insert it.  This is language-
dependant, but any language that has PostgreSQL libraries will have
functions to escape text data.

>
> pd: sample off data to save ( from postgres log)
>
> "
>  UPDATE plbrecord SET documentation =
> '{\rtf1\ansi\deff0{\fonttbl{\f0\fnil Tahoma;}}
>         \viewkind4\uc1\pard\lang1033\f0\fs16
>         \par }
>         ', version_ = 4 WHERE (plbrecord.id_ = 8 AND
> plbrecord.version_ = 3 AND plbrecord.inst_class_ =
> 'EntityDataWindow')
> LOG:  statement: COMMIT1
> LOG:  statement: BEGIN
> LOG:  statement: UPDATE plbrecord SET documentation =
> '{\rtf1\ansi\deff0{\fonttbl{\f0\fnil Tahoma;}}
>         \viewkind4\uc1\pard\lang1033\f0\fs16   SELECT
> "PARAMETROS"."PARAMETRO",
>         \par
> substr(to_char("PARAMETROS"."F_VAL_PARAM",
> ''YYYY/MM/DD''), 1,10),
>         \par
> substr(to_char("PARAMETROS"."F_ANUL_PARAM",''YYYY/MM/DD''),
> 1,10),
>         \par          "PARAMETROS"."VALOR1",
>         \par          "PARAMETROS"."VALOR2"
>         \par     FROM "PARAMETROS"
>         \par " )
>         \par
>         \par }
>         ', version_ = 5 WHERE (plbrecord.id_ = 8 AND
> plbrecord.version_ = 4 AND plbrecord.inst_class_ =
> 'EntityDataWindow')
> LOG:  statement: COMMIT
> LOG:  statement: BEGIN
> LOG:  statement: UPDATE plbrecord SET documentation =
> '{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0
> Tahoma;}{\f1\fnil Tahoma;}}
>         \viewkind4\uc1\pard\lang1033\f0\fs18   SELECT
> "PARAMETROS"."PARAMETRO",
>         \par
> substr(to_char("PARAMETROS"."F_VAL_PARAM",
> ''YYYY/MM/DD''), 1,10),
>         \par
> substr(to_char("PARAMETROS"."F_ANUL_PARAM",''YYYY/MM/DD''),
> 1,10),
>         \par          "PARAMETROS"."VALOR1",
>         \par          "PARAMETROS"."VALOR2"
>         \par     FROM "PARAMETROS"
>         \par " )
>         \par \f1\fs16
>         \par }
> "
>
>
>       __________________________________________________
> Preguntá. Respondé. Descubrí.
> Todo lo que querías saber, y lo que ni imaginabas,
> está en Yahoo! Respuestas (Beta).
> ¡Probalo ya!
> http://www.yahoo.com.ar/respuestas
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>        choose an index scan if your joining column's datatypes do not
>        match


--
Bill Moran
http://www.potentialtech.com

Re: string fields helps

From
Tom Lane
Date:
Bill Moran <wmoran@potentialtech.com> writes:
> marcelo Cortez <jmdc_marcelo@yahoo.com.ar> wrote:
>> I need to save data on rtf format but , postgres
>> refuses to storage for backslah or character's
>> problem's   any idea or vice are welcomed       best

> You need to escape the data before you insert it.  This is language-
> dependant, but any language that has PostgreSQL libraries will have
> functions to escape text data.

Also, given that his main problem seems to be with backslashes, using
8.2 and setting standard_conforming_strings = on might help.  It's still
the case that not using a proper escaping function will come back to
haunt you someday, though.

            regards, tom lane

Re: string fields helps

From
"Michael Nolan"
Date:
On 4/16/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
.  It's still
the case that not using a proper escaping function will come back to
haunt you someday, though.


Has anybody written a 'proper escaping function' in php, something along the lines of addslashes()?
--
Mike Nolan

Re: string fields helps

From
Chris
Date:
> Has anybody written a 'proper escaping function' in php, something along
> the lines of addslashes()?

It has been around for ages: http://php.net/pg_escape_string

--
Postgresql & php tutorials
http://www.designmagick.com/

Re: string fields helps

From
marcelo Cortez
Date:
Thanks  Tom!

 this works.
 best regards
 MDC


--- Tom Lane <tgl@sss.pgh.pa.us> escribió:

> Bill Moran <wmoran@potentialtech.com> writes:
> > marcelo Cortez <jmdc_marcelo@yahoo.com.ar> wrote:
> >> I need to save data on rtf format but , postgres
>
> >> refuses to storage for backslah or character's
> >> problem's   any idea or vice are welcomed
> best
>
> > You need to escape the data before you insert it.
> This is language-
> > dependant, but any language that has PostgreSQL
> libraries will have
> > functions to escape text data.
>
> Also, given that his main problem seems to be with
> backslashes, using
> 8.2 and setting standard_conforming_strings = on
> might help.  It's still
> the case that not using a proper escaping function
> will come back to
> haunt you someday, though.
>
>             regards, tom lane
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org/
>



      __________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas