Wednesday, August 15, 2012

PL-SQL function, the basics

There are Procedures and Functions.

A Function is declared like this:

CREATE OR REPLACE FUNCTION SHOULDALERT 
(
  p_technicalmessageid IN VARCHAR2  
) RETURN NUMBER IS 
v_count integer;
BEGIN
  select count(*) into v_count from nesoa2_alert_instances where technicalmessageid = p_technicalmessageid 
   and status in ('CREATED', 'PROCESSED') ;
  return v_count;
END SHOULDALERT;



and can be invoked as

select SHOULDALERT('BLABLA^PuO20111212_164122_1640.txt^AVE^1344962989697') from dual;



No comments: