Fórum Returns de Store Procedure sem decimal #51804
26/07/2005
0
Olá!!!
Uso Delphi 7 e o Interbase 6.5
Crie uma STORE PROCEDURE para me retornar o total de debitos e
creditos.
....
returns (total numeric(15,2)
só que não me retorna a parte decimal, somente a parte inteira do valor.
Ex.: 8162,04 me retorna 8162
Daí troquei o tipo por double precision e me retornou correto.
Então o que está acontecendo com o tipo numeric ou decimal?
É correto usar o double precision neste caso?
Obrigado pela ajuda!!!
José. :D
Uso Delphi 7 e o Interbase 6.5
Crie uma STORE PROCEDURE para me retornar o total de debitos e
creditos.
....
returns (total numeric(15,2)
só que não me retorna a parte decimal, somente a parte inteira do valor.
Ex.: 8162,04 me retorna 8162
Daí troquei o tipo por double precision e me retornou correto.
Então o que está acontecendo com o tipo numeric ou decimal?
É correto usar o double precision neste caso?
Obrigado pela ajuda!!!
José. :D
Ejose
Curtir tópico
+ 0
Responder
Posts
27/07/2005
Afarias
Bom, o problema não está no campo NUMERIC, seria interessante q vc colocasse o código do SP aqui para ver onde está realmente o erro.
T+
T+
Responder
Gostei + 0
27/07/2005
Ejose
Obrigado pela atenção!!!
// Criacao da SP.
SQLstmt := ´CREATE PROCEDURE CTSALDOGERAL1(EMPRESA INTEGER, EMPRESAF INTEGER,´;
SQLstmt := SQLstmt + ´ LOCAL INTEGER,´;
SQLstmt := SQLstmt + ´ DATAI CHAR(10),´;
SQLstmt := SQLstmt + ´ DATAF CHAR(10),´;
SQLstmt := SQLstmt + ´ CONTA VARCHAR(20),´;
SQLstmt := SQLstmt + ´ TIPO VARCHAR(1))´;
//SQLstmt := SQLstmt + ´ returns (total NUMERIC(15,2))´; (ANTES)
SQLstmt := SQLstmt + ´ returns (total double precision)´; (DEPOIS)
// Com double precision funcionou.
SQLstmt := SQLstmt + ´ as begin´;
SQLstmt := SQLstmt + ´ select sum(valor) from CTMOVA´;
SQLstmt := SQLstmt + ´ where df is null´;
SQLstmt := SQLstmt + ´ and EMPRESA >= :EMPRESA and EMPRESA <= :EMPRESAF´;
SQLstmt := SQLstmt + ´ and CONTA = :CONTA´;
SQLstmt := SQLstmt + ´ and DATAL >= :DATAI and DATAL <= :DATAF´;
SQLstmt := SQLstmt + ´ and TIPO = :TIPO´;
SQLstmt := SQLstmt + ´ into :total;´;
SQLstmt := SQLstmt + ´ end´;
DMbd1.SQLconn1.Execute(SQLstmt,nil,nil);
// Como eu chamo a SP.
dmbd12.SPct.StoredProcName := ´CTSALDOGERAL1´;
dmbd12.SPct.ParamByName(´EMPRESA´).AsInteger := Strtoint(sEmpresa[2]);
dmbd12.SPct.ParamByName(´EMPRESAF´).AsInteger := Strtoint(sEmpresa[2]);
dmbd12.SPct.ParamByName(´LOCAL´).AsInteger := aLocal[0];
dmbd12.SPct.ParamByName(´DATAI´).AsString := sdatamovi;
dmbd12.SPct.ParamByName(´DATAF´).AsString := sdataiatualmenos1;
dmbd12.SPct.ParamByName(´CONTA´).AsString := wconta;
dmbd12.SPct.ParamByName(´TIPO´).AsString := ´0´; //Debito
dmbd12.SPct.ExecProc;
wDperiodoA := dmbd12.SPct.Params[7].AsFloat;
label5.Caption := floattostr(wdperiodoa); //Só coloquei para teste.
dmbd12.SPct.StoredProcName := ´CTSALDOGERAL1´;
dmbd12.SPct.ParamByName(´EMPRESA´).AsInteger := Strtoint(sEmpresa[2]);
dmbd12.SPct.ParamByName(´EMPRESAF´).AsInteger := Strtoint(sEmpresa[2]);
dmbd12.SPct.ParamByName(´LOCAL´).AsInteger := aLocal[0];
dmbd12.SPct.ParamByName(´DATAI´).AsString := sdatamovi;
dmbd12.SPct.ParamByName(´DATAF´).AsString := sdataiatualmenos1;
dmbd12.SPct.ParamByName(´CONTA´).AsString := wconta;
dmbd12.SPct.ParamByName(´TIPO´).AsString := ´1´; //Crédito
dmbd12.SPct.ExecProc;
wCperiodoA := dmbd12.SPct.Params[7].AsFloat;
label6.Caption := floattostr(wcperiodoa); //Só coloquei para teste.
// Criacao da SP.
SQLstmt := ´CREATE PROCEDURE CTSALDOGERAL1(EMPRESA INTEGER, EMPRESAF INTEGER,´;
SQLstmt := SQLstmt + ´ LOCAL INTEGER,´;
SQLstmt := SQLstmt + ´ DATAI CHAR(10),´;
SQLstmt := SQLstmt + ´ DATAF CHAR(10),´;
SQLstmt := SQLstmt + ´ CONTA VARCHAR(20),´;
SQLstmt := SQLstmt + ´ TIPO VARCHAR(1))´;
//SQLstmt := SQLstmt + ´ returns (total NUMERIC(15,2))´; (ANTES)
SQLstmt := SQLstmt + ´ returns (total double precision)´; (DEPOIS)
// Com double precision funcionou.
SQLstmt := SQLstmt + ´ as begin´;
SQLstmt := SQLstmt + ´ select sum(valor) from CTMOVA´;
SQLstmt := SQLstmt + ´ where df is null´;
SQLstmt := SQLstmt + ´ and EMPRESA >= :EMPRESA and EMPRESA <= :EMPRESAF´;
SQLstmt := SQLstmt + ´ and CONTA = :CONTA´;
SQLstmt := SQLstmt + ´ and DATAL >= :DATAI and DATAL <= :DATAF´;
SQLstmt := SQLstmt + ´ and TIPO = :TIPO´;
SQLstmt := SQLstmt + ´ into :total;´;
SQLstmt := SQLstmt + ´ end´;
DMbd1.SQLconn1.Execute(SQLstmt,nil,nil);
// Como eu chamo a SP.
dmbd12.SPct.StoredProcName := ´CTSALDOGERAL1´;
dmbd12.SPct.ParamByName(´EMPRESA´).AsInteger := Strtoint(sEmpresa[2]);
dmbd12.SPct.ParamByName(´EMPRESAF´).AsInteger := Strtoint(sEmpresa[2]);
dmbd12.SPct.ParamByName(´LOCAL´).AsInteger := aLocal[0];
dmbd12.SPct.ParamByName(´DATAI´).AsString := sdatamovi;
dmbd12.SPct.ParamByName(´DATAF´).AsString := sdataiatualmenos1;
dmbd12.SPct.ParamByName(´CONTA´).AsString := wconta;
dmbd12.SPct.ParamByName(´TIPO´).AsString := ´0´; //Debito
dmbd12.SPct.ExecProc;
wDperiodoA := dmbd12.SPct.Params[7].AsFloat;
label5.Caption := floattostr(wdperiodoa); //Só coloquei para teste.
dmbd12.SPct.StoredProcName := ´CTSALDOGERAL1´;
dmbd12.SPct.ParamByName(´EMPRESA´).AsInteger := Strtoint(sEmpresa[2]);
dmbd12.SPct.ParamByName(´EMPRESAF´).AsInteger := Strtoint(sEmpresa[2]);
dmbd12.SPct.ParamByName(´LOCAL´).AsInteger := aLocal[0];
dmbd12.SPct.ParamByName(´DATAI´).AsString := sdatamovi;
dmbd12.SPct.ParamByName(´DATAF´).AsString := sdataiatualmenos1;
dmbd12.SPct.ParamByName(´CONTA´).AsString := wconta;
dmbd12.SPct.ParamByName(´TIPO´).AsString := ´1´; //Crédito
dmbd12.SPct.ExecProc;
wCperiodoA := dmbd12.SPct.Params[7].AsFloat;
label6.Caption := floattostr(wcperiodoa); //Só coloquei para teste.
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)