Page 6 of 7

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Sun Aug 12, 2012 5:06 pm
by Daniel Garcia-Gil
Hello

are you downloaded from svn?

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Sun Aug 12, 2012 5:21 pm
by mosh1
Daniel Garcia-Gil wrote:Hello

are you downloaded from svn?


To be honest - I dont remember. Where is svn?

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Sun Aug 12, 2012 5:28 pm
by Daniel Garcia-Gil
look

http://tdolphin.blogspot.com/2010/06/comanzando-starting.html

do you have gmail account? maybe we can talk by gmail chat

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Wed Aug 15, 2012 5:06 pm
by mosh1
I cannot change value of a field :

Code: Select all | Expand


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

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Wed Aug 15, 2012 9:45 pm
by Daniel Garcia-Gil
Hello

put the save after modify value

Code: Select all | Expand


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
 

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Wed Aug 15, 2012 10:44 pm
by mosh1
[quote="Daniel Garcia-Gil"]Hello

put the save after modify value

Code: Select all | Expand

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
 


It doesnt help. After Save() value becomes as it was before FieldPut!

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Wed Aug 15, 2012 11:03 pm
by Daniel Garcia-Gil
hello

it's a better way and more fast

with dolphin

method 1

Code: Select all | Expand

oServer:Execute( "UPDATE table_name SET account = 'sobachka', balance = 3.14 WHERE account = 'dog' )


method 2

Code: Select all | Expand

oServer:Update( "table_name",  { "account", "balance" }, { 'sobachka', 3.14 } , "account = 'dog' " )

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Wed Aug 15, 2012 11:18 pm
by mosh1
Daniel Garcia-Gil wrote:hello

it's a better way and more fast

with dolphin

method 1

Code: Select all | Expand

oServer:Execute( "UPDATE table_name SET account = 'sobachka', balance = 3.14 WHERE account = 'dog' )


method 2

Code: Select all | Expand

oServer:Update( "table_name",  { "account", "balance" }, { 'sobachka', 3.14 } , "account = 'dog' " )


1) May there is better way but why this way doesn't work? And what if I need to replace just one record?

2)Both ways give me same error :

08/15/12 19:16:14
Error MYSQL/1406 Data too long for column 'ACCOUNT' at row 1
=> DOLPHIN_DEFERROR line 2478
=> TDOLPHINSRV:CHECKERROR line 691
=> TDOLPHINSRV:SQLQUERY line 1705
=> TDOLPHINSRV:UPDATE line 1920
=> MAIN line 51
e:genCode 0
e:osCode 0
Workarea :

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Wed Aug 15, 2012 11:36 pm
by Daniel Garcia-Gil
Hello

please create the table in Dolphin server, add some data and post the minimal sample here...

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Thu Aug 16, 2012 12:10 am
by mosh1
Daniel Garcia-Gil wrote:Hello

please create the table in Dolphin server, add some data and post the minimal sample here...


1) This is the Dolphin server ?

host=dolphintest.sitasoft.net
user=test_dolphin
psw=123456
flags=0
port=3306
dbname=dolphin_man



2) I there a sample how to create a table from Dbstruct() ?

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Thu Aug 16, 2012 12:15 am
by Daniel Garcia-Gil
mosh1 wrote:1) This is the Dolphin server ?

host=dolphintest.sitasoft.net
user=test_dolphin
psw=123456
flags=0
port=3306
dbname=dolphin_man

yes
use in mysql console... SHOW CREATE TABLE my_table
use this result to create the table in Dolphin server, is very fast and to easy


mosh1 wrote:2) I there a sample how to create a table from Dbstruct() ?

no

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Thu Aug 16, 2012 5:42 pm
by mosh1
Daniel Garcia-Gil wrote:Hello

please create the table in Dolphin server, add some data and post the minimal sample here...


Code: Select all | Expand


#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"



 

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Thu Aug 16, 2012 6:53 pm
by Daniel Garcia-Gil
Hello

not work because dolphin delete extra space using Function AllTrim

the field LAST_NAME all content start with one SPACE,

example: " polkan"

when TDolphin use the Method Save, does convert the data to UPDATE statement ( but delete the first space ), now the field FIRST_NAME is "" TDolphin convert it to NULL (maybe a little bug)

for this case the best way is use the statement UPDATE directly...

now if you create a primary key, TDolphin locate the value for primary key and will make the SAVE successful

look the next sample with a copy of lanu2 ( lanu2_copy)

Code: Select all | Expand


#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
 

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Fri Aug 17, 2012 5:35 am
by dutch
Dear Mosh1,

I use update() or replace data in field and save() for delete the record. I'm not quite show what is the different but it's working fine for me.

Dutch

Code: Select all | Expand

        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


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

Re: What is the best of MySql (lib or class) TMySql, TDolphin

Posted: Fri Aug 17, 2012 3:57 pm
by mosh1
Dear dutch,
dutch wrote:odb1:update()

There is no such method in my TDolphin version