Problem with character ' (single quote) in text fields - Mailing list pgsql-general

From Jordi
Subject Problem with character ' (single quote) in text fields
Date
Msg-id a2gqr0$968$1@news.tht.net
Whole thread Raw
Responses Re: Problem with character ' (single quote) in text fields  (Einar Karttunen <ekarttun@cs.helsinki.fi>)
List pgsql-general
Hi,

I have an old problem using the single quote (') character in text field
because Postgresql thinks it is the "end of text" character.   The '
characther is used a lot in my language.  As a workaround I'm parsing the
fields duplicating the ' characters inside the text but this is a bad
solution because:

   Assuming field1 and field2 are text field, as I usually use in my
programs something like :
    ...
    sprintf (auxstr, "SELECT field WHERE field=%s AND field2=%s" , vartext1,
vartext2);
   ..

  As vartext1 and vartext2 can contain the ' so I need to create char[size]
variables to save the output of my "duplicate ' characters"  function.
Something like:

  char[SIZE] vartext1;
  char[SIZE] vartext2;

  DuplicateSingleQuote (OriginalText1, vartext1); //vartext1 is the new
valid text to insert
  DuplicateSingleQuote(OriginalText2, vartext2);
  sprintf(...)

So the code is full of temporary chart[] variables.

Is there any way to change the start/end of Text field character or do you
know a better workaround to avoid parsing/changing all the text fields just
in case they contain the single quote ( ') character??.

Best regards,

Jordi



pgsql-general by date:

Previous
From: Justin Clift
Date:
Subject: Re: [HACKERS] PostgreSQL Licence: GNU/GPL
Next
From: Einar Karttunen
Date:
Subject: Re: Problem with character ' (single quote) in text fields