Subject RE: [firebird-support] using exists in SPs and triggers
Author Thomas Steinmaurer
> Is this kind of usage of exist 'legal'?
>
> CREATE PROCEDURE TEST_PROC (IN_PARAM1 TIMESTAMP) RETURNS (OUT_PARAM1
> SMALLINT)
> AS
> DECLARE VARIABLE V_MONTH SMALLINT;
> begin
> v_month = extract(month from :in_param1);
> if (exists(select * from test_view r where r.rdb$relation_id >
> :v_month)) then begin
> OUT_PARAM1 = 10;
> suspend;
> end
> end
>
> I'm having a problem with it in another SP. I tried to reproduce it in
> this SP, but this one works as expected.

Do you want to query what relations where created after the
current month? ;-)

Seriously, your usage of EXISTS seems to be. Well, I'm usually
using it without using the * operator, because a simple

EXISTS(SELECT 1 FROM ...)

will do the job as well.

Why do you think that your usage of EXISTS isn't legal? Do
you get any error message? How do you call TEST_PROC? You
know that you have to call it as a selectable stored
procedure, that means with:

SELECT * FROM TEST_PROC(...);



HTH,
Thomas Steinmaurer

Logging/Auditing Suite for InterBase and Firebird
http://www.iblogmanager.com
Logging/Auditing Suite for Advantage Database Server 7
http://www.adslogmanager.com