🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.delphi.bazy-danych
Article #82565

TIBCQuery Insert/Post nie zważa na triggera autoinkremantacji

#82565
From: Borneq
Date: Thu, 20 Aug 2015 09:53
23 lines
1931 bytes
Najpierw robiłem w następujący sposób:
    queryInsert:=TIBCQuery.Create(self);
    queryInsert.SQL.Text:='insert into books (title) values (:title);';
    queryInsert.ParamByName('title').AsString:=edTitle.Text;
    queryInsert.Execute;
    queryInsert.Free;

ale aby zobaczyć id_books nowo wstawionego musiałem odczytywać wartość 
generatora: select gen_id(gen_books_id, 0) from rdb$database;

Teraz robię w ten sposób, że mam na formie IBCQuery1 podczepione do 
grida z zapytaniem "select ID_BOOKS,TITLE from BOOKS"
To samo query używam jednak za pomocą Insert:
     IBCQuery1.Insert;
     IBCQuery1.FieldByName('title').AsString := edTitle.Text;
     IBCQuery1.Post;
aby odczytywać bezpośrednio
id_books := IBCQuery1.FieldByName('id_books').AsInteger;

Jednak jest błąd w IBCQuery1.Post polegający na tym, że id_books jest 
puste, choć w bazie ma triggera autoinkrementacji. Prawdopodobnie 
jeszcze przed odwołaniem do bazy programowo jest sprawdzane (?), w 
każdym razie Insert/Post nie zważa na triggera
Technical Details
Message-ID: <mr481t$1q8$1@node2.news.atman.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!agh.edu.pl!news.agh.edu.pl!newsfeed2.atman.pl!newsfeed.atman.pl!.POSTED!not-for-mail
From: Borneq <borneq@antyspam.hidden.pl>
Newsgroups: pl.comp.lang.delphi.bazy-danych
Subject: TIBCQuery Insert/Post nie zważa na triggera
 autoinkremantacji
Date: Thu, 20 Aug 2015 11:53:01 +0200
Organization: ATMAN - ATM S.A.
Lines: 23
Message-ID: <mr481t$1q8$1@node2.news.atman.pl>
NNTP-Posting-Host: 91.239.205.105
Mime-Version: 1.0
X-Trace: node2.news.atman.pl 1440064381 1864 91.239.205.105 (20 Aug 2015 09:53:01 GMT)
X-Complaints-To: usenet@atman.pl
NNTP-Posting-Date: Thu, 20 Aug 2015 09:53:01 +0000 (UTC)
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0
X-Mozilla-News-Host: news://news.atman.pl:119
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit