🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.delphi.bazy-danych
4 messages
4 total messages Started by Borneq Mon, 17 Aug 2015 21:46
Problemy z autoinkrementacją klucza w Firebird
#82558
Author: Borneq
Date: Mon, 17 Aug 2015 21:46
26 lines
1500 bytes
Pole kluczowe AUTHORS.ID oznaczyłem że ma mieć generator 
autoinkremantacji - GEN_AUTHORS_ID.
To nie wystarcza, potrzebny trigger.
Zrobiłem
--------------------
SET TERM ^ ;

CREATE trigger authors_bi0 for authors
active before insert position 0
AS
begin
   if (AUTHORS.ID is NULL) then AUTHORS.ID = GEN_ID(GEN_AUTHORS_ID, 1);
end^

SET TERM ; ^
-------------------
Nie wiem, co znaczy position 0
Ale jest błąd:
Column does not belong to referenced table.
Dynamic SQL Error.
SQL error code = -206.
Column unknown.
AUTHORS.ID.
At line 5, column 15.
----
Nie wiem czemu, taka kolumna istnieje a jej nie znajduje
Re: Problemy z autoinkrementacją klucza w Firebird
#82559
Author: Borneq
Date: Mon, 17 Aug 2015 21:52
12 lines
1282 bytes
W dniu 17.08.2015 o 23:46, Borneq pisze:
>    if (AUTHORS.ID is NULL) then AUTHORS.ID = GEN_ID(GEN_AUTHORS_ID, 1);

> Column unknown.
> AUTHORS.ID.
> At line 5, column 15.
> ----
> Nie wiem czemu, taka kolumna istnieje a jej nie znajduje

Już wiem!
Zamiast AUTHORS.ID powinno być NEW.ID, tak jak w przykładach, gdzie 
myśłałem że NEW to nazwa tabeli.
Re: Problemy z autoinkrementacją klucza w Firebird
#82560
Author: Borneq
Date: Mon, 17 Aug 2015 23:56
14 lines
1401 bytes
W dniu 17.08.2015 o 23:52, Borneq pisze:
> Już wiem!
> Zamiast AUTHORS.ID powinno być NEW.ID, tak jak w przykładach, gdzie
> myśłałem że NEW to nazwa tabeli.

jest problem z WHERE
nie działa w IBExpercie
SELECT * FROM BOOKS_AUTHORS where AUTHORS=1
ani
SELECT * FROM BOOKS_AUTHORS where BOOKS_AUTHORS.AUTHORS=1
ani
SELECT * FROM BOOKS_AUTHORS r where r.AUTHORS=1

chyba trzeba coś wstawić tak jak tam było NEW, tylko coś innego.
Re: Problemy z autoinkrementacją klucza w Firebird
#82561
Author: Borneq
Date: Tue, 18 Aug 2015 00:24
10 lines
1221 bytes
W dniu 18.08.2015 o 01:56, Borneq pisze:
> SELECT * FROM BOOKS_AUTHORS r where r.AUTHORS=1
>
> chyba trzeba coś wstawić tak jak tam było NEW, tylko coś innego.


zadziałało:
select a.*
from books_authors a
where a.author=1
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads