On Mon, Mar 28, 2016 at 2:32 AM, Sterpu Victor wrote:
*table1*
> id
> nr - integer
>
> *table2*
> id
> id_table1 - FK in Table 1
> valid_from - timestamp
>
> There must be unique values for:
> - nr - from table1
> and
> - YEAR(MIN(valid_from)) from table 2
>
Just trying to understand your goal
Le Mon, 28 Mar 2016 12:44:51 +0200,
Emre Hasegeli a écrit :
> > Could I use lock tables to fix this? Is postgres automaticaly locking a
> > table while running a trigger on that table?
>
> You can use LOCK TABLE. See the documentation:
>
> http://www.postgresql.org/docs/current/static/explicit-
> Could I use lock tables to fix this? Is postgres automaticaly locking a
> table while running a trigger on that table?
You can use LOCK TABLE. See the documentation:
http://www.postgresql.org/docs/current/static/explicit-locking.html
--
Sent via pgsql-general mailing list (pgsql-general@post
-- Original Message --
From: "Emre Hasegeli"
To: "Sterpu Victor"
Cc: "PostgreSQL General"
Sent: 28/3/2016 12:06:23 PM
Subject: Re: [GENERAL] Unique values on multiple tables
I have 2 tables and I must make asure unique values like this.
table1
> I have 2 tables and I must make asure unique values like this.
>
> table1
> id
> nr - integer
>
> table2
> id
> id_table1 - FK in Table 1
> valid_from - timestamp
>
> There must be unique values for:
> - nr - from table1
> and
> - YEAR(MIN(valid_from)) from table 2
In situations like this, I add
I think I fixed the problem by executing the function AFTER insert or
update but I'm not sure.
Until now the execution was before insert or update.
-- Original Message --
From: "Sterpu Victor"
To: "PostgreSQL General"
Sent: 28/3/2016 9:32:17 AM
Subject: [
Hello
I have 2 tables and I must make asure unique values like this.
table1
id
nr - integer
table2
id
id_table1 - FK in Table 1
valid_from - timestamp
There must be unique values for:
- nr - from table1
and
- YEAR(MIN(valid_from)) from table 2
I already made this with a function but in rare c