Subject Re: [firebird-support] Re: Calling procedure from trigger
Author Lucas Franzen
Michael Vilhelmsen schrieb:

> Yes it actually gave my a little problem.
>
> I have made a small stored procedure like this (called test):
>
> begin
> ii = 0;
> while (ii < strlen(in_p)) do
> begin
> if (substr(In_P,ii,ii)='ø') then
> begin
> out_p = 'Ø';
> end
> else
> begin
> out_p = substr(In_P,ii,ii);
> end
> ii = ii + 1;
> end
> suspend;
> end
>
> Where II is a variable as integer
> in_p is varchar(30)
> out_p is varchar(30)
> This procedure get generated OK.
>
> when I define a trigger like this:
>
> if (new.varenavn1 <> old.varenavn1) then
> begin
> new.uniktvarenavn1 = test(new.varenavn1);

should read:
select out_p from test(new.varenavn1) into new.uniktvarenavn1;

or to make it a little more transparent you can do:

CREATE TRIGGER ...
AS
declare a variable NEWVAL varchar(30)
BEGIN
SELECT out_p from test ( new.varenavn1 ) into :NEWVAL:
new.uniktvarenavn1 = :NEWVAL;
END


Note:

I think what you're doing here is to set the scandinavian character "ø"
to its uppercase equivalent.
If you use the right Character set and collation you shoudl be able to
this with a simple:
new.uniktvarenavn1 = UPPER ( new.uniktvarenavn1 )
too
without having to use the stroed procedure.



Luc.