Subject Re: [IBDI] Can I do this with a procedure?
Author Ann Harrison
At 02:09 PM 6/12/00 -0300, ibase@... wrote:

>I want to make a procedure that updates the value in a field of a
>table based on a WHERE condition. Seems easy, but I couldn't
>find a sample in the Interbase documentation to do this... maybe it
>didn't come with IB 5.0 or I didn't see it.
>I think it should be something like this:
>
>CREATE PROCEDURE PONEAPROBADO1
>AS
>BEGIN
> for select aprobado from cursada
> where cursada.cod_cur in
> (select i.cod_cur from instancia i
> where (i.num_instancia=1 and i.nota is not null)
> or (i.num_instancia=2 and i.nota is not null)
> or (i.num_instancia=3 and i.nota is not null)
> )
> into :aprobado
>do
> begin
> aprobado=1;
> suspend;
> END
>end

The obvious way to do it would be:

>CREATE PROCEDURE PONEAPROBADO1
>AS
>BEGIN
> update cursada set aprobado=1
> where cursada.cod_cur in
> (select i.cod_cur from instancia i
> where (i.num_instancia=1 and i.nota is not null)
> or (i.num_instancia=2 and i.nota is not null)
> or (i.num_instancia=3 and i.nota is not null)
> )
>END


There are other ways -

Ann