Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

lisa

Probelmas com o script de comparação

Recommended Posts

Seguinte Pessoal, Tenho 3 tabelas em bancos de Dados diferentes, que NAO podem ser juntadas

 

TAB1--------------------TAB2--------------------TAB3

id1------------------------id2----------------------id3

nome--------------------nome-------------------nome

cir1-----------------------cir2---------------------cir3

 

 

Preciso que meu script toda vez que por executado faça isso:

 

Leia a TAB1 e verifica que o valor do campo "nome" esteja nas tabelas TAB2 e TAB3

 

Se o nome conter nas 3 tabelas, verificar se o CIR é igual nas TAB2 e TAB2. Se for diferente, atualizar com o valor do "cir" da primeira tabela:

 

Eu ja comecei a fazer... so que tem um problema:

 

- Quando ele começa a comparar o "CIR" de 2 tabelas, para fazer o UPLOAD so ta pegando o valor do primeiro campo... por exemplo:

 

 

EQUIPAMENTO QUE TEM NA TAB1 E TAB2-----------CIR1 ------ CIR2 ------ igual o diferente?

PAUZ001------------------------------------- 192 ------ 128 ------ diferente

PBOG024------------------------------------- 128 ------ 128 ------ diferente

PCCS040---------------------------------------128 ------ 128 ------ diferente

 

 

Segue o codigo....

 

 

<%'Conectando com o banco 1set objCon77=server.createobject("adodb.connection")objCon77.open "dsn_xxx" %><%'Conectando com o banco 2set objConn10=server.createobject("adodb.connection")objConn10.open "tabcir","xxxx","xxxxx"%><table width="100%">  <tr> 	<td>EQUIPAMENTO QUE TEM NA TAB1 E TAB2</td>	<td>CIR1</td>	<td>CIR2</td>	 <td>igual o diferente?</td>  </tr>  <%  ' selecionar os nomes que tem na TAB1sql1 = "select * from tabela1"set RSsql1 = objcon77.execute (sql1) %><%while not RSsql1.EOF%><%' selecionar os nomes que tem nas tabelas TAB1 e TAB2sql2 = "select * from tabela2 where nome = '"&TRIM(RSsql1(1))&"' "set RSsql2 = objConn10.execute (sqltabcir)%><%if not RSsql2.EOF thenRSsql2.MoveFirstend ifDo while not RSsql2.EOF %>  <tr>  <td> <%=RSsql2("nome")%></td>   <td> <%=objRS77("cir")%> </td>   <td><%=RSsql2("cir")%> </td>            <% if RSsql2("cir") <> RSsql1("cir") then %>   	 <td>diferente </td>   <% end if %>    </tr> <%RSsql2.MoveNextLoop %><%RSsql1.Movenext  wend%>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Repare que você move apenas o registro do RSsql2 e não o do RSsql1.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Fiz o que você falou e continua pegando somente o 1 registro e comparando...

 

<%'Conectando com o banco 1set objCon77=server.createobject("adodb.connection")objCon77.open "dsn_xxx" %><%'Conectando com o banco 2set objConn10=server.createobject("adodb.connection")objConn10.open "tabcir","xxxx","xxxxx"%><table width="100%">  <tr> 	<td>EQUIPAMENTO QUE TEM NA TAB1 E TAB2</td>	<td>CIR1</td>	<td>CIR2</td>	 <td>igual o diferente?</td>  </tr>  <%  ' selecionar os nomes que tem na TAB1sql1 = "select * from tabela1"set RSsql1 = objcon77.execute (sql1) %><%if not RSsql1.EOF thenRSsql1.MoveFirstend ifDo while not RSsql1.EOF %><%' selecionar os nomes que tem nas tabelas TAB1 e TAB2sql2 = "select * from tabela2 where nome = '"&TRIM(RSsql1(1))&"' "set RSsql2 = objConn10.execute (sqltabcir)%><%if not RSsql2.EOF thenRSsql2.MoveFirstend ifDo while not RSsql2.EOF %>  <tr>  <td> <%=RSsql2("nome")%></td>   <td> <%=objRS77("cir")%> </td>   <td><%=RSsql2("cir")%> </td>            <% if RSsql2("cir") <> RSsql1("cir") then %>   	 <td>diferente </td>  <% end if %>    </tr><%RSsql2.MoveNextLoop %><%RSsql1.Movenext  Loop %>

Compartilhar este post


Link para o post
Compartilhar em outros sites

Agora que vi, de onde vem esse <%=objRS77("cir")%>?

Compartilhar este post


Link para o post
Compartilhar em outros sites

Oi Lisa naum sei c eh assim q você quer mas de uma olhada<%'Conectando com o banco 1set objCon77=server.createobject("adodb.connection")objCon77.open "dsn_xxx" 'Conectando com o banco 2set objConn10=server.createobject("adodb.connection")objConn10.open "tabcir","xxxx","xxxxx"%><table width="100%"> <tr> <td>EQUIPAMENTO QUE TEM NA TAB1 E TAB2</td> <td>CIR1</td> <td>CIR2</td> <td>igual o diferente?</td> </tr> <%' selecionar os nomes que tem na TAB1sql1 = "select * from tabela1"set RSsql1 = objcon77.execute (sql1) %>if RSsql1.EOF then RESPONSE.WRITE "Não existem produtos cadastrados na tabela 1"else DO WHILE NOT RSsql1.EOF ' selecionar os nomes que tem nas tabelas TAB1 e TAB2 sql2 = "select * from tabela2 where nome = '" & TRIM(RSsql1("nome")) & "' " set RSsql2 = objConn10.execute (sql2) IF RSsql2.EOF THEN RESPONSE.WRITE "Não existem produtos cadastrados na tabela 2" ELSE DO WHILE NOT RSsql2.EOF RESPONSE.WRITE "<tr>" RESPONSE.WRITE "<td>" & RSsql2("nome") & "</td>" RESPONSE.WRITE "<td>" & RSsql1("cir") & "</td>" RESPONSE.WRITE "<td>" & RSsql2("cir") & "</td>" IF RSsql2("cir") <> RSsql1("cir") THEN RESPONSE.WRITE "<td>diferente</td>" ELSE RESPONSE.WRITE "<td>igual</td>" END IF RESPONSE.WRITE "</tr>" RSsql2.MOVENEXT LOOP END IF RSsql1.MOVENEXT LOOPEnd if%>bom pelo q intendi eh soh pra mostra se eh igual ou diferente o CIR, eu achei melhor assim mas qualquer coisa eh soh dar um toq

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ola.. Speedole.. Obrigada pelo codigo..

 

eu consegui resolver mudando essa linha:

 

<% if RSsql2("cir") <> RSsql1("cir") then %>por	<% if trim(RSsql2("cir")) <> trim(RSsql1("cir")) then %>

ai funcionou perfeitamente.. eu so nao sei pq do outro jeito não funciona....

 

brigadão!!!!

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.