Fórum Arithmetic exception, numeric overflow,or string(Não encont) #325051

10/07/2006

0

Bom dia pessoal, estou no seguinte dilema... tenho um form e nele faço o cadastro de um cliente. Porém, quando acabo de fazer o cadastro do cliente eu posso continuar fazendo as alterações necessárias nele e depois será dado um update, com informações adicionais. Vamos ao problema: Se eu entro no form, faço o cadastro básico do cliente e fecho, tudo dá certo. Aí eu acesso o cadastro novamente e edito e dou o update, tb funciona perfeitamente.
O problema está justamente quando eu faço o cadastro, o cadastro é efetivado aí eu pego e continuo preenchendo as infos e depois dou o update, aí chega a bendita msg: ´Arithmetic exception, numeric overflow,or string truncation´

Alguém pode me ajudar... li algo sobre acentos, campos maiores, porém meu sistema não tem nada disso...


Flaviobrazuca

Flaviobrazuca

Responder

Posts

10/07/2006

Sremulador

voce deve estar tentando gravar uma quantoidade de informações maior do que aceita no campo de db


Responder

Gostei + 0

10/07/2006

Flaviobrazuca

sremulador, como havia dito acima, eu já tinha verificado isto... não é o meu caso... valew... outra sugestão??


Responder

Gostei + 0

17/07/2006

Flaviobrazuca

Bem pessoal... meu sql final está ficando assim:

TABELA:
CREATE TABLE CLIENTE (COD_AUX_GERAL INTEGER NOT NULL PRIMARY KEY, COD_CLIENTE VARCHAR(7), /* 2 LETRAS + 5 NÚMEROS */ NM_CLIENTE VARCHAR(50), DT_NASC DATE, SEXO CHAR(1), NATURALIDADE VARCHAR(40), CPF VARCHAR(14), /* 000.000.000-00 = 14 */ RG VARCHAR(14), EMISSAO_RG DATE, CIDADE_RG VARCHAR(40), UF_RG CHAR(2), CEP VARCHAR(9), /* 00000-000 = 9 */ NUMERO VARCHAR(6), COMPLEMENTO VARCHAR(60), FONE VARCHAR(13), /* (00)0000-0000 = 13 */ FONE_RECADO VARCHAR(13), /* (00)0000-0000 = 13 */ CELULAR VARCHAR(13), /* (00)0000-0000 = 13 */ PAI VARCHAR(60), MAE VARCHAR(60), EMAIL VARCHAR(40), COD_EST_CIVIL INTEGER, CONJUGE VARCHAR(60), COD_PROFISSAO INTEGER, COD_EMPRESA INTEGER, COD_CARGO INTEGER, COD_STATUS INTEGER, DT_CADASTRO DATE, FOTO BLOB, OBS VARCHAR(255), /* VARCHAR(250) */ PONTO_REFERENCIA VARCHAR(255), FOREIGN KEY (COD_EST_CIVIL) REFERENCES EST_CIVIL (COD_EST_CIVIL), FOREIGN KEY (COD_STATUS) REFERENCES STATUS (COD_STATUS), FOREIGN KEY (COD_PROFISSAO) REFERENCES PROFISSAO (COD_PROFISSAO), FOREIGN KEY (COD_EMPRESA) REFERENCES EMPRESA (COD_EMPRESA), FOREIGN KEY (COD_CARGO) REFERENCES CARGO (COD_CARGO) );


Meu sql de inserção está funcionando perfeitamente. Então, na mesma tela, após eu cadastrar o cliente eu continuo e faço o update:
update cliente set nm_cliente=´ANTONIO PEDRO´, dt_nasc=´29.05.1951´, sexo=´MASCULINO´, naturalidade=´SAO PAULO´, cpf=´123.456.789-10´, rg=´128374 SSPSP´, cidade_rg=´SAO PAULO´, uf_rg=´SP´, cep=´29345000´, numero=´19´, complemento=´PROXIMO A VIDA´, fone=´( ) - ´, fone_recado=´( ) - ´, celular=´( ) - ´, pai=´´, mae=´´, email=´´, cod_est_civil=´4´, conjuge=´´, cod_profissao=NULL, cod_empresa=NULL, cod_cargo=NULL, cod_status=´2´, foto=NULL, obs=´´, ponto_referencia=´´ where cod_cliente=´CT06460´


Quando é executado este update acima é que dá o bendito erro. Agora se eu pego esta query e lanço em um editor SQL externo ele funciona normalmente.

Segue trechos do código:
inserção:
with DmTabelas.IBTCliente do begin DMTabelas.IBTCliente.Active:=True; Last; insert; FieldByName(´COD_AUX_GERAL´).AsInteger:= StrToInt(EditCodCliente.Text[3]+EditCodCliente.Text[4]+EditCodCliente.Text[5]+EditCodCliente.Text[6]+EditCodCliente.Text[7]); FieldByName(´COD_CLIENTE´).AsString:= EditCodCliente.text; FieldByName(´NM_CLIENTE´).AsString:= EditNome.text; FieldByName(´DT_NASC´).AsString:= EditNasc.text; if (CBSexo.text=´MASCULINO´) then FieldByName(´SEXO´).AsString:= ´M´ else if (CBSexo.text=´FEMININO´) then FieldByName(´SEXO´).AsString:= ´F´; FieldByName(´NATURALIDADE´).AsString:= EditNaturalidade.text; FieldByName(´CPF´).AsString:= EDITCPF.text; FieldByName(´RG´).AsString:= EDITRG.text; FieldByName(´EMISSAO_RG´).AsString:= EDITEmissaoRG.text; FieldByName(´CIDADE_RG´).AsString:= EDITCidadeRG.text; FieldByName(´UF_RG´).AsString:= EditUFRG.text; FieldByName(´COD_STATUS´).AsInteger:= StrToInt(DBLookSituacao.KeyValue); FieldByName(´OBS´).AsString:= MemoObs.text; FieldByName(´COMPLEMENTO´).AsString:= EditComplemento.text; FieldByName(´PONTO_REFERENCIA´).AsString:= EditPontoRef.text; FieldByName(´CEP´).AsString:= EDITCEP.text; FieldByName(´FONE´).AsString:= EDITFone.text; FieldByName(´PAI´).AsString:= EDITPai.text; FieldByName(´MAE´).AsString:= EDITMae.text; FieldByName(´CONJUGE´).AsString:= EDITConjuge.text; FieldByName(´EMAIL´).AsString:= EDITEmail.text; FieldByName(´COD_EST_CIVIL´).AsInteger:= StrToInt(DBLookEstCivil.KeyValue); if (DBLookProfissao.KeyValue <> NULL) then FieldByName(´cod_profissao´).AsInteger:= DBLookProfissao.KeyValue; if (DBLookEmpresa.KeyValue <> NULL) then FieldByName(´cod_empresa´).AsInteger:= DBLookEmpresa.KeyValue; if (DBLookCargo.KeyValue <> NULL) then FieldByName(´cod_cargo´).AsInteger:= DBLookCargo.KeyValue; if (ExtractFileName(OpenPictureDialog1.Filename)<>´´) then FieldByName(´FOTO´).AsString:= ExtractFileName(OpenPictureDialog1.Filename); FieldByName(´DT_CADASTRO´).AsString:= datetostr(now); Refresh; Active:=False; Active:=True; DMBanco.IBTrSisloc.CommitRetaining;


update:
IBQAux2.Active := False; IBQAux2.SQL.Clear; strSql:=´nm_cliente=´+QuotedStr(EditNome.Text); if (TRIM(ReplaceStr(EditNasc.Text,´/´,´´))<>´´) then begin try data_ok:=´, dt_nasc=´+QuotedStr(ReplaceStr(EditNasc.Text,´/´,´.´)); StrToDate(EditNasc.Text); except on EConvertError do begin data_ok:=´, dt_nasc=NULL´; end end; strSQL:=strSQL+data_ok; END; if (CBSexo.Text=´´) then strSQL:=strSQL+´, sexo=NULL´ else strSQL:=strSQL+´, sexo=´+ QuotedStr(CBSexo.Text); if (EditNaturalidade.Text=´´) then strSQL:=strSQL+´, naturalidade=NULL´ else strSQL:=strSQL+´, naturalidade=´+ QuotedStr(EditNaturalidade.Text); if (EditCPF.Text=´´) then strSQL:=strSQL+´, cpf=NULL´ else strSQL:=strSQL+´, cpf=´+ QuotedStr(EditCPF.Text); if (EditRG.Text=´´) then strSQL:=strSQL+´, rg=NULL´ else strSQL:=strSQL+´, rg=´+ QuotedStr(EditRG.Text); if (TRIM(ReplaceStr(EditEmissaoRG.Text,´/´,´´))<>´´) then begin try StrToDate(EditEmissaoRG.Text); except on EConvertError do begin strSQL:=strSQL+´, emissao_rg=NULL´; end else strSQL:=strSQL+´, emissao_rg=´+ QuotedStr(ReplaceStr(EditEmissaoRG.Text,´/´,´.´)); end; END; if (EditCidadeRG.Text=´´) then strSQL:=strSQL+´, cidade_rg=NULL´ else strSQL:=strSQL+´, cidade_rg=´+ QuotedStr(EditCidadeRG.Text); if (EditUFRG.Text=´´) then strSQL:=strSQL+´, uf_rg=NULL´ else strSQL:=strSQL+´, uf_rg=´+ QuotedStr(EditUFRG.Text); if (EditCep.Text=´´) then strSQL:=strSQL+´, cep=´+ QuotedStr(EditCep.Text) else strSQL:=strSQL+´, cep=´+ QuotedStr(EditCep.Text); if (EditNumero.Text=´´) then strSQL:=strSQL+´, numero=´+ QuotedStr(EditNumero.Text) else strSQL:=strSQL+´, numero=´+ QuotedStr(EditNumero.Text); if (EditComplemento.Text=´´) then strSQL:=strSQL+´, complemento=´+ QuotedStr(EditComplemento.Text) else strSQL:=strSQL+´, complemento=´+ QuotedStr(EditComplemento.Text); if (EditFone.Text=´´) then strSQL:=strSQL+´, fone=´+ QuotedStr(EditFone.Text) else strSQL:=strSQL+´, fone=´+ QuotedStr(EditFone.Text); if (EditFoneRecado.Text=´´) then strSQL:=strSQL+´, fone_recado=´+ QuotedStr(EditFoneRecado.Text) else strSQL:=strSQL+´, fone_recado=´+ QuotedStr(EditFoneRecado.Text); if (EditCelular.Text=´´) then strSQL:=strSQL+´, celular=´+ QuotedStr(EditCelular.Text) else strSQL:=strSQL+´, celular=´+ QuotedStr(EditCelular.Text); if (EditPai.Text=´´) then strSQL:=strSQL+´, pai=´+ QuotedStr(EditPai.Text) else strSQL:=strSQL+´, pai=´+ QuotedStr(EditPai.Text); if (EditMae.Text=´´) then strSQL:=strSQL+´, mae=´+ QuotedStr(EditMae.Text) else strSQL:=strSQL+´, mae=´+ QuotedStr(EditMae.Text); if (EditEmail.Text=´´) then strSQL:=strSQL+´, email=´+ QuotedStr(EditEmail.Text) else strSQL:=strSQL+´, email=´+ QuotedStr(EditEmail.Text); if (DBLookEstCivil.KeyValue=-1) then strSQL:=strSQL+´, cod_est_civil=NULL´ else strSQL:=strSQL+´, cod_est_civil=´+ QuotedStr(DBLookEstCivil.KeyValue); if (EditConjuge.Text=´´) then strSQL:=strSQL+´, conjuge=´+ QuotedStr(EditConjuge.Text) else strSQL:=strSQL+´, conjuge=´+ QuotedStr(EditConjuge.Text); if ((DBLookProfissao.KeyValue=-1) or (DBLookProfissao.KeyValue=NULL)) then strSQL:=strSQL+´, cod_profissao=NULL´ else strSQL:=strSQL+´, cod_profissao=´+ QuotedStr(DBLookProfissao.KeyValue); if ((DBLookEmpresa.KeyValue=-1) or (DBLookEmpresa.KeyValue=NULL)) then strSQL:=strSQL+´, cod_empresa=NULL´ else strSQL:=strSQL+´, cod_empresa=´+ QuotedStr(DBLookEmpresa.KeyValue); if ((DBLookCargo.KeyValue=-1) or (DBLookCargo.KeyValue=NULL)) then strSQL:=strSQL+´, cod_cargo=NULL´ else strSQL:=strSQL+´, cod_cargo=´+ QuotedStr(DBLookCargo.KeyValue); if ((DBLookSituacao.KeyValue=-1) or (DBLookSituacao.KeyValue=NULL)) then strSQL:=strSQL+´, cod_status=NULL´ else strSQL:=strSQL+´, cod_status=´+ QuotedStr(DBLookSituacao.KeyValue); if (OpenPictureDialog1.Filename=´´) then if (LabelAuxFoto.Caption=´NULL´) then strSQL:=strSQL+´, foto=NULL´ else strSQL:=strSQL+´, foto=´+QuotedStr(LabelAuxFoto.Caption) else strSQL:=strSQL+´, foto=´+ QuotedStr(ExtractFileName(OpenPictureDialog1.Filename)); if (MemoObs.Text=´´) then strSQL:=strSQL+´, obs=´+ QuotedStr(MemoObs.Text) else strSQL:=strSQL+´, obs=´+ QuotedStr(MemoObs.Text); if (EditPontoRef.Text=´´) then strSQL:=strSQL+´, ponto_referencia=´+ QuotedStr(EditPontoRef.Text) else strSQL:=strSQL+´, ponto_referencia=´+ QuotedStr(EditPontoRef.Text); strSQL:=´update cliente set ´+strSQL+´ where cod_cliente=´+QuotedStr(EditCodCliente.Text); if IBQAux2.Active=True then IBQAux2.Active:=False; IBQAux2.SQL.Clear; IBQAux2.SQL.Add(strSQL); IBQAux2.Active:=True;


Lembrando q se eu faço o cadastro do cliente, fecho a tela e abro novamente e faço oupdate, tudo funciona perfeitamente.
Alguém pode ajudar??

Att.
Flávio.


Responder

Gostei + 0

17/07/2006

Flaviobrazuca

Ninguém pode me ajudar?

Att.
Flávio.


Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar