Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Multiple DUAL_UNIQUE generate conflicting statements
Multiple DUAL_UNIQUE generate conflicting statements [message #49869] Wed, 23 May 2018 11:36 Go to next message
busiek is currently offline  busiek
Messages: 64
Registered: February 2011
Location: Poland
Member
This is a problem for PostgreSQL backend for sure.
TABLE(T)
    ...
    DUAL_UNIQUE(A, B)
    DUAL_UNIQUE(C, D)
END_TABLE

will generate A_script.sql containing:
...
alter table T add constraint DQ_T unique (A, B);
alter table T add constraint DQ_T unique (C, D);

Constraint names should be unique. The way to fix it is to add column names to the constraint name separated by some special symbol.
Re: Multiple DUAL_UNIQUE generate conflicting statements [message #50047 is a reply to message #49869] Wed, 27 June 2018 10:35 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
What about using UNIQUE_LIST instead?
Re: Multiple DUAL_UNIQUE generate conflicting statements [message #50048 is a reply to message #49869] Wed, 27 June 2018 15:50 Go to previous messageGo to next message
busiek is currently offline  busiek
Messages: 64
Registered: February 2011
Location: Poland
Member
Thanks, in UNIQUE_LIST you can name a constraint. I wasn't aware of that. I will use it.

Until now, I simply run A_script.sql manually, by editing the name of conflicting constraint.
Re: Multiple DUAL_UNIQUE generate conflicting statements [message #52066 is a reply to message #50048] Sun, 14 July 2019 02:30 Go to previous messageGo to next message
zsolt is currently offline  zsolt
Messages: 693
Registered: December 2005
Location: Budapest, Hungary
Contributor
Fix:
-#define DUAL_UNIQUE(k1, k2)        ATTRIBUTE("alter table @t add constraint DQ_@t unique "\
+#define DUAL_UNIQUE(k1, k2)        ATTRIBUTE("alter table @t add constraint DQ_@t$" #k1 #k2 " unique "\
                                              "(" #k1 ", " #k2 ");",\
-                                             "alter table @t drop constraint DQ_@t;")
+                                             "alter table @t drop constraint DQ_@t$" #k1 #k2 ";")

Re: Multiple DUAL_UNIQUE generate conflicting statements [message #52084 is a reply to message #52066] Wed, 17 July 2019 10:42 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Thanks, applied, with a small addition:

#define DUAL_UNIQUE(k1, k2)        ATTRIBUTE("alter table @t add constraint DQ_@t$" #k1 "$" #k2 " unique "\
                                             "(" #k1 ", " #k2 ");",\
                                             "alter table @t drop constraint DQ_@t$" #k1 "$" #k2 ";")
Previous Topic: SQLite On delete cascade .sch ?
Next Topic: BOOL in SQLite
Goto Forum:
  


Current Time: Thu Mar 28 18:14:55 CET 2024

Total time taken to generate the page: 0.01033 seconds