tcl script
От | Vijay Deval |
---|---|
Тема | tcl script |
Дата | |
Msg-id | 3DEF43D1.6555A124@giaspn01.vsnl.net.in обсуждение исходный текст |
Ответы |
Re: tcl script
|
Список | pgsql-novice |
I extended Bruce Momjian's script for use with my application. It does insert record into the desired table, but says "pg_recvbuf: unexpected EOF on client connection. Where is the error? here is the script that I have named as "inward" #!/usr/local/pgsql/bin/pgtclsh set conn [pg_connect test]; # connect to the database puts -nonewline "Enter first three characters: " ;# prompt user for a code flush stdout gets stdin code ;# send the query set cmd "string toupper $code" set ucode [eval $cmd] set res [pg_exec $conn \ "SELECT name,clid \ FROM client\ WHERE upper(substring(name from 1 for 3)) = '$ucode' "] set ntups [pg_result $res -numTuples] if {$ntups==0} {puts stdout "No match found"; return} else { for {set i 0} {$i < $ntups} {incr i} { puts stdout [pg_result $res -getTuple $i]; }} puts -nonewline "Enter client number: " ;# prompt user for a code flush stdout gets stdin mclid ;# send the query set res [pg_exec $conn \ "SELECT jobkey,jobname\ FROM job\ where job.clid=client.clid and job.clid=$mclid"] set ntups [pg_result $res -numTuples] if {$ntups==0 } {puts stdout "No record found"; return} else { for {set i 0} {$i < $ntups} {incr i} { puts stdout [pg_result $res -getTuple $i]; } } puts -nonewline "Enter jobcode: " ;# prompt user for a code flush stdout gets stdin jobno ;# send the query puts -nonewline "Enter indoc no: " ;# prompt user for a code flush stdout gets stdin docno ;# send the query puts -nonewline "Enter indoc date 'yyyymmdd' : " ;# prompt user for a code flush stdout gets stdin datein ;# send the query set res [pg_exec $conn \ "SELECT hlpstr\ FROM job\ WHERE jobkey=$jobno"] set ntups [pg_result $res -numTuples] set mstr [pg_result $res -getTuple 0]; puts -nonewline "Enter quantity $mstr: " ;# prompt user for a code flush stdout gets stdin qty ;# send the query set res [pg_exec $conn \ "SELECT rate\ FROM job\ WHERE jobkey=$jobno"] set ntups [pg_result $res -numTuples] set mrate [pg_result $res -getTuple 0]; puts stdout $mrate pg_result $res -clear pg_exec $conn \ "insert into inmat (clid,jobkey, oc,ratex,indoc,indate,inqty) values ($mclid,$jobno,'O',$mrate,$docno,$datein,$qty);" pg_disconnect $conn; Vijay
В списке pgsql-novice по дате отправления: