AndréLB
DTDrizzle Team
•Created by AndréLB on 1/4/2025 in #help
Upsert on foreign key changes serial ID
The problem is that that even when doing nothing the employeeStoreID is being updated on the employeeStore table. This means the employeeCheckin table has an outdated value for employeeStoreID.
I use employeeStoreID as a foreign key in many places so it won't be an easy refactor to have a composite key.
4 replies
DTDrizzle Team
•Created by AndréLB on 9/9/2024 in #help
Getting total sales by service
I have the tables orderListing and orders:
I want a function that returns:
I have unit costs and amount of each service in order listing but I want total sold for each service. I am stuck getting the sum of cost*amount for each serviceID. As there can be many orderListings with the same serviceID and since there is a multiplication it is too tricky.
I would also like to select by orderStatus and by submissionTime but that I should be able to figure out easily
1 replies
DTDrizzle Team
•Created by AndréLB on 8/17/2024 in #help
Joins with results in arrays
I would like a single select with joins that gives me more or less the same result. Something along the lines of:
139 replies
DTDrizzle Team
•Created by AndréLB on 7/17/2024 in #help
Update with array of objects
How do I do an update with an array of object where I update multiple fields in the object. The examples I find are just updating one field in the row.
4 replies
DTDrizzle Team
•Created by AndréLB on 4/29/2024 in #help
onConflictDoUpdate error, there is no unique or exclusion constraint matching the ON CONFLICT
My goal is to insert new data into the storespecialhours table. If there is a conflict with specialDateID or (storeID and Day) then do an update. Lots of rows can have conflicting dayOpen, dayClose or day attributes that conflict.
How do I fix it? Currently I am getting:
there is no unique or exclusion constraint matching the ON CONFLICT specification
3 replies
DTDrizzle Team
•Created by AndréLB on 4/7/2024 in #help
Best way to use select in a function that is returning a specific type
I don't understand why this code works. It doesn't return something of type VerifyUser yet the type checker doesn't complain.
I am getting:
Instead of:
2 replies