Fórum Problemas com SQLDataSet #130628

19/03/2010

0

Ola,
Estou tentando realizar uma pesquisa de cliente com uma união de duas tabelas e essa pesquisa pode ser feita por codigo, nome, nome fantasia, endereço, bairro, cidade, estado.
Estou usando o delphi 2010 e não sei por que cargas d'água só aceita 255 em um linha.

Toda ves que vou testar ele da o seguinte erro: token unknown -line 1, column 168 a.
eu cansei de ler e não consigo visualizar o problema.

wcomtxt := 'select a.codcli, a.nomcli, a.baicli, a.endcli, a.numend, a.codcid, a.cgccli, a.insest, a.fancli, a.cliafa, a.ratina, a.ratinb, a.ratinc, b.nomcid, b.estcid' +
   'from arq005 a, arq013 b where b.codcid = a.codcid and a.tipdoc = :wtipdoc and a.cliafa = :wcliafa';

   cdsArq005.Close;
   Arq005.CommandText := wcomtxt;
   if Edit1.text <> '' then
      begin
      wcomtxt := wcomtxt + wstrsql;
      Arq005.CommandText := wcomtxt;
      case radiogroup1.itemindex of
         0 : Arq005.Params.ParamByName('wcodcli').asinteger := strtoint(edit1.text);
         1 : Arq005.Params.ParamByName('wnomcli').asstring := edit1.text;
         2 : Arq005.Params.ParamByName('wfancli').asstring := edit1.text;
         3 : Arq005.Params.ParamByName('wcgccli').asstring := edit1.text;
         4 : Arq005.Params.ParamByName('wendcli').asstring := edit1.text;
         5 : Arq005.Params.ParamByName('wnomcid').asstring := edit1.text;
         6 : Arq005.Params.ParamByName('wbaicli').asstring := edit1.text;
         7 : Arq005.Params.ParamByName('westcid').asstring := edit1.text;
         end;
      end;
   if wtipemi = 'F' THEN
      Arq005.params.parambyname('wtipdoc').value := 'P'
   else
      Arq005.params.parambyname('wtipdoc').value := 'R';
   IF PageControl1.ActivePage = TabSheet1 THEN
      Arq005.Params.ParamByName('wcliafa').Value := 0
   Else
      Arq005.Params.ParamByName('wcliafa').Value := 1;
   cdsArq005.open;

essa é a rotina, wcomtxt e wstrsql são variavel do tipo string.
Aguem pode me ajudar por favor.

obrigado
Wilton Júnior

Wilton Júnior

Responder

Posts

19/03/2010

Emerson Nascimento

wcomtxt := 'select a.codcli, a.nomcli, a.baicli, a.endcli, a.numend, a.codcid, a.cgccli, a.insest, a.fancli, a.cliafa, a.ratina, a.ratinb, a.ratinc, b.nomcid, b.estcid' + <- falta um espaço ANTES do from
   'from arq005 a, arq013 b where b.codcid = a.codcid and a.tipdoc = :wtipdoc and a.cliafa = :wcliafa';

wcomtxt := 'select a.codcli, a.nomcli, a.baicli, a.endcli, a.numend, '+
           ' a.codcid, a.cgccli, a.insest, a.fancli, a.cliafa, a.ratina, '+
           ' a.ratinb, a.ratinc, b.nomcid, b.estcid '+
           'from arq005 a, arq013 b '+
           'where b.codcid = a.codcid and a.tipdoc = :wtipdoc '
           ' and a.cliafa = :wcliafa';

note que eu sempre finalizo a string com um espaço, assim não emenda com a parte seguinte.
Responder

Gostei + 0

19/03/2010

Pjrm1470

Grande Emerson. Nem vi esse detalhe.
Uma boa prática de programação é uma boa identação/organização do codigo.
Nem que ocupe mais linhas, mas deixar de uma forma padronizada e facil de se identificar e ler... ja torna o codigo mais facil de identificar problemas deste tipo.

Cada programador tem uma padrão. quanto mais organizado for o codigo mais facil a leitura.
;D

Abraço e bons codigos.
pjrm1470.
Responder

Gostei + 0

19/03/2010

Emerson Nascimento

é sim. devemos deixar o mais legível pra nós, até porque o compilardor/linkador vai fazer todo um tratamento ao gerar a linguagem de máquina (executável em si).
Responder

Gostei + 0

19/03/2010

Wilton Júnior

Obrigado seu Ermeson pela dica, mas agora surgiu um novo problema

case radiogroup1.ItemIndex of
      0 : wstrsql := ' and a.codcli = :wcodcli ';
      1 : wstrsql := ' and a.nomcli like %:wnomcli%';
      2 : wstrsql := ' and a.fancli like %:wfancli%';
      3 : wstrsql := ' and a.cgccli like %:wcgccli%';
      4 : wstrsql := ' and a.endcli like %:wendcli%';
      5 : wstrsql := ' and b.nomcid like %:wnomcid%';
      6 : wstrsql := ' and a.baicli like %:wbaicli%';
      7 : wstrsql := ' and b.estcid like %:westicid%';
      end;

preciso juntar wstrsql no wcomtxt assim estaria correto?


wcomtxt := 'select a.codcli, a.nomcli, a.baicli, a.endcli, a.numend, '+
           ' a.codcid, a.cgccli, a.insest, a.fancli, a.cliafa, a.ratina, '+
           ' a.ratinb, a.ratinc, b.nomcid, b.estcid '+
           'from arq005 a, arq013 b '+
           'where b.codcid = a.codcid and a.tipdoc = :wtipdoc ' +
           ' and a.cliafa = :wcliafa ';

   cdsArq005.Close;
   Arq005.CommandText := wcomtxt;
   if Edit1.text <> '' then
      begin
      case radiogroup1.itemindex of
         0 : begin
             Arq005.CommandText := wcomtxt + wstrsql;
             Arq005.params.parambyname('wcodcli').asinteger := StrToInt(edit1.text);
             end;
         1 : begin
             Arq005.CommandText := wcomtxt + wstrsql;
             Arq005.Params.ParamByName('wnomcli').asstring := edit1.text;
             end;
         2 : begin
             Arq005.CommandText := wcomtxt + wstrsql;
             Arq005.Params.ParamByName('wfancli').asstring := edit1.text;
             end;
         3 : begin
             Arq005.CommandText := wcomtxt + wstrsql;
             Arq005.Params.ParamByName('wcgccli').asstring := edit1.text;
             end;
         4 : begin
             Arq005.CommandText := wcomtxt + wstrsql;
             Arq005.Params.ParamByName('wendcli').asstring := edit1.text;
             end;
         5 : begin
             Arq005.CommandText := wcomtxt + wstrsql;
             Arq005.Params.ParamByName('wnomcid').asstring := edit1.text;
             end;
         6 : begin
             Arq005.CommandText := wcomtxt + wstrsql;
             Arq005.Params.ParamByName('wbaicli').asstring := edit1.text;
             end;
         7 : begin
             Arq005.CommandText := wcomtxt + wstrsql;
             Arq005.Params.ParamByName('westcid').asstring := edit1.text;
             end;
         end;
      end;
   if wtipemi = 'F' THEN
      Arq005.params.parambyname('wtipdoc').value := 'P'
   else
      Arq005.params.parambyname('wtipdoc').value := 'R';
   IF PageControl1.ActivePage = TabSheet1 THEN
      Arq005.Params.ParamByName('wcliafa').Value := 0
   Else
      Arq005.Params.ParamByName('wcliafa').Value := 1;
   cdsArq005.open;

esse código quando testo da o seguinte mensagem de erro"DBExpress driver does not support the TDBxTypes. UInt8 dat type. Vendor error message unkown ISC error 0.

se puder me ajudar...

grato
Responder

Gostei + 0

19/03/2010

Emerson Nascimento

wcomtxt := 'select a.codcli, a.nomcli, a.baicli, a.endcli, a.numend, '+
           ' a.codcid, a.cgccli, a.insest, a.fancli, a.cliafa, a.ratina, '+
           ' a.ratinb, a.ratinc, b.nomcid, b.estcid '+
           'from arq005 a, arq013 b '+
           'where b.codcid = a.codcid and a.tipdoc = :wtipdoc ' +
           ' and a.cliafa = :wcliafa ';

case radiogroup1.ItemIndex of
   0: wcomtxt := wcomtxt + ' and a.codcli = :wcodcli ';
   1: wcomtxt := wcomtxt + ' and a.nomcli like :wnomcli';
   2: wcomtxt := wcomtxt + ' and a.fancli like :wfancli';
   3: wcomtxt := wcomtxt + ' and a.cgccli like :wcgccli';
   4: wcomtxt := wcomtxt + ' and a.endcli like :wendcli';
   5: wcomtxt := wcomtxt + ' and b.nomcid like %:wnomcid%';
   6: wcomtxt := wcomtxt + ' and a.baicli like %:wbaicli%';
   7: wcomtxt := wcomtxt + ' and b.estcid like %:westicid%';
end;

cdsArq005.Close;

Arq005.CommandText := wcomtxt;

if Edit1.text <> '' then
   case radiogroup1.itemindex of
      0: Arq005.params.parambyname('wcodcli').asinteger := StrToInt(edit1.text);
      1: Arq005.Params.ParamByName('wnomcli').asstring := '%'+edit1.text+'%';
      2: Arq005.Params.ParamByName('wfancli').asstring := '%'+edit1.text+'%';
      3: Arq005.Params.ParamByName('wcgccli').asstring := '%'+edit1.text+'%';
      4: Arq005.Params.ParamByName('wendcli').asstring := '%'+edit1.text+'%';
      5: Arq005.Params.ParamByName('wnomcid').asstring := '%'+edit1.text+'%';
      6: Arq005.Params.ParamByName('wbaicli').asstring := '%'+edit1.text+'%';
      7: Arq005.Params.ParamByName('westcid').asstring := '%'+edit1.text+'%';
   end;

if wtipemi = 'F' then
   Arq005.params.parambyname('wtipdoc').value := 'P'
else
   Arq005.params.parambyname('wtipdoc').value := 'R';

if PageControl1.ActivePage = TabSheet1 then
   Arq005.Params.ParamByName('wcliafa').Value := 0
else
   Arq005.Params.ParamByName('wcliafa').Value := 1;

cdsArq005.open;







ou, para simplificar:

wcomtxt := 'select a.codcli, a.nomcli, a.baicli, a.endcli, a.numend, '+
           ' a.codcid, a.cgccli, a.insest, a.fancli, a.cliafa, a.ratina, '+
           ' a.ratinb, a.ratinc, b.nomcid, b.estcid '+
           'from arq005 a, arq013 b '+
           'where b.codcid = a.codcid and a.tipdoc = :wtipdoc ' +
           ' and a.cliafa = :wcliafa ';

case radiogroup1.ItemIndex of
   0: wcomtxt := wcomtxt + ' and a.codcli = '+StrToInt(edit1.text);
   1: wcomtxt := wcomtxt + ' and a.nomcli like '+QuotedStr('%'+edit1.text+'%');
   2: wcomtxt := wcomtxt + ' and a.fancli like '+QuotedStr('%'+edit1.text+'%');
   3: wcomtxt := wcomtxt + ' and a.cgccli like '+QuotedStr('%'+edit1.text+'%');
   4: wcomtxt := wcomtxt + ' and a.endcli like '+QuotedStr('%'+edit1.text+'%');
   5: wcomtxt := wcomtxt + ' and b.nomcid like '+QuotedStr('%'+edit1.text+'%');
   6: wcomtxt := wcomtxt + ' and a.baicli like '+QuotedStr('%'+edit1.text+'%');
   7: wcomtxt := wcomtxt + ' and b.estcid like '+QuotedStr('%'+edit1.text+'%');
end;

cdsArq005.Close;

Arq005.CommandText := wcomtxt;

if wtipemi = 'F' then
   Arq005.params.parambyname('wtipdoc').value := 'P'
else
   Arq005.params.parambyname('wtipdoc').value := 'R';

if PageControl1.ActivePage = TabSheet1 then
   Arq005.Params.ParamByName('wcliafa').Value := 0
else
   Arq005.Params.ParamByName('wcliafa').Value := 1;

cdsArq005.open;

Responder

Gostei + 0

19/03/2010

Emerson Nascimento

retificando....

wcomtxt := 'select a.codcli, a.nomcli, a.baicli, a.endcli, a.numend, '+
           ' a.codcid, a.cgccli, a.insest, a.fancli, a.cliafa, a.ratina, '+
           ' a.ratinb, a.ratinc, b.nomcid, b.estcid '+
           'from arq005 a, arq013 b '+
           'where b.codcid = a.codcid and a.tipdoc = :wtipdoc ' +
           ' and a.cliafa = :wcliafa ';

case radiogroup1.ItemIndex of
   0: wcomtxt := wcomtxt + ' and a.codcli = :wcodcli ';
   1: wcomtxt := wcomtxt + ' and a.nomcli like :wnomcli';
   2: wcomtxt := wcomtxt + ' and a.fancli like :wfancli';
   3: wcomtxt := wcomtxt + ' and a.cgccli like :wcgccli';
   4: wcomtxt := wcomtxt + ' and a.endcli like :wendcli';
   5: wcomtxt := wcomtxt + ' and b.nomcid like :wnomcid';
   6: wcomtxt := wcomtxt + ' and a.baicli like :wbaicli';
   7: wcomtxt := wcomtxt + ' and b.estcid like :westicid';
end;

cdsArq005.Close;

Arq005.CommandText := wcomtxt;

if Edit1.text <> '' then
   case radiogroup1.itemindex of
      0: Arq005.params.parambyname('wcodcli').asinteger := StrToInt(edit1.text);
      1: Arq005.Params.ParamByName('wnomcli').asstring := '%'+edit1.text+'%';
      2: Arq005.Params.ParamByName('wfancli').asstring := '%'+edit1.text+'%';
      3: Arq005.Params.ParamByName('wcgccli').asstring := '%'+edit1.text+'%';
      4: Arq005.Params.ParamByName('wendcli').asstring := '%'+edit1.text+'%';
      5: Arq005.Params.ParamByName('wnomcid').asstring := '%'+edit1.text+'%';
      6: Arq005.Params.ParamByName('wbaicli').asstring := '%'+edit1.text+'%';
      7: Arq005.Params.ParamByName('westcid').asstring := '%'+edit1.text+'%';
   end;

if wtipemi = 'F' then
   Arq005.params.parambyname('wtipdoc').value := 'P'
else
   Arq005.params.parambyname('wtipdoc').value := 'R';

if PageControl1.ActivePage = TabSheet1 then
   Arq005.Params.ParamByName('wcliafa').Value := 0
else
   Arq005.Params.ParamByName('wcliafa').Value := 1;

cdsArq005.open;







ou, para simplificar:

wcomtxt := 'select a.codcli, a.nomcli, a.baicli, a.endcli, a.numend, '+
           ' a.codcid, a.cgccli, a.insest, a.fancli, a.cliafa, a.ratina, '+
           ' a.ratinb, a.ratinc, b.nomcid, b.estcid '+
           'from arq005 a, arq013 b '+
           'where b.codcid = a.codcid and a.tipdoc = :wtipdoc ' +
           ' and a.cliafa = :wcliafa ';

case radiogroup1.ItemIndex of
   0: wcomtxt := wcomtxt + ' and a.codcli = '+StrToInt(edit1.text);
   1: wcomtxt := wcomtxt + ' and a.nomcli like '+QuotedStr('%'+edit1.text+'%');
   2: wcomtxt := wcomtxt + ' and a.fancli like '+QuotedStr('%'+edit1.text+'%');
   3: wcomtxt := wcomtxt + ' and a.cgccli like '+QuotedStr('%'+edit1.text+'%');
   4: wcomtxt := wcomtxt + ' and a.endcli like '+QuotedStr('%'+edit1.text+'%');
   5: wcomtxt := wcomtxt + ' and b.nomcid like '+QuotedStr('%'+edit1.text+'%');
   6: wcomtxt := wcomtxt + ' and a.baicli like '+QuotedStr('%'+edit1.text+'%');
   7: wcomtxt := wcomtxt + ' and b.estcid like '+QuotedStr('%'+edit1.text+'%');
end;

cdsArq005.Close;

Arq005.CommandText := wcomtxt;

if wtipemi = 'F' then
   Arq005.params.parambyname('wtipdoc').value := 'P'
else
   Arq005.params.parambyname('wtipdoc').value := 'R';

if PageControl1.ActivePage = TabSheet1 then
   Arq005.Params.ParamByName('wcliafa').Value := 0
else
   Arq005.Params.ParamByName('wcliafa').Value := 1;

cdsArq005.open;

Responder

Gostei + 0

19/03/2010

Wilton Júnior

MUito Obrigado senhor Emerson pela ajuda.
Responder

Gostei + 0

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

Aceitar