Subject: LibPQ

From: [email-masked]
Date: Fri, 27 Mar 92 11:14:47 -0800

I have a number of questions regarding inserting records into a
database. Most of these stem from performance problems.

1. Can I populate a database from a C program by giving a  -\i  command
and a script file name, in much the same way as the demo database is
initialized. If so how ?

2. I have written an application which inserts records into a database
by creating a string eg

append Station  (StaName = "System ",Class = "- ",Parent = "- ")

and then using the PQexec command from a C program to execute it. This
works but has 2 problems 

    a) The performance is very poor ie several seconds per record. (
    it is also poor if I use PQputline )

    b) When this record append Station  (StaName = "Sta1 ",Class = "- ",Parent = "System
")
       is entered a get the following error. This I think has to do
       with the fact that the string goes over onto a new line 

WARN:Mar 27 14:05:31:*** scanner error: Unterminated char/string constant

Does anyone have any ideas as to how to overcome the above error and
also consrning the performance problem. Is there a faster way of
inserting records ?

Thanks in advance 

Edwin J Tait

---

From: postarch (Postgres Mailing Archive)
Date: Mon, 30 Mar 92 14:36:30 PST

> and then using the PQexec command from a C program to execute it. This

When you use \i in the monitor it is functionally equivalent to what you are
doing in your hand coded program.
>     it is also poor if I use PQputline )

This seems a little fishy.  But one way to get around using individual append
queries is to use the copy command.

> Does anyone have any ideas as to how to overcome the above error ...

Don't put your string on two lines!!  If you need to break up the query the
following will work:

	append Station  (StaName = "Sta1 ",
			 Class = "- ",
			 Parent = "System")

Jeff Meredith
[email-masked]