Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Wywala mi błąd o braku sekwencji
pgrzelka
post
Post #1





Grupa: Zarejestrowani
Postów: 313
Pomógł: 24
Dołączył: 9.08.2008
Skąd: Kielce

Ostrzeżenie: (0%)
-----


Witam

mam taką tabelę
Kod
CREATE TABLE group_has_users (
    group_id integer DEFAULT 0 NOT NULL,
    users_id integer NOT NULL
);


ALTER TABLE public.group_has_users OWNER TO postgres;
ALTER TABLE ONLY group_has_users
    ADD CONSTRAINT group_has_users_pkey PRIMARY KEY (group_id, users_id);

CREATE INDEX fk_group_has_users_group1 ON group_has_users USING btree (group_id);

CREATE INDEX fk_group_has_users_users1 ON group_has_users USING btree (users_id);

ALTER TABLE ONLY group_has_users
    ADD CONSTRAINT group_has_users_group_id_fkey FOREIGN KEY (group_id) REFERENCES "group"(id) ON DELETE CASCADE;

ALTER TABLE ONLY group_has_users
    ADD CONSTRAINT group_has_users_users_id_fkey FOREIGN KEY (users_id) REFERENCES users(id) ON DELETE CASCADE;


podczas dodawania rekordu mam taki błąd
Kod
undefined table: 7 ERROR:  relation "group_has_users_id_seq" does not exist
LINE 1: SELECT CURRVAL('group_has_users_id_seq')


nie chcę używać żadnych sekwencji w tej tabeli, co mogę zmienić w zapytaniu tworzącym tą tabelę ?
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
phpion
post
Post #2





Grupa: Moderatorzy
Postów: 6 072
Pomógł: 861
Dołączył: 10.12.2003
Skąd: Dąbrowa Górnicza




Szukasz błędu w złym miejscu. Twój kod tworzący tabelę jest poprawny. Błąd pewnie leży po stronie aplikacji, która stara się odczytać aktualną wartość sekwencji po wstawieniu rekordu do tabeli, a że takowej sekwencji nie ma stąd wywala błąd.
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 24.08.2025 - 23:13