0

I have some strings in an audit table that describe an entire row that was deleted. Ie, they look like:

'(029e99b4-6ea2-46e4-a89d-91d96aff41c4/4/5b,029e99b4-6ea2-46e4-a89d-91d96aff41c4,029e99b4-6ea2-46e4-a89d-91d96aff41c4,M4,short_rainy,54,Coffee,1,,2,,,2015-11-09,2,,,,,2,,)'

They were creating using the ROW() function in the useful script described here.

Now, I want to insert them into the table they came from. It still has the same schema, so each column in the string should correspond to the correct column in the table. How can I do that?

My apologies if this has been asked already - I looked around and only found this question, which doesn't seem workable in my case because I have so many columns.

Thanks

1 Answer 1

1

Cast it to the table type before inserting:

insert into t
values
    ((
        029e99b4-6ea2-46e4-a89d-91d96aff41c4/4/5b,
        029e99b4-6ea2-46e4-a89d-91d96aff41c4,
        029e99b4-6ea2-46e4-a89d-91d96aff41c4,
        M4,short_rainy,54,Coffee,1,,2,,,2015-11-09,2,,,,,2,,
    )::t)
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.