Exibir mensagem anterior :: Exibir próxima mensagem |
Autor |
Mensagem |
adriano_servitec Colaborador

Registrado: Sexta-Feira, 30 de Janeiro de 2004 Mensagens: 17618
|
Enviada: Qui Set 26, 2019 4:41 pm Assunto: Resultado do SQL no Delphi diferente do firebrid? |
|
|
Criei essa função para retornar cfe o ID no delphi
Código: | function TComunicacao.pSelectComunicacoes(idPai: Int64): WideString;
begin
Result := EmptyStr;
DM.FDQuerySelect.Close;
DM.FDQuerySelect.SQL.Clear;
DM.FDQuerySelect.SQL.Text :=
' SELECT LIST(VALOR, '';'') AS L_COMUNICACAO '+
' FROM( SELECT FIRST 5 DISTINCT CM.VALOR FROM '+
' COMUNICACAO AS CM '+
' INNER JOIN CONTATO AS CT ON '+
' CM.CONTATO_IDCONTATO = CT.IDCONTATO '+
' WHERE CM.CONTATO_IDCONTATO = :pidPai ) '+
' AS LISTA_COMUNICACAO ';
DM.FDQuerySelect.ParamByName('pidPai').AsInteger := idPai;
DM.FDQuerySelect.Open();
if not DM.FDQuerySelect.IsEmpty then
Result := DM.FDQuerySelect.FieldByName('L_COMUNICACAO').Value;
end; |
Usando firedac, porem verifiquei que o id 644531 que não tem valor algum diz que é NOT ISEMPTY e entra no result.
Copiei e colei este SQL no firebird
Código: | SELECT LIST(VALOR, ';') AS L_COMUNICACAO
FROM( SELECT FIRST 5 DISTINCT CM.VALOR FROM
COMUNICACAO AS CM
inner join CONTATO AS ct on
CM.CONTATO_IDCONTATO = CT.IDCONTATO
where CM.CONTATO_IDCONTATO = :pidPai )
AS LISTA_COMUNICACAO |
Executo e retorna null como deve ser
Pior ainda no delphi quando vem o id 653944 que tem 3 preenchido também vem o result null mesmo passando pelo isempy not null
Ja no firebird dentro do ibexpert vem os valores que estão gravados.
O que esta acontecendo porque o delphi não esta fazendo certo? _________________ Jogo seu smartphone? Acesse o link e confira.
https://play.google.com/store/apps/details?id=br.com.couldsys.rockdrum
https://play.google.com/store/apps/details?id=br.com.couldsys.drumsetfree |
|
Voltar ao Topo |
|
 |
adriano_servitec Colaborador

Registrado: Sexta-Feira, 30 de Janeiro de 2004 Mensagens: 17618
|
Enviada: Seg Set 30, 2019 11:37 am Assunto: |
|
|
Bom dia, problema resolvido.
Código: | function TComunicacao.fSelectComunicacoes(idPai: Int64): WideString;
begin
Result := EmptyStr;
DM.FDQueryAux.Close;
DM.FDQueryAux.SQL.Clear;
DM.FDQueryAux.SQL.Text :=
' SELECT A.L_COMUNICACAO FROM ( '+
' SELECT LIST(VALOR, '';'') AS L_COMUNICACAO '+
' FROM( SELECT FIRST 5 DISTINCT CM.VALOR FROM '+
' COMUNICACAO AS CM '+
' INNER JOIN CONTATO AS CT ON '+
' CM.CONTATO_IDCONTATO = CT.IDCONTATO '+
' WHERE CM.CONTATO_IDCONTATO = :pidPai '+
' ORDER BY CM.PREFERENCIAL) '+
' ) A WHERE A.L_COMUNICACAO IS NOT NULL ';
DM.FDQueryAux.ParamByName('pidPai').AsInteger := idPai;
DM.FDQueryAux.Open();
if not DM.FDQueryAux.IsEmpty then
Result := DM.FDQueryAux.FieldByName('L_COMUNICACAO').Value;
end; |
Assim funciona, no delphi _________________ Jogo seu smartphone? Acesse o link e confira.
https://play.google.com/store/apps/details?id=br.com.couldsys.rockdrum
https://play.google.com/store/apps/details?id=br.com.couldsys.drumsetfree |
|
Voltar ao Topo |
|
 |
|