amazon-redshift-utils icon indicating copy to clipboard operation
amazon-redshift-utils copied to clipboard

sp_pivot_for needs to handle empty sets gracefully

Open Jeffrey-Lieske opened this issue 4 years ago • 0 comments

sp_pivot_for will run into an issue with the dynamic sql when it tries to pivot and there are no rows in the pivot table.

To reproduce this you can run one of the example CALLs in the SP but truncate the table ahead of time.

A solution could just be to run a quick count(*) on the source table and return an error if the value = 0

Jeffrey-Lieske avatar Nov 29 '21 19:11 Jeffrey-Lieske