use DBI; my $db = 'Pg'; my $database = 'test'; my $user = 'test'; my $password = 'test'; my $dbh = DBI->connect( "DBI:${db}:database=" . $database . ";", $user, $password, { RaiseError => 1, PrintError => 1, PrintWarn => 1, # AutoCommit => 0, } ); $dbh->begin_work; my $st = $dbh->prepare('delete from test where inc = ?'); for my $x (2, 4, 6) { my $ra = $st->execute($x); print $st->rows, "\n"; } $dbh->rollback; #### -- -- PostgreSQL database dump -- SET client_encoding = 'UTF8'; SET check_function_bodies = false; SET client_min_messages = warning; -- -- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: postgres -- COMMENT ON SCHEMA public IS 'Standard public schema'; CREATE USER test WITH PASSWORD 'test'; SET search_path = public, pg_catalog; SET default_tablespace = ''; SET default_with_oids = false; -- -- Name: test; Type: TABLE; Schema: public; Owner: test; Tablespace: -- CREATE TABLE test ( inc integer, test character varying(40) ); ALTER TABLE public.test OWNER TO test; -- -- Data for Name: test; Type: TABLE DATA; Schema: public; Owner: test -- COPY test (inc, test) FROM stdin; 1 a 2 b 3 b 4 b 5 b 6 c \. GRANT ALL ON TABLE test TO test;