Automatic sequence
Posted: 21.11.2015, 08:31
Hello.
We have a problem: PostgreSQL + Zeos + Delphi XE2... Consider this:
DB part:
Delphi part:
TZQuery named qDuomenys:
Assign UpdateObject property to TZUpdateSQL (named uqDuomenys) with InsertSQL:
Resulting data in DB will be: last sequence + 2 e.g. 1, 3, 5, 7, 9, etc.
I think it is a bug that ZeosLib doesn't look at AutoGenerateValue property setting.
We have a problem: PostgreSQL + Zeos + Delphi XE2... Consider this:
DB part:
Code: Select all
CREATE DATABASE test
WITH OWNER = postgres
ENCODING = 'UTF8'
TABLESPACE = pg_default
LC_COLLATE = 'Lithuanian_Lithuania.1257'
LC_CTYPE = 'Lithuanian_Lithuania.1257'
CONNECTION LIMIT = -1;
CREATE TABLE sutartis
(
st_id serial NOT NULL,
st_vardas character varying(255) NOT NULL,
CONSTRAINT sutartis_pkey PRIMARY KEY (st_id)
)
WITH (
OIDS=FALSE
);
ALTER TABLE sutartis
OWNER TO postgres;
CREATE OR REPLACE FUNCTION fnk_sutartis_edt(
prm_id integer,
prm_vardas character varying)
RETURNS integer AS
$BODY$
BEGIN
INSERT INTO sutartis(
st_vardas)
VALUES(
prm_vardas
);
RETURN 0;
END;
$BODY$
LANGUAGE plpgsql VOLATILE SECURITY DEFINER
COST 100;
ALTER FUNCTION fnk_sutartis_edt(integer, character varying)
OWNER TO postgres;
TZQuery named qDuomenys:
Code: Select all
SELECT
*
FROM
sutartis;
Code: Select all
SELECT
*
FROM
fnk_sutartis_edt(null, :prm_vardas);
Code: Select all
qDuomenys.Close;
qDuomenys.Open;
qDuomenys.Insert;
uqDuomenys.Params.ParamByName('prm_vardas').Value := DateTimeToStr(Now);
qDuomenys.Post;
I think it is a bug that ZeosLib doesn't look at AutoGenerateValue property setting.