Daniel Garcia-Gil wrote:Hello
are you downloaded from svn?
oQry = oServer:Query( "SELECT account, last_name, first_name,balance FROM lanu" )
do while !oQry:Eof()
if oQry:account="dog"
?"before",oQry:account,oQry:balance
oQry:FieldPut("account" , "sobachka" )
oQry:FieldPut("balance" , 3.14 )
?"after",oQry:account,oQry:balance
endif
oQry:Skip()
enddo
oQry:Save()
do while !oQry:Eof()
if oQry:account="dog"
?"before",oQry:account,oQry:balance
oQry:account = "sobachka"
oQry:balancen = 3.14
oQry:Save()
?"after",oQry:account,oQry:balance
endif
oQry:Skip()
enddo
do while !oQry:Eof()
if oQry:account="dog"
?"before",oQry:account,oQry:balance // dog 0.00
oQry:FieldPut("account" , "sobachka" )
oQry:FieldPut("balance" , 3.14 )
?"after",oQry:account,oQry:balance // sobachka 3.14
oQry:Save()
?"after save",oQry:account,oQry:balance // dog 0.00
endif
oQry:Skip()
enddo
oServer:Execute( "UPDATE table_name SET account = 'sobachka', balance = 3.14 WHERE account = 'dog' )
oServer:Update( "table_name", { "account", "balance" }, { 'sobachka', 3.14 } , "account = 'dog' " )
Daniel Garcia-Gil wrote:hello
it's a better way and more fast
with dolphin
method 1
- Code: Select all Expand view
oServer:Execute( "UPDATE table_name SET account = 'sobachka', balance = 3.14 WHERE account = 'dog' )
method 2
- Code: Select all Expand view
oServer:Update( "table_name", { "account", "balance" }, { 'sobachka', 3.14 } , "account = 'dog' " )
Daniel Garcia-Gil wrote:Hello
please create the table in Dolphin server, add some data and post the minimal sample here...
mosh1 wrote:1) This is the Dolphin server ?
host=dolphintest.sitasoft.net
user=test_dolphin
psw=123456
flags=0
port=3306
dbname=dolphin_man
mosh1 wrote:2) I there a sample how to create a table from Dbstruct() ?
Daniel Garcia-Gil wrote:Hello
please create the table in Dolphin server, add some data and post the minimal sample here...
#include "tdolphin.ch"
#define CRLF Chr( 13 ) + Chr( 10 )
PROCEDURE Main()
LOCAL oServer := NIL
LOCAL cText := ""
local chost:="dolphintest2.sitasoft.net"
local cuser:="test2_dolphin"
local cpsw:="123456"
local cflags:=0
local cport:=3306
local cdbname:="tdolphin_test"
local oQry
IF ( oServer := ConnectTo(2) ) == NIL
RETURN
ENDIF
IF ! oServer:lError
cText += "Connection OK" + CRLF
cText += "Host: " + oServer:cHost +CRLF
cText += "Database: " +oServer:cDBName + CRLF
cText += oServer:GetServerInfo() + CRLF
cText += oServer:GetClientInfo()
? cText + CRLF
ENDIF
oQry = oServer:Query( "SELECT account, last_name, first_name,balance FROM lanu2" )
do while !oQry:Eof()
if oQry:account="dog"
?"before",oQry:account,oQry:balance
oQry:FieldPut("account" , "sobaka" )
oQry:FieldPut("balance" , 3.14 )
?"after",oQry:account,oQry:balance
oQry:Save()
?"after save",oQry:account,oQry:balance
endif
oQry:Skip()
enddo
?"Wait"
inkey(0)
oServer:End()
RETURN
#include "connto.prg"
#include "tdolphin.ch"
PROCEDURE Main()
LOCAL oServer := NIL
LOCAL cText := ""
local chost:="dolphintest2.sitasoft.net"
local cuser:="test2_dolphin"
local cpsw:="123456"
local cflags:=0
local cport:=3306
local cdbname:="tdolphin_test"
local oQry
CONNECT oServer HOST chost ;
USER cUser ;
PASSWORD cpsw ;
PORT cPort ;
DATABASE cDBName
oServer:bDebug = {| c | logfile( "debug.txt", { c } ) }
oQry = oServer:Query( "SELECT id, account, last_name, first_name,balance FROM lanu2_copy" )
do while !oQry:Eof()
if oQry:account="dog"
oQry:FieldPut("account" , "sobaka" )
oQry:FieldPut("balance" , 3.14 )
oQry:Save()
endif
oQry:Skip()
enddo
oServer:End()
RETURN
odb1:=oServer:Query("select * from rmty_avl")
n := 0
cTlRec := strim(odb1:reccount())
odb1:gotop()
do while !odb1:eof() // odb1:recno() <= 100
if valtype(odb1:rta_date) = 'D'
if odb1:fieldget("rta_date") < MEMVAR->comdat
do while odb1:fieldget("rta_date") < MEMVAR->comdat .and. !odb1:eof()
odb1:delete()
odb1:save()
end
else
if RTY->(DbSeek( dtos(odb1:rta_date)+odb1:rta_rmty ))
if odb1:fieldget("rta_ooo") <> RTY->RTA_OOO .or. odb1:fieldget("rta_occ") <> RTY->RTA_OCC
odb1:fieldput('rta_ooo', RTY->RTA_OOO )
odb1:fieldput('rta_occ', RTY->RTA_OCC )
odb1:update()
n++
end
end
end
end
odb1:skip()
end
odb1:End()
mosh1 wrote:I cannot change value of a field :
- Code: Select all Expand view
oQry = oServer:Query( "SELECT account, last_name, first_name,balance FROM lanu" )
do while !oQry:Eof()
if oQry:account="dog"
?"before",oQry:account,oQry:balance
oQry:FieldPut("account" , "sobachka" )
oQry:FieldPut("balance" , 3.14 )
?"after",oQry:account,oQry:balance
endif
oQry:Skip()
enddo
oQry:Save()
When I run this sample second time account is still "dog".
dutch wrote:odb1:update()
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 95 guests