Error After Post With AutoRefresh + Sequence

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
thiagoalx
Posts: 5
Joined: Mon 24 Jun 2013 17:47

Error After Post With AutoRefresh + Sequence

Post by thiagoalx » Tue 01 Oct 2013 14:51

I use PostgreSQL.

After TUniQuery.Post, my application show "Refresh Failed. Found 0 Records".
But in my database, the record post normally.
My table:

Code: Select all

CREATE TABLE public.usuario (
  id SERIAL,
  funcionario VARCHAR(20),
  login VARCHAR(100),
  CONSTRAINT usuario_pkey PRIMARY KEY(id)
)
TUniQuery.SQLInsert

Code: Select all

INSERT INTO usuario
  (funcionario, login, data_cadastro)
VALUES
  (:funcionario, :login, :data_cadastro)
TUniQuery.SQLRefresh

Code: Select all

SELECT funcionario, login, data_cadastro
WHERE
  id = :id
My TUniQuery set roAfterInsert := True and roAfterUpdate := True
In my table, my column ID have a Default value := nextval('funcionario_id_seq'::regclass)

Others tables show the same error, and i don't want use StrictUpdate := False, because in some cases, in Refresh, i use JOINS or VIEWS.

Please, help me.

Thanks !

thiagoalx
Posts: 5
Joined: Mon 24 Jun 2013 17:47

Re: Error After Post With AutoRefresh + Sequence

Post by thiagoalx » Tue 01 Oct 2013 20:37

I solved the problem.

Delete all fields in TUniQuery and set:
TUniQuery.Options.DefaultValues := True;
In my table in PostgreSQL i set:
PRIMARY KEY = SERIAL with Default = nextval('usuario_id_seq'::regclass) // Sequence created automatically

And add all fields in TUniQuery.

:D

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Re: Error After Post With AutoRefresh + Sequence

Post by AlexP » Wed 02 Oct 2013 09:33

Hello,

Glad to see that you solved the problem. If you have any other questions, feel free to contact us

Post Reply