I am trying to create a table with a timestamp column. The problem is that I want the combination of month and year to be unique. I tried this, but this does not help:
CREATE TABLE adempiere.SOIP_Deudas (
SOIP_Deudas_ID numeric(10) NOT NULL PRIMARY KEY,
ad_client_id numeric(10) NOT NULL,
ad_org_id numeric(10) NOT NULL,
updatedby numeric(10) NOT NULL,
createdby numeric(10) NOT NULL,
updated timestamp NOT NULL,
created timestamp NOT NULL,
isactive char(1) DEFAULT 'Y'::bpchar NOT NULL,
SOIP_Departamentos_ID numeric(10) NOT NULL,
fecha timestamp NOT NULL,
monto real NOT NULL DEFAULT 0,
FOREIGN KEY (SOIP_Departamatos_ID) REFERENCES SOIP_Departamentos(SOIP_Departamentos_ID),
UNIQUE (EXTRACT (MONTH FROM TIMESTAMP fecha), EXTRACT(YEAR FROM TIMESTAMP fecha))
)
Any idea on how I can do this without specific columns of the year and month?
Thank.
source
share