mercredi 9 septembre 2020

If count(column) Then Select in Oracle

can I do something like this in oracle? I want to check if the result dataset is more than 20k records then DO NOT SELECT, if less than 20k then SELECT.

DECLARE cnt number;
BEGIN
select count(*) into cnt from ir_mpn where material LIKE '%A00%';
IF cnt > 20000 THEN
   select manuf_part, material, vendor, vendor_name from ir_mpn where material LIKE '%A00%';
END IF;
END;

I tried to do like this but shows error:

ORA-06550: line 6, column 4:
PLS-00428: an INTO clause is expected in this SELECT statement

Any better suggestions for me to do this?

Aucun commentaire:

Enregistrer un commentaire