Quantcast
Channel: User Schwern - Stack Overflow
Viewing all articles
Browse latest Browse all 581

Answer by Schwern for plpgsql does not handle exception

$
0
0

For select to raise NO_DATA_FOUND you must use the strict option. The intent is when you expect exactly ONE row to be returned.

If the STRICT option is specified, the command must return exactly one row or a run-time error will be reported, either NO_DATA_FOUND (no rows) or TOO_MANY_ROWS (more than one row)...

    SELECT qty,total_amount       INTO STRICT v_qty,v_total_amount    FROM stock_holdings    WHERE account_id = 1       AND ticker_cd = 'XYZ';

Demonstration.


Viewing all articles
Browse latest Browse all 581

Trending Articles