CTOAS Posted June 14, 2012 Report Share Posted June 14, 2012 Amigos... Como indexar um mesmo DBF por dos indices condicionais diferentes e varrer o DBF pegando um valor de uma condição procurando-o na outra condição. Exemplo: DBSELECTAREA('TEMP_BL0') INDEX ON LEFT(TEMP_BL0->CAMPO06,2) TO TEMP_04 FOR TEMP_BL0->CAMPO01 == '0200' INDEX ON LEFT(TEMP_BL0->CAMPO02,2) TO TEMP_05 FOR TEMP_BL0->CAMPO01 == '0190' WHILE TEMP_BL0->(!EOF()) // USANDO O INDICE TEMP_05 IF TEMP_BL0->(!DBSEEK(LEFT(TEMP_BL0->CAMPO02,2))) // USANDO O INDICE TEMP_04 TEMP_BL0->(DBDELETE()) END END id=code>id=code>Obrigado Quote Link to comment Share on other sites More sharing options...
CTOAS Posted June 14, 2012 Report Share Posted June 14, 2012 Amigos... Como indexar um mesmo DBF por dos indices condicionais diferentes e varrer o DBF pegando um valor de uma condição procurando-o na outra condição. Exemplo: DBSELECTAREA('TEMP_BL0') INDEX ON LEFT(TEMP_BL0->CAMPO06,2) TO TEMP_04 FOR TEMP_BL0->CAMPO01 == '0200' INDEX ON LEFT(TEMP_BL0->CAMPO02,2) TO TEMP_05 FOR TEMP_BL0->CAMPO01 == '0190' WHILE TEMP_BL0->(!EOF()) // USANDO O INDICE TEMP_05 IF TEMP_BL0->(!DBSEEK(LEFT(TEMP_BL0->CAMPO02,2))) // USANDO O INDICE TEMP_04 TEMP_BL0->(DBDELETE()) END END id=code>id=code>Obrigado Quote Link to comment Share on other sites More sharing options...
CIACPD Posted June 14, 2012 Report Share Posted June 14, 2012 Olá Cristiano, Ja tentou abrir a mesma tabela com Alias diferente? Daniel Segura Quote Link to comment Share on other sites More sharing options...
sambomb Posted June 14, 2012 Report Share Posted June 14, 2012 FOR ( TEMP_BL0->CAMPO01 == '0200' .Or. TEMP_BL0->CAMPO01 == '0190' ) Será que funcionaria assim? Você adicionaria o valor dese CAMPO01 no indice assim ficaria "filtrado" pelo FOR e organizado pelo CAMPO01 + seu indice podendo no seu loop verificar o CAMPO01 para definir se é válido. RCA Sistemas - Itaocara - RJ Quote Link to comment Share on other sites More sharing options...
netsys Posted June 14, 2012 Report Share Posted June 14, 2012 Ola Cristiano Eu faria assim: DBSELECTAREA('TEMP_BL0') INDEX ON Temp_Bl0->Campo1+LEFT(TEMP_BL0->CAMPO06,2) TO TEMP_04 INDEX ON Temp_Bl0->Campo1+LEFT(TEMP_BL0->CAMPO02,2) TO TEMP_05 Temp_Bl0->(DbSeek("0190") WHILE TEMP_BL0->(!EOF()) .and. Temp_bl0-Campo1="0190" // USANDO O INDICE TEMP_05 nReco:=Temp_Bl0->(Recno()) Temp_Bl0->(DbSetindex("Temp_05")) lAchou:=TEMP_BL0->(!DBSEEK("0200"+LEFT(TEMP_BL0->CAMPO02,2))) // USANDO O INDICE TEMP_04 Temp_Bl0->(DbSetIndex("Temp_04")) Temp_Bl0->(DbGoto(nReco)) If !lAchou Temp_Bl0->(DbDelete()) End Temp_Bl0->(DbSkip()) End id=code>id=code>Se eu entendi bem, você precisa remover de Temp_Bl0, todos os registros cujo campo01='0190' que não tenham um registro correspondente com campo01='0200' , certo? Alberto -SP Quote Link to comment Share on other sites More sharing options...
netsys Posted June 14, 2012 Report Share Posted June 14, 2012 Favor inverter os 2 DbSetindex. Alberto - SP Quote Link to comment Share on other sites More sharing options...
vagner Posted June 15, 2012 Report Share Posted June 15, 2012 citação: DBSELECTAREA('TEMP_BL0') INDEX ON LEFT(TEMP_BL0->CAMPO06,2) TO TEMP_04 FOR TEMP_BL0->CAMPO01 == '0200' INDEX ON LEFT(TEMP_BL0->CAMPO02,2) TO TEMP_05 FOR TEMP_BL0->CAMPO01 == '0190' Temp_Blo->(DbSetOrder(1))id=blue> WHILE TEMP_BL0->(!EOF()) // USANDO O INDICE TEMP_05 IF TEMP_BL0->(!DBSEEK(LEFT(TEMP_BL0->CAMPO02,2))) // USANDO O INDICE TEMP_04 TEMP_BL0->(DBDELETE()) END END id=code>id=code> id=quote>id=quote>Vagner Wirts "Ele não sabendo que era impossÃvel, foi lá e fez" Quote Link to comment Share on other sites More sharing options...
CTOAS Posted June 15, 2012 Report Share Posted June 15, 2012 Obrigado amigos... Testando. Quote Link to comment Share on other sites More sharing options...
Luiz Fernando Posted December 12, 2012 Author Report Share Posted December 12, 2012 Colegas é possivel fazer algo do tipo abaixo... cSql+=" where vencto+10 < "+Any2Sql(date()) o campo vencto é do tipo data Obrigado Luiz Fernando msn: empresoft@globo.com skype:empresoft empresoft@globo.com FWH 9.12,XHARBOUR 1.2,ADS 9.0 FWH1104,XHARBOUR 1.2 Rev.6717, MYSQL c\ SQLLIB FREE Quote Link to comment Share on other sites More sharing options...
Luiz Fernando Posted December 12, 2012 Author Report Share Posted December 12, 2012 Colegas é possivel fazer algo do tipo abaixo... cSql+=" where vencto+10 < "+Any2Sql(date()) o campo vencto é do tipo data Obrigado Luiz Fernando msn: empresoft@globo.com skype:empresoft empresoft@globo.com FWH 9.12,XHARBOUR 1.2,ADS 9.0 FWH1104,XHARBOUR 1.2 Rev.6717, MYSQL c\ SQLLIB FREE Quote Link to comment Share on other sites More sharing options...
joaosolution Posted December 12, 2012 Report Share Posted December 12, 2012 Luiz Acredito que seria assim: cSql+=" where DATE_ADD(vencto,INTERVAL 10 DAY) < "+Any2Sql(date()) Att João Bosco Contagem/MG FWH 10.6b xHb 1.2.1 WorkShop 4.5 PellesC SQLLIB SQLRDD UltraEdit xDev MySql MS-Sql Quote Link to comment Share on other sites More sharing options...
Luiz Fernando Posted December 12, 2012 Author Report Share Posted December 12, 2012 citação:Luiz Acredito que seria assim: cSql+=" where DATE_ADD(vencto,INTERVAL 10 DAY) < "+Any2Sql(date()) id=quote>id=quote>Joao obrigado pela resposta, mais não deu certo, sera que alguém teria mais alguma dica... Obrigado Luiz Fernando msn: empresoft@globo.com skype:empresoft empresoft@globo.com FWH 9.12,XHARBOUR 1.2,ADS 9.0 FWH1104,XHARBOUR 1.2 Rev.6717, MYSQL c\ SQLLIB FREE Quote Link to comment Share on other sites More sharing options...
Polirep Posted December 12, 2012 Report Share Posted December 12, 2012 'select date_add(data_venc, interval 10 day) from contas_receb where data_venc<='+any2sql(date())+' order by data_venc desc' Alexandre (Polirep) Belo Horizonte / MG alexandrepolirep@hotmail.com Quote Link to comment Share on other sites More sharing options...
Geraldo (gbsilva) Posted December 12, 2012 Report Share Posted December 12, 2012 Luiz acho que assim funciona. Fiz um IF() para testar o retorno. SELECT data_teste, DATE(now()), DATE_ADD(data_teste, INTERVAL 10 DAY), IF(DATE_ADD(data_teste,INTERVAL 10 DAY) < DATE(NOW()), 'Menor','Maior') AS Teste_Data FROM cad_obras ; id=code>id=code>Geraldo B. Silva Fwh1202 Fev/2012, xHarbour 2.0, Bcc582, Pelles, xDev, Sqllib, Tdolphin e MySql. lucgera@terra.com.br São Paulo - SP Quote Link to comment Share on other sites More sharing options...
Erciley Junior Posted December 13, 2012 Report Share Posted December 13, 2012 A resposta do João Bosco não funcionou? Estranho, pois está certo. Dá para você usar a função DATEDIFF() do MySQL também... Erciley Junior (FWH8.01 + SQLLIB 1.9d + xHB 1.10 + xDev 0.65 + @SAY) NÃO ABANDONE O POST, QUEREMOS SABER SE SUA DÚVIDA/PROBLEMA TEVE SOLUÇÃO Quote Link to comment Share on other sites More sharing options...
joaosolution Posted December 13, 2012 Report Share Posted December 13, 2012 E ai Luiz Conseguiu? Att João Bosco Contagem/MG FWH 10.6b xHb 1.2.1 WorkShop 4.5 PellesC SQLLIB SQLRDD UltraEdit xDev MySql MS-Sql Quote Link to comment Share on other sites More sharing options...
netsys Posted December 13, 2012 Report Share Posted December 13, 2012 citação:Colegas é possivel fazer algo do tipo abaixo... cSql+=" where vencto+10 < "+Any2Sql(date()) o campo vencto é do tipo data Obrigado Luiz Fernando msn: empresoft@globo.com skype:empresoft empresoft@globo.com FWH 9.12,XHARBOUR 1.2,ADS 9.0 FWH1104,XHARBOUR 1.2 Rev.6717, MYSQL c\ SQLLIB FREE id=quote>id=quote>Luiz, Não seria mais simples assim: ...where vencto < "+Any2Sql(Date()+10) Abs Alberto Quote Link to comment Share on other sites More sharing options...
ronaldo Posted December 13, 2012 Report Share Posted December 13, 2012 sim seria, mas deveria diminui né? where vencto < "+Any2Sql(Date()-10) Ronaldo Minacapelli (11) 2950 3069 Quote Link to comment Share on other sites More sharing options...
netsys Posted December 13, 2012 Report Share Posted December 13, 2012 citação:sim seria, mas deveria diminui né? where vencto < "+Any2Sql(Date()-10) Ronaldo Minacapelli (11) 2950 3069 id=quote>id=quote>Certissimo Ronaldo! Falha nossa! Vencidos a mais de 10 dias. Abs Alberto Quote Link to comment Share on other sites More sharing options...
Luiz Fernando Posted December 15, 2012 Author Report Share Posted December 15, 2012 colegas desculpa pela demora do retorno, tive uns contratempo aqui, com a primeira resposta do joao, nao estava dando certo pois estava fazendo assim... cSql="SELECT pedido,duplicat,emissao,vencto,valor,'','',docu,'',''" cSql+=" from parcela" cSql+=" where cliente='"+cCliente+"'" cSql+=" and pago= 0" cSql+=" and date_add(vencto, interval 10 day) <"+Any2Sql(date()) id=code>id=code>depois pela reposta do alexandre que percebi que estava colocando o comando no lugar errado, desta forma funcionou certinho cSql="SELECT pedido,duplicat,emissao,date_add(vencto, interval 10 day),valor,'','',docu,'',''" cSql+=" from parcela" cSql+=" where cliente='"+cCliente+"'" cSql+=" and pago= 0" cSql+=" and vencto <"+Any2Sql(date()) id=code>id=code>Obs: Alberto estava tentando achar uma solução dentro do SELECT, e nem me passou na cabeça em fazer fora dele, realmente é muito mais pratico da sua forma... Obrigado a todos Luiz Fernando msn: empresoft@globo.com skype:empresoft empresoft@globo.com FWH 9.12,XHARBOUR 1.2,ADS 9.0 FWH1104,XHARBOUR 1.2 Rev.6717, MYSQL c\ SQLLIB FREE Quote Link to comment Share on other sites More sharing options...
silvanof Posted March 7, 2013 Report Share Posted March 7, 2013 Ola Luiz, Utilizo o xHarbour.com com a SQLRDD e a sintax passada a query tem que ser sempre em SQL ANSI. Vc poderia tentar assim: cSql+=" where vencto < "+Any2Sql(date()-10) que acho que o resultado seria o mesmo. Att., Silvano. Quote Link to comment Share on other sites More sharing options...
evandro Posted March 7, 2013 Report Share Posted March 7, 2013 Olá, cSql+=" where adddate( vencto,10) < "+Any2Sql(date()) []s, Evandro G. de Paula Curvelo - MG Quote Link to comment Share on other sites More sharing options...
Luiz Fernando Posted March 8, 2013 Author Report Share Posted March 8, 2013 Colegas obrigado pelas reposta, mais este topico ja foi resolvido a um bom tempo, é que com o retorno do forum foi perdido informações de case 3 meses, por isto as resposta não estão mais aqui... mesmo assim vlw Luiz Fernando Quote Link to comment Share on other sites More sharing options...
Erciley Junior Posted March 8, 2013 Report Share Posted March 8, 2013 Também tinha visto isto, principalmente no tópico de piadas, o mais importante, huahahua Quote Link to comment Share on other sites More sharing options...
marcioe Posted March 8, 2013 Report Share Posted March 8, 2013 amigos eu criei uma funcao para tratar os comandos SQL. Não sei se foi a melhor opção, mas no meu caso resolveu o problema de esquecer de colocar aspas, etc. quando vou gravar eu estou fazendo assim TRY BEGIN TRANSACTION cQuery_Mtabela := "INSERT INTO cfop ( " cQuery_Mtabela := cQuery_Mtabela + " CODIGO" cQuery_Mtabela := cQuery_Mtabela + " ,NOME" cQuery_Mtabela := cQuery_Mtabela + " ,MOVIMENTA_ESTOQUE" cQuery_Mtabela := cQuery_Mtabela + " ) VALUES ( " cQuery_Mtabela := cQuery_Mtabela + TRANSFORMA_SQL(T_CODI_CFOP,"T",05,0) + "," cQuery_Mtabela := cQuery_Mtabela + TRANSFORMA_SQL(T_NOME_CFOP,"T",65,0) + ',' cQuery_Mtabela := cQuery_Mtabela + TRANSFORMA_SQL(IF(T_MOVIMENTA_ESTOQUE=(.T.),'S','N'),'T',01,0) cQuery_Mtabela := cQuery_Mtabela + " )" COMITAR_DADOS_SQL(cQuery_Mtabela) END TRANSACTION CATCH ROLLBACK TRANSACTION End *------------------------------------------------------------------------------- FUNCTION TRANSFORMA_SQL(VARIVEL_SQL,TIPO_VARIAVEL_SQL,TAMANHO_SQL,DECIMAIS_SQL) Cursor('SQL') RETORNO_SQL := "'" IF TIPO_VARIAVEL_SQL = "N" && Numerica RETORNO_SQL := RETORNO_SQL + STR(VARIVEL_SQL,(TAMANHO_SQL),(DECIMAIS_SQL)) + "'" ENDIF IF TIPO_VARIAVEL_SQL = "D" && Data IF VARIVEL_SQL = CTOD('') RETORNO_SQL := RETORNO_SQL + '00000000' + "'" ELSE RETORNO_SQL := RETORNO_SQL + DTOS(VARIVEL_SQL) + "'" ENDIF ENDIF IF TIPO_VARIAVEL_SQL = "T" .OR. TIPO_VARIAVEL_SQL = "C" && Caracter, && Texto IF TIPO_VARIAVEL_SQL != "C" VARIVEL_SQL := TiraAcento(VARIVEL_SQL) ENDIF RETORNO_SQL := RETORNO_SQL + PADR(ALLTRIM(VARIVEL_SQL),(TAMANHO_SQL)) + "'" ENDIF IF TIPO_VARIAVEL_SQL = "B" && BLOB RETORNO_SQL := RETORNO_SQL + ANY2SQL( MemoRead( (VARIVEL_SQL) )) + "'" ENDIF IF TIPO_VARIAVEL_SQL = "L" && Logico RETORNO_SQL := RETORNO_SQL + IF(VARIVEL_SQL=(.T.),"S","N") + "'" ENDIF IF TIPO_VARIAVEL_SQL = "C" && Caracter, sem Acen VARIVEL_SQL := TiraAcento(VARIVEL_SQL) RETORNO_SQL := RETORNO_SQL + PADR(ALLTRIM(VARIVEL_SQL),(TAMANHO_SQL)) + "'" ENDIF RETURN RETORNO_SQL Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.