Transactions, PostgreSQL and MS Access front end.

Started by Karen Hillalmost 20 years ago6 messagesgeneral
Jump to latest
#1Karen Hill
karen_hill22@yahoo.com

From Access I'd like to run pass the following from MS Access to

PostgreSQL 8.1 using VBA:

BEGIN;
UPDATE accounts SET balance = balance + 100.00 WHERE acctnum = 12345;
UPDATE accounts SET balance = balance - 100.00 WHERE acctnum = 7534;
COMMIT;

It won't let me. Any ideas solutions?

#2Bruce Momjian
bruce@momjian.us
In reply to: Karen Hill (#1)
Re: Transactions, PostgreSQL and MS Access front end.

Karen Hill wrote:

From Access I'd like to run pass the following from MS Access to

PostgreSQL 8.1 using VBA:

BEGIN;
UPDATE accounts SET balance = balance + 100.00 WHERE acctnum = 12345;
UPDATE accounts SET balance = balance - 100.00 WHERE acctnum = 7534;
COMMIT;

It won't let me. Any ideas solutions?

What error does it show?

--
Bruce Momjian http://candle.pha.pa.us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#3Karen Hill
karen_hill22@yahoo.com
In reply to: Bruce Momjian (#2)
Re: Transactions, PostgreSQL and MS Access front end.

Bruce Momjian wrote:

Karen Hill wrote:

From Access I'd like to run pass the following from MS Access to

PostgreSQL 8.1 using VBA:

BEGIN;
UPDATE accounts SET balance = balance + 100.00 WHERE acctnum = 12345;
UPDATE accounts SET balance = balance - 100.00 WHERE acctnum = 7534;
COMMIT;

It won't let me. Any ideas solutions?

What error does it show?

Error on character 7.

I suspect it only allows one SQL statement to go through and thinks
everything after the BEGIN; is an error. I thought of creating a
function in pl/pgsql that would allow me to do this. Something like
this in postgresql: NOTE:pseudocode
function(sql_statement_1, sql_statement_2){
BEGIN;
sql_statement_1;
sql_statement_2;
COMMIT;
}

And then I'd run that function from access: NOTE:pseudocode

DoCmd.RunSQL "function('UPDATE accounts..WHERE acctnum = 12345',
'UPDATE accounts...WHERE acctnum = 7534')"

#4Noname
arthurjr07@gmail.com
In reply to: Karen Hill (#1)
Re: Transactions, PostgreSQL and MS Access front end.

Try to use ADO

Dim con as ADODB.Connection
set con = new ADODB.Connection
con.Open "DRIVER={PostgreSQL};
SERVER=ipaddress; port=5432;
DATABASE=dbname;
UID=username;PWD=password;"

con.BeginTrans
con.Execute "UPDATE accounts SET balance = balance + 100.00
WHERE acctnum = 12345"
con.Execute "UPDATE accounts SET balance = balance - 100.00
WHERE acctnum = 7534"
Con.CommitTrans

#5vladimir
bouncer@nowhere.org
In reply to: Karen Hill (#1)
Re: Transactions, PostgreSQL and MS Access front end.

Karen Hill wrote:

From Access I'd like to run pass the following from MS Access to

PostgreSQL 8.1 using VBA:

BEGIN;
UPDATE accounts SET balance = balance + 100.00 WHERE acctnum = 12345;
UPDATE accounts SET balance = balance - 100.00 WHERE acctnum = 7534;
COMMIT;

It won't let me. Any ideas solutions?

it should work in pass-through query, and the query could be generated by
code (AFAIK, it has been a while i did Access).

vlad

#6Karen Hill
karen_hill22@yahoo.com
In reply to: Karen Hill (#1)
Re: Transactions, PostgreSQL and MS Access front end.

Cool. I knew ADO could do transactions on Access's JET database
engine, but didn't know they could do so on another RDBMS like
PostgreSQL. So basically I can use the BeginTrans and CommitTrans to
do the work of PostgreSQL's BEGIN; and COMMIT;

On a adjacent topic, how does PostgreSQL know that BeginTrans and
CommitTrans are psuedonyms for BEGIN and COMMIT? Is it the ODBC driver?