pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Williams <drykath@runbox.com>
To: shavonne.marietta@studioform.it
Cc: pgsql-sql@postgresql.org
Subject: Re: INSERT INTO
Date: Fri, 16 Mar 2007 20:19:53 -0500 (EST)
Message-ID: <E1HSNaL-0003K5-8U@fenris.runbox.com> (raw)
In-Reply-To: <002c01c767a8$20d5d600$1102a8c0@dream>
References: <002c01c767a8$20d5d600$1102a8c0@dream>

From: "Shavonne Marietta Wijesinghe" <shavonne.marietta@studioform.it>
> I have 2 tables. TABLE1 and TABLE2.
>
> TABLE1 has about 400 records with details (client code, name, surname,
> address, date of birth) of my clients.
> TABLE2 is filled with some of the client details and other extra details
> (client code, address, telephone, etc)
>
> So in my ASP page i have a select that gets the client details from TABLE1
> using the client code and inserts them in to TABLE2
>
> When i have a string that has a ' inside of it the record is not inserted in
> to TABLE2. I know that writing it twice will fix it but how can i ask my ASP
> code to do it..

I'm sadly tasked with maintaining a little ASP code from time to time.  If you need to do it through a script, what you're looking for is the Replace function, as already mentioned in the thread:

Replace( InputString, "'", "''" )

However since we're already on pgsql-sql, assuming you're not doing a whole lot more than pulling from one table and inserting into another, you may want to consider seeing if you can roll it into a single SQL statement:

> INSERT INTO TABLE2 (TE_INDI) VALUES ('SANT'ANGELO LODIGIANO');

INSERT INTO TABLE2 (TE_INDI) VALUES SELECT TE_INDI FROM TABLE1 WHERE (...)

No quoting or server->client->server worries to deal with at all...

Best of luck,
 - Josh Williams



view thread (13+ messages)

Message-ID: <E1HSNaL-0003K5-8U@fenris.runbox.com>
Permalink:  ../E1HSNaL-0003K5-8U@fenris.runbox.com/
Also on:    postgresql.org/message-id/E1HSNaL-0003K5-8U@fenris.runbox.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: drykath@runbox.com, shavonne.marietta@studioform.it
  Subject: Re: INSERT INTO
  In-Reply-To: <E1HSNaL-0003K5-8U@fenris.runbox.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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