Jump to content
Fivewin Brasil

dbUseArea SQLRDD


sistem

Recommended Posts

 

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)

Link to comment
Share on other sites

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.)

 

Link to comment
Share on other sites

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)
Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...