3 ms·
Perhaps I'm interpreting your code incorrectly, but this seems like you can do this with PG as well? You just define a custom type and use that type in the "ret
by RedShift1 6y ago
Perhaps I'm interpreting your code incorrectly, but this seems like you can do this with PG as well? You just define a custom type and use that type in the "returning" clause? You can easily define a bunch of scalars (customer_id, first_name, ...) and an array (customer_orders[]) inside this type.
- Tostino 6y agoThat is one way to do it, kinda sucks compared to just returning multiple result sets because you have the overhead of maintaining those custom types for every type of query you're going to need. I don't personally like that solution much for complicated apps which will have a ton of queries written against their database.
- RedShift1 6y agoI see that as an advantage. What you're really doing is defining the interface for that function, and once the function is in use, you can't just change it willy nilly. Having to alter the type is in some way a "are you sure you want to do that?" layer.
- Tostino 6y agoIt would be extremely nice if you could just specify that directly in the function and not have that sprawl where it's unnecessary. For a single result set you do exactly that with PG, just wish it would allow you to specify multiple.