You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I understand the example in the Docs for a SELECT query but
I have a query where I want to UPDATE my "bookings" table and then JOIN my "invoices" table
I've gotten close but this is my current query:
-- name: UpdateBooking :one
WITH booking_with_invoice AS (
SELECT sqlc.embed(bookings), sqlc.embed(invoices)
FROM bookings
JOIN invoices ON invoices.booking_id = bookings.id
)
UPDATE booking_with_invoice
SET
start_date = COALESCE(sqlc.narg(start_date), start_date),
end_date = COALESCE(sqlc.narg(end_date), end_date),
status = COALESCE(sqlc.narg(status), status)
WHERE bookings.id = @id
RETURNING *;
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm fairly new to Postgres and sqlc.
I understand the example in the Docs for a SELECT query but
I have a query where I want to UPDATE my "bookings" table and then JOIN my "invoices" table
I've gotten close but this is my current query:
And my generated code:
As you can see, the
UpdateBookingRow
struct showsinterface{}
for both fields but I want the Booking and Invoice struct.Beta Was this translation helpful? Give feedback.
All reactions