macs Posted February 13, 2020 Report Share Posted February 13, 2020 Olá Pessoal.... Existe alguma forma de pesquisa, com DBF, que eu possa digitar uma determinada palavra e a pesquisa seja feita em todos os campos do DBF. E que também apenas seja visualizado no browse apenas o conteúdo pesquisado. Exemplo: Ao digitar a palavra "INDÚSTRIA", apenas seja visualizado os registros que possua em qualquer campo da tabela o conteúdo "INDÚSTRIA". É como se fosse o LIKE do SQL, mas tem que ser em todos os campos. WildSeek faz em parte... localiza 1 registro por vez, mesmo assim tenho que criar um índice com todos os campos que eu quero que seja pesquisado. Alguém possou alguma solução pra isso? Desde já agradeço! Quote Link to comment Share on other sites More sharing options...
kapiaba Posted February 13, 2020 Report Share Posted February 13, 2020 yes, con xBrowse. Quote Link to comment Share on other sites More sharing options...
macs Posted February 13, 2020 Author Report Share Posted February 13, 2020 yes, con xBrowse. Como? tem algum exemplo? Quote Link to comment Share on other sites More sharing options...
kapiaba Posted February 13, 2020 Report Share Posted February 13, 2020 http://forums.fivetechsupport.com/viewtopic.php?f=6&t=38342&p=228900&hilit=cseek&sid=2c564720b378e2180fcb7402b598bc81#p228900 Quote Link to comment Share on other sites More sharing options...
Jmsilva Posted February 14, 2020 Report Share Posted February 14, 2020 ex1: Filtro('maur?cio*rebou?as') ex2: Filtro('ana*ur?cio*rebou?as') **========================================================================== Static Function Filtro(cKey) **========================================================================== cKey := StrTran(cKey,".","*") cKey := StrTran(cKey,"-","") cKey := StrTran(cKey,"/","") cKey := alltrim(cKey) If !Empty(cKey) cKey := "*"+Alltrim(cKey)+"*" CADCLI->(DbSetFilter({|| WildMatch(cKey,Upper(CADCLI->CPF+" "+CADCLI->NOME+" "+; CADCLI->CARGO+" "+CADCLI->ENDRES+" "+DToS(CADCLI->DTUPD)))})) Else CADCLI->(DbSetFilter(Nil)) Endif CADCLI->(DBGoTop()) oBrw[1]:Refresh() Return Nil PARECIDO COM LIKE...BLZ Quote Link to comment Share on other sites More sharing options...
Frazato Posted February 14, 2020 Report Share Posted February 14, 2020 Tarde! com a Pesquisa em campo com indice e rapido mais pesquisar sem o indice fica lento, cheguei a fazer um tempo a trás mais desistir não tinha muito onde usar e tá lenta mais tinha me ajudado na época. Frazato Function Main() /*By Joao Frazato Jaf Desenvolvimentos Pesquisa Geral - Ta lenta */ REQUEST DBFCDX RDDSETDEFAULT("dbfcdx") DBSETDRIVER("dbfcdx") set confirm On set deleted on set bell off set scoreboard off set date british set epoch to 1950 Set date format to "DD/MM/YYYY" set exclusive off mTemporal := 'c:\temp\' cLocaServ := 'c:\temp\' cLocaServ := 'c:\servidor\dba\' cLocaServ := '' Set Defa to ( cLocaServ ) BuscaGeral('c:\servidor\dba\') Return nil //------------------------------------------------ Function BuscaGeral(cLocal) Local ListaDbf := {} Local cPasta := cLocal Lista := {} cPesq :='PERDIGAO' *cPesq := '53196' Aadd(ListaDbf,'Produto.dbf') Aadd(ListaDbf,'Inventa1.dbf') for i:= 1 to Len(ListaDbf) Close all cArq := cPasta+ListaDbf[i] @ 00,00 say cArq Use (cArq) Alias Tmp sele tmp Go top nTotReg := RecCount() nRegAtu := 0 Do while ! Eof() cString := '' @ 02,00 say 'Aguarde....Termino...'+Str(nRegAtu++/nTotReg*100,7,2)+'%' for x:= 1 to FCount() If FieldType(x)=="C" cString+= FieldGet(x) * ElseIF FieldType(x)=="N" * cString+= Str(FieldGet(x)) Endif Next If cPesq$cString nPosInicial:= At(cPesq,cString) If nPosInicial > 15 nPosInicial := nPosInicial -14 Endif cString2 := SubStr(cString,nPosinicial,50) Aadd(Lista,cArq+'|Reg:'+Str(recno(),11)+'-'+cString2) Endif @ 24,00 say cString Skip+1 Enddo * Lista := {} * *Centra(24,"Selecionando Registro(s) "+Time()) * cPesq := '*'+Alltrim(cPesq) +'*' * cLista:= {} * Do While OrdWildSeek(cPesq,.t.) * Aadd(Lista,Str(recno(),11)+'-'+Tmp->DESCRICAO ) * *Centra(24,"Selecionando Registro(s) "+Str(nReg++,5)) * Enddo nPos := achoice(08,13,23,83,Lista,.t.,,) * * *Dbedit(01,00,24,79) Next Return Nil Quote Link to comment Share on other sites More sharing options...
SISCO Posted February 16, 2020 Report Share Posted February 16, 2020 Function FiltraPro(oLbx) PRODTMP(.T.) USE PRODUTO(.F.) cProTmp := cDirTrb+"PRODTMP.dbf" Copy FOR RTrim(cDescPro) $ PRODUTO->Descricao to &cProTmp //? "Fim da Pesquisa" PRODTMP(.T.) oLbx:UpStable() oLbx:Refresh() Return .t. Quote Link to comment Share on other sites More sharing options...
AcessoSoft Posted February 16, 2020 Report Share Posted February 16, 2020 /******************************************************************************************* * EXEMPLO DE BUSCA GERAL POR UMA EXPRESSÃO QUALQUER NUM ARQUIVO DBF E RETORNO DE ARRAY * FUNCIONA COM QUALQUER ARQUIVO DBF * by: Acesso Softwares *******************************************************************************************/ #include "fivewin.ch" /******************************************************************************************/ FUNCTION Main() LOCAL cBusca, aFiltrados USE clientes.dbf cBusca := "SÃO PAULO" aFiltrados := CriaArrayFiltrado( cBusca ) XBROWSE( aFiltrados ) RETURN NIL /*******************************************************************************************/ FUNCTION CriaArrayFiltrado( cBusca ) LOCAL nFor, bFiltro, aArray := {}, aCampos, cFiltro := "" cTextoBusca := cBusca //------------------------------ OBTEM CAMPOS DO ARQUIVO ----------------------------------// aCampos := DBSTRUCT() //---- MONTA STRING PARA CONDICAO DO DBEVAL SOMENTE COM OS CAMPOS DO TIPO C, M, D, N ------// FOR nFor = 1 TO LEN( aCampos ) DO CASE // Campo tipo caracter ou memo CASE aCampos[ nFor, 2 ] $ "CM" cFiltro += "UPPER( cTextoBusca ) $ TiraAcento( UPPER( " + aCampos[ nFor, 1 ] + ") ) .OR. " // campo do tipo data CASE aCampos[ nFor, 2 ] == "D" cFiltro += "UPPER( cTextoBusca ) $ DTOC( " + aCampos[ nFor, 1 ] + ") .OR. " // campo do tipo numérico CASE aCampos[ nFor, 2 ] == "N" cFiltro += "UPPER( cTextoBusca ) $ STR( " + aCampos[ nFor, 1 ] + " ) .OR. " ENDCASE NEXT cFiltro := "{||" + SUBSTR( cFiltro, 1, LEN( cFiltro ) - 6 ) + "}" // -6 para retira o último .OR. criado acima //----------------------- MONTA CODEBLOCK DE FILTRO PARA DBEVAL --------------------------// IF EMPTY( cFiltro ) bFiltro := {|| .T. } ELSE bFiltro := &cFiltro ENDIF //------------ ADICIONA NO ARRAY REGISTRO QUE SATISFAÇA A CONDIÇAO ( bFiltro ) ------------// WHILE !EOF() IF EVAL( bFiltro ) AADD( aArray, PegaRegistro( aCampos ) ) ENDIF SKIP ENDDO //----------------------- CRIA ARRAY COM 1 LINHA EM BRANCO PARA O BROWSE -----------------// IF EMPTY( aArray ) aArray := { { LEN( aCampos ) } } AFILL( aArray[1], SPACE(10) ) ENDIF RETURN( aArray ) /********************************************************************************************/ FUNCTION PegaRegistro( aCampos ) LOCAL nFor, aRegistro := {}, cNomeCampo FOR nFor = 1 TO LEN( aCampos ) cNomeCampo := aCampos[ nFor, 1 ] AADD( aRegistro, &cNomeCampo ) NEXT RETURN( aRegistro ) /********************************************************************************************/ FUNCTION TiraAcento( cTexto ) // ESCREVA AQUI CÓDIGO QUE RETIRE DA STRING CARACTERES COMO: Ç, Ã, Ó, É, etc RETURN( cTexto ) /********************************************************************************************/ 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.