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

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

Postby Daniel Garcia-Gil » Sun Aug 12, 2012 5:06 pm

Hello

are you downloaded from svn?
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

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

Postby mosh1 » Sun Aug 12, 2012 5:21 pm

Daniel Garcia-Gil wrote:Hello

are you downloaded from svn?


To be honest - I dont remember. Where is svn?
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

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

Postby Daniel Garcia-Gil » Sun Aug 12, 2012 5:28 pm

look

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

do you have gmail account? maybe we can talk by gmail chat
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

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

Postby mosh1 » Wed Aug 15, 2012 5:06 pm

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".
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

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

Postby Daniel Garcia-Gil » Wed Aug 15, 2012 9:45 pm

Hello

put the save after modify value

Code: Select all  Expand view

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
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

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

Postby mosh1 » Wed Aug 15, 2012 10:44 pm

[quote="Daniel Garcia-Gil"]Hello

put the save after modify value

Code: Select all  Expand view
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!
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

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

Postby Daniel Garcia-Gil » Wed Aug 15, 2012 11:03 pm

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' " )
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

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

Postby mosh1 » Wed Aug 15, 2012 11:18 pm

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' " )


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 :
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

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

Postby Daniel Garcia-Gil » Wed Aug 15, 2012 11:36 pm

Hello

please create the table in Dolphin server, add some data and post the minimal sample here...
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

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

Postby mosh1 » Thu Aug 16, 2012 12:10 am

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() ?
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

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

Postby Daniel Garcia-Gil » Thu Aug 16, 2012 12:15 am

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
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

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

Postby mosh1 » Thu Aug 16, 2012 5:42 pm

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 view

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



 
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

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

Postby Daniel Garcia-Gil » Thu Aug 16, 2012 6:53 pm

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 view

#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
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

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

Postby dutch » Fri Aug 17, 2012 5:35 am

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 view
        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".
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

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

Postby mosh1 » Fri Aug 17, 2012 3:57 pm

Dear dutch,
dutch wrote:odb1:update()

There is no such method in my TDolphin version
mosh1
 
Posts: 129
Joined: Sun Oct 09, 2011 3:50 pm

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 83 guests