I have a function
CREATE OR REPLACE FUNCTION rules_broken(ordref bigint)
RETURNS character varying AS
DECLARE
rules RECORD;
rulesbroken character varying;
ordsource character varying;
BEGIN
FOR rules IN SELECT rul_id,rul_sql FROM sd_stp_rules ORDER BY rul_id LOOP
EXECUTE rules.rul_sql || ' AND ord_id =' || ordref;
If found then
rulesbroken:=rulesbroken || rules.rul_id || ';';
end if;
END LOOP;
RETURN rulesbroken;
END;
In my table sd_STP_rules.rul_sql I had simple selects e.g.
SELECT COUNT(*) FROM d_order WHERE ....
This bombs. I read that I should use a PERFORM statement but again this bombs.
Anybody have a clue of the correct syntax of the PERFOM statement.
I have been trying PERFORM Select Count(*) FROM d_order WHERE ....
and also PERFORM Count(*) FROM d_order WHERE ....
but no joy
any help here would be much appreciated ...
Thanks W
WP
CREATE OR REPLACE FUNCTION rules_broken(ordref bigint)
RETURNS character varying AS
DECLARE
rules RECORD;
rulesbroken character varying;
ordsource character varying;
BEGIN
FOR rules IN SELECT rul_id,rul_sql FROM sd_stp_rules ORDER BY rul_id LOOP
EXECUTE rules.rul_sql || ' AND ord_id =' || ordref;
If found then
rulesbroken:=rulesbroken || rules.rul_id || ';';
end if;
END LOOP;
RETURN rulesbroken;
END;
In my table sd_STP_rules.rul_sql I had simple selects e.g.
SELECT COUNT(*) FROM d_order WHERE ....
This bombs. I read that I should use a PERFORM statement but again this bombs.
Anybody have a clue of the correct syntax of the PERFOM statement.
I have been trying PERFORM Select Count(*) FROM d_order WHERE ....
and also PERFORM Count(*) FROM d_order WHERE ....
but no joy
any help here would be much appreciated ...
Thanks W
WP