Re: [INTERFACES] Message-id: <37d5c912.1673.0@chariot.net.au>

From: Rusty Brooks <rbrooks(at)utdallas(dot)edu>
To: "Andrew O'Callaghan" <androc(at)chariot(dot)net(dot)au>
Cc: pgsql-interfaces(at)postgreSQL(dot)org
Subject: Re: [INTERFACES] Message-id: <37d5c912.1673.0@chariot.net.au>
Date: 1999-09-08 04:21:26
Message-ID: Pine.LNX.4.10.9909072315460.576-100000@pickles.utdallas.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

On Wed, 8 Sep 1999, Andrew O'Callaghan wrote:

==>I am new to postgresql, and am trying to create an interface to the database
==>so that I can insert records into a table from, say, a Tcl/Tk GUI. I am having
==>trouble finding any examples where this has been done. Most interface examples
==>are for extracting data from the database, ie. queries, but not for inserting
==>it into the database.

It's basically as simple as forming a correct SQL insert command. The
general format is
"insert into <table>(col1,col2,...,coln) values(val1,val2,...,valn);"

Then, just use pg_exec to execute the SQL query. There isn't really
anything returned, like there is with an pg_select, so just get the
result and if necessary, the error.

Here's a short example: (globs(conn) was opened previously)

set sql "insert into images(image_id,name,dest,source,source_type,\
show_copy_p,copyright,res,border_p,title,description,technotes) "
append sql "values(nextval('image_seq'),'$name','$Defaults(dest)','$file',\
'$type','t','$Defaults(copy)','$Defaults(res)','t','','','');"
set result [ pg_exec $globs(conn) $sql ]
set status [ pg_result $result -status ]
set error [ pg_result $result -error ]

~~~~~~
| | Rusty Brooks
|c--OD The University of Texas at Dallas
| _) Computer Science Dept.
| |
|-. | http://www.utdallas.edu/~rbrooks
/ `-# /A
/ /_|..`#.J/ Statisticians probably do it.

Better by far you should forget and smile than that you should remember
and be sad.

If a picture is worth a thousand words, then television must be worth
30,000 words per second.
-- Rusty Brooks

Browse pgsql-interfaces by date

  From Date Subject
Next Message Mark Gaschermann 1999-09-08 05:12:55 Re: [INTERFACES] PGACCESS formdemo.sql
Previous Message Andrew O'Callaghan 1999-09-08 02:25:22