This content has been marked as final. Show 3 replies
Seems you'd be better off having your update clause the other way around
MERGE INTO sales_snapshot dest USING (SELECT col_book_id, MAX (col_sales_volume) highval, MIN (col_sales_volume) lowval FROM (SELECT col_book_id, ROW_NUMBER () OVER (PARTITION BY col_book_id ORDER BY col_tran_date_time DESC) rn, col_sales_volume FROM daily_sales ) WHERE rn > 31 GROUP BY col_book_id ) src ON (src.col_book_id = dest.col_book_id) WHEN MATCHED THEN UPDATE SET dest.col_30dayhigh = src.highval, dest.col_30daylow = src.lowval
ORA-06502: PL/SQL: numeric or value error: character string buffer too small
That means you have a buffer that is too small for what is being put into it.
This is in a procedure so you need to post the code (use code tags this time - see the FAQ) for the procedure so we can see what variables it is defining and how they are being used.