Talking about transactions, is it possible to issue BEGIN, COMMIT, ROLLBACK commands instead of using PgSqlTransaction?
If so, what would be the advantage/disadvantage of issuing transaction command directly?
Respectfully,
Jorge Maldonado
Using transaction commands directly instead of PgSqlTransact
-
- Devart Team
- Posts: 2420
- Joined: Wed 02 Nov 2011 09:44
Yes, you can. You can use PgSqlScript, which allows you to execute several SQL statements one by one, for this. For more information please refer to: http://www.devart.com/dotconnect/postgr ... cript.html
For example you can use the following code:
DDL/DML Scripts:
For example you can use the following code:
Code: Select all
PgSqlConnection conn = new PgSqlConnection("Host=***;port=***;user id=***;password=***;");
conn.Open();
PgSqlScript script = new PgSqlScript();
script.Connection = conn;
script.ScriptText = @"begin;
select * from dept where deptno=212;
update dept set loc='NY' where deptno=212;
select * from dept where deptno=212;
commit;";
script.Execute();
Code: Select all
CREATE TABLE dept
(
deptno integer NOT NULL,
dname character varying(14),
loc character varying(13),
CONSTRAINT dept_pkey PRIMARY KEY (deptno)
);
INSERT INTO dept(deptno, dname, loc)
VALUES (212, 'Butcher', 'Vegas');