sistem Posted March 27, 2013 Report Share Posted March 27, 2013 gente é possivel fazer isto em SQLRDD? dbSelectArea( "0" ) dbUseArea(.t., "SQLRDD", "tabela", .t., .f.,,, Iif(SR_ExistTable("tabela"), nConn1, nConn0)) pois preciso verificar se minha tabela esta no db1 ou db2 tentei aqui eh nao deu certo, este ultimo parametro existe mesmo? "(parametro da conexao) Quote Link to comment Share on other sites More sharing options...
joaosolution Posted March 27, 2013 Report Share Posted March 27, 2013 Boa tarde Trabalho com esta função para testar se a tablea existe: /* ----------------------------------------------------------------------------- Função : FileSQL Proposito : Verifica se a tabela já foi criada no banco SQL Parametros : cFile - Nome da tabela ------------------------------------------------------------------------------ */ FUNCTION FILESQL(cFile) Local nErr, nPos, oSql, cComm Local aReturn := {} oSql := SR_GetConnection() cFile := StrTran(cFile,".","_") cComm := "SELECT * FROM SR_MGMNTTABLES WHERE Table_= '"+cFile+"'" nErr := oSql:exec( cComm,, .T.,@aReturn) return IIF(Len(aReturn)>0,.T.,.F.) Quote Link to comment Share on other sites More sharing options...
Erciley Junior Posted March 27, 2013 Report Share Posted March 27, 2013 Olá, uma forma de ver se existe a tabela é com o comando abaixo SHOW TABLE STATUS FROM nome_banco WHERE NAME = "nome_tabela" Quote Link to comment Share on other sites More sharing options...
emotta Posted March 27, 2013 Report Share Posted March 27, 2013 Aconselho a usar assim: nConn := nConn1 If ! SR_ExistTable("tabela") nConn := nConn0 EndIf nConnOld := Sr_SetActiveConnection(nConn) dbUseArea(.t., "SQLRDD", "tabela", .t., .f.) Sr_SetActiveConnection(nConnOld) Eu também ja tentei várias vezes usar da forma como voce descreveu e não deu certo. Usando assim da certo. gente é possivel fazer isto em SQLRDD? dbSelectArea( "0" ) dbUseArea(.t., "SQLRDD", "tabela", .t., .f.,,, Iif(SR_ExistTable("tabela"), nConn1, nConn0)) pois preciso verificar se minha tabela esta no db1 ou db2 tentei aqui eh nao deu certo, este ultimo parametro existe mesmo? "(parametro da conexao) Quote Link to comment Share on other sites More sharing options...
sistem Posted March 27, 2013 Author Report Share Posted March 27, 2013 Eduardo estava fazendo +ou- dessa maneira que vc descreveu mais nao encontrava o indice na hora de abrir a tabela (pensei que fosse erro de abertura da tabela) *------------------------------------------------------------------------------------------------------------ FUNCTION NETUSESQL( cFile, ex_use, wait, cAlias, lRede ) LOCAL forever := ( wait = 0 ), lRet := .F., nConn, FalhaCon1:=.f. IF ex_use = NIL ex_use := .f. ENDIF IF lRede = NIL lRede := .t. ENDIF IF wait = NIL wait := 10 ENDIF SR_SetActiveConnection(nConn0) If SR_ExistTable( cFile ) Else SR_SetActiveConnection(nConn1) If !SR_ExistTable( cFile ) MsgAlert("Base de dados não encontrado.", "Alerta!") DbCloseAll() SET RESOURCES TO SR_EndConnection( nConn0 ) SR_EndConnection( nConn1 ) nConn0:=0 nConn1:=0 SR_End() Quit Return nil Endif Endif IF ex_use IF !EMPTY( cAlias ) USE ( cFile ) EXCLUSIVE ALIAS ( cAlias ) VIA "SQLRDD" ELSE USE ( cFile ) EXCLUSIVE VIA "SQLRDD" ENDIF ELSE IF !EMPTY( cAlias ) USE ( cFile ) SHARED NEW ALIAS ( cAlias ) VIA "SQLRDD" ELSE USE ( cFile ) SHARED NEW VIA "SQLRDD" ENDIF ENDIF RETURN ( lRet ) com o comando RENAME TABLE db1.clie TO db0.clie; o mesmo remove do database db1 e adiciona no db0 a tabela clie com seus indices e tudo ( workbench ) soh que nao sabia que seria preciso indexar novamente, mesmo mostrando os indices no db0 em resumo recriei os indices e deu certo obs:se mover tabela com indices para outro DB tem que reidexar obrigado a tados 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.