Is it possible to update multiple columns of a table using a select
statement to derive the values?
For example (trying to port from Oracle to Postgres)
-- update the image record for original size image
update WPImage set (WPImageStateID, Width, Height, ContentType,
ContentLength) = (
select 3, Width, Height, ContentType, ContentLength
from WPImageHeader
where WDResourceID = pResourceID
)
where WDResourceID = pResourceID and WPSizeTypeID = 0;
I have seen mention of a Postgres (specific) feature,
update ... set .... from {other_table} where {join_condition}
Is this the most appropriate way to do the above in postgres?
update WPImage
set WPImageStateID = 3,
Width = WPImageHeader.Width,
Height = WPImageHeader.Height,
ContentType = WPImageHeader.ContentType,
ContentLength = WPImageHeader.ContentLength
where WPImage.WDResourceID = WPImageHeader.WDResourceID
and WPImage.WDResourceID = pResourceID
and WPImage.WPSizeTypeID = 0;
{where pResourceID is a variable}
Thanks
John Sidney-Woollett