Subject | Re: problem with "for" in procedure |
---|---|
Author | ronaldorezende |
Post date | 2003-05-16T10:31:06Z |
The test that I'm doing is in the IBExpert. The metadata that
ibexpert create for procedure is a quite strange.
SET TERM ^ ;
CREATE PROCEDURE DESVIO_PADRAO_MATERIA (
CURSO INTEGER,
DISCIPLINA SMALLINT,
FASE SMALLINT,
TURMA VARCHAR(10) CHARACTER SET WIN1252,
NUMERO_PROVA SMALLINT,
MEDIA DOUBLE PRECISION,
QTD_ALUNO SMALLINT)
RETURNS (
Y INTEGER,
DPM DOUBLE PRECISION)
AS
BEGIN
EXIT;
END^
SET TERM ; ^
SET TERM ^ ;
ALTER PROCEDURE DESVIO_PADRAO_MATERIA (
CURSO INTEGER,
DISCIPLINA SMALLINT,
FASE SMALLINT,
TURMA VARCHAR(10) CHARACTER SET WIN1252,
NUMERO_PROVA SMALLINT,
MEDIA DOUBLE PRECISION,
QTD_ALUNO SMALLINT)
RETURNS (
Y INTEGER,
DPM DOUBLE PRECISION)
AS
DECLARE VARIABLE SOMA DOUBLE PRECISION;
DECLARE VARIABLE NOTA_PROVA DOUBLE PRECISION;
DECLARE VARIABLE X DOUBLE PRECISION;
DECLARE VARIABLE POTENCIA DOUBLE PRECISION;
begin
SOMA = 0.0;
Y = 4;
FOR
select
DPA.NOTA_PROVA
from DIARIO_PROVA_ALUNO DPA
where
DPA.NOTA_PROVA is not null and
DPA.ID_CURSO = :CURSO and
DPA.ID_DISCIPLINA = :DISCIPLINA and
DPA.ID_FASE = :FASE and
DPA.ID_TURMA = :TURMA and
DPA.NUMERO_PROVA = :NUMERO_PROVA
into :NOTA_PROVA
DO BEGIN
Y = Y+1;
X = NOTA_PROVA - MEDIA;
POTENCIA = POWER(X,2);
SOMA = SOMA + POTENCIA;
END
SOMA = SOMA / qtd_aluno;
DPM = SQRT(SOMA);
suspend;
end
^
SET TERM ; ^
--- In ib-support@yahoogroups.com, "Thomas Steinmaurer" <ts@i...>
wrote:
ibexpert create for procedure is a quite strange.
SET TERM ^ ;
CREATE PROCEDURE DESVIO_PADRAO_MATERIA (
CURSO INTEGER,
DISCIPLINA SMALLINT,
FASE SMALLINT,
TURMA VARCHAR(10) CHARACTER SET WIN1252,
NUMERO_PROVA SMALLINT,
MEDIA DOUBLE PRECISION,
QTD_ALUNO SMALLINT)
RETURNS (
Y INTEGER,
DPM DOUBLE PRECISION)
AS
BEGIN
EXIT;
END^
SET TERM ; ^
SET TERM ^ ;
ALTER PROCEDURE DESVIO_PADRAO_MATERIA (
CURSO INTEGER,
DISCIPLINA SMALLINT,
FASE SMALLINT,
TURMA VARCHAR(10) CHARACTER SET WIN1252,
NUMERO_PROVA SMALLINT,
MEDIA DOUBLE PRECISION,
QTD_ALUNO SMALLINT)
RETURNS (
Y INTEGER,
DPM DOUBLE PRECISION)
AS
DECLARE VARIABLE SOMA DOUBLE PRECISION;
DECLARE VARIABLE NOTA_PROVA DOUBLE PRECISION;
DECLARE VARIABLE X DOUBLE PRECISION;
DECLARE VARIABLE POTENCIA DOUBLE PRECISION;
begin
SOMA = 0.0;
Y = 4;
FOR
select
DPA.NOTA_PROVA
from DIARIO_PROVA_ALUNO DPA
where
DPA.NOTA_PROVA is not null and
DPA.ID_CURSO = :CURSO and
DPA.ID_DISCIPLINA = :DISCIPLINA and
DPA.ID_FASE = :FASE and
DPA.ID_TURMA = :TURMA and
DPA.NUMERO_PROVA = :NUMERO_PROVA
into :NOTA_PROVA
DO BEGIN
Y = Y+1;
X = NOTA_PROVA - MEDIA;
POTENCIA = POWER(X,2);
SOMA = SOMA + POTENCIA;
END
SOMA = SOMA / qtd_aluno;
DPM = SQRT(SOMA);
suspend;
end
^
SET TERM ; ^
--- In ib-support@yahoogroups.com, "Thomas Steinmaurer" <ts@i...>
wrote:
> > My original code is this below.this
> > The result of the query of ther "for" give me 37 records.
> > The result of the output variable Y is 4. The right result for
> > variable is not for.
> >
> > begin
> > SOMA = 0.0;
> > Y = 4;
> > FOR
> > select
> > DPA.NOTA_PROVA
> > from DIARIO_PROVA_ALUNO DPA
> > where
> > DPA.NOTA_PROVA is not null and
> > DPA.ID_CURSO = :CURSO and
> > DPA.ID_DISCIPLINA = :DISCIPLINA and
> > DPA.ID_FASE = :FASE and
> > DPA.ID_TURMA = :TURMA and
> > DPA.NUMERO_PROVA = :NUMERO_PROVA
> > into :NOTA_PROVA
> > DO BEGIN
> > Y = Y+1;
> > X = NOTA_PROVA - MEDIA;
> > POTENCIA = POWER(X,2);
> > SOMA = SOMA + POTENCIA;
> > END
> > SOMA = SOMA / qtd_aluno;
> > DPM = SQRT(SOMA);
> > suspend;
> > end
>
>
> Can you show us the stored procedure header too?
>
> You'd best posting the entire stored procedure DDL
> including the input/output parameters.
>
> How do you use the stored procedure? As selectable or
> executable stored procedure?
>
> Regards,
> Thomas.