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

Поиск
Список
Период
Сортировка
От Rusty Brooks
Тема Re: [INTERFACES] Message-id: <37d5c912.1673.0@chariot.net.au>
Дата
Msg-id Pine.LNX.4.10.9909072315460.576-100000@pickles.utdallas.edu
обсуждение исходный текст
Список 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



В списке pgsql-interfaces по дате отправления:

Предыдущее
От: "Gene Selkov, Jr."
Дата:
Сообщение: Re: [INTERFACES] documentation for ssh tunnelling of connections?
Следующее
От: "Mark Gaschermann"
Дата:
Сообщение: Re: [INTERFACES] PGACCESS formdemo.sql