0

I want to do something like this inside a stored procedure so I can see the result of an insert statement for debugging:

thing := array_to_string(ARRAY(select * from some_table limit 1 ));
raise info 'insert result: %',thing;

Where all the columns of some_table get concatenated into an array

Is there a way to do this?

1 Answer 1

1

Arrays are of uniform type. You can't have an array where different entries have different data types.

What you appear to want is an anonymous row (record).

DECLARE
    debug_row record;
BEGIN
    SELECT * FROM some_table LIMIT 1 INTO debug_row;
    RAISE INFO 'insert result: %',debug_row;

Note that this only works for a single row result. For multiple rows you can call the query as the input for a loop and iterate over the result. There are examples in the PL/PgSQL documentation.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.