pg_TCL and COMMIT - Mailing list pgsql-novice

From Paul Skinner
Subject pg_TCL and COMMIT
Date
Msg-id 003501bfeab6$0c8dcbb0$02320a0a@k6500
Whole thread Raw
List pgsql-novice
Greetings,
 
    Just joined the list and hope someone can answer this for me. 
   
Why can't I successfully use a SELECT statement within a transaction (BEGIN) ?  I get a message saying that the transaction is aborted, as a result I have to build all my queries in a list and issue them to the backend on the outside of a loop.  I pretty sure I did it with oratcl for 8.0.x but I don't have an environment ready to try it...
 
 
....                        set srvrrules ""
                        # An array of hosts and info...
                        foreach rule [array names rules_array] {
                                # Get the key to the rule
                                set ruleidx [findrule $rule $conn]
                                # If it didn't return, add the rule to the DB ...
                                if {[string length $ruleidx] == 0} {
                                        addrule $rule $conn
                                }
                                # .... and get it's key.
                                set ruleidx [findrule $rule $conn]
                                # RUNNING THE UPDATE HERE WOULD BE COOL!!
                                # but I add it to a list instead, because putting the key checks in the BEGIN;
                                # causes the TX to abort.
 
                                lappend SQLRules [ SQLaddsrvrrule $ruleidx $srvridx $rules_array($rule)]
                        }
                        ExecSql "BEGIN;" $conn
                        ExecSql "Delete from GG_srvr_rules where srvr = $srvridx;" $conn
                        ExecSql "update GG_players set online = 'f' where srvr = $srvridx" $conn
 

                        foreach statement $SQLRules {
                                ExecSql $statement $conn
                        }
                        ExecSql "COMMIT;" $conn
                        unset SQLRules
                    ....          
 
Paul

pgsql-novice by date:

Previous
From: Jacques Williams
Date:
Subject: Re: Library Error
Next
From: James Hall
Date:
Subject: Perl and pg_dump