Can't to catch in which place is mine mistake . Please help to me . I'm doing migration from DBF to SqLite tables . It looks something like that :
- Code: Select all Expand view RUN
aFld := { "uzsak", "telkinys", "uzs_data", "uzs_sav", "preke", "uzs_kiekis", "uzs_spalv", "graz_data", "graz_sav", ;
"fakt_data", "fakt_sav", "specai", "mazi_did", "svarbus", "sukirp_lap", "subrang", ;
"pastabos_ord", "pastabos_buh", "pastabos_zs", "kerpa", "kainos_proc", "plan_modelis", "db" }
cFld := ar2fld( aFld )
ORD->( dbgotop() )
do while !ORD->( eof() )
aVls := {}
if val( ORD->ORD_DATA ) >= val( cDat )
cMod := ""
cPMd := ""
if MODL->( dbseek( ORD->MD_K ) )
cMod := alltrim( MODL->MODEL )
endif
if MODL->( dbseek( ORD->NMD_K ) )
cPmd := alltrim( MODL->MODEL )
endif
aVls := { alltrim( ORD->ORDER ), alltrim( ORD->TRF_DATA ), ;
left( ORD->ORD_DATA, 4 ) + "." + substr( ORD->ORD_DATA, 5, 2 ) + "." + substr( ORD->ORD_DATA, 7, 2 ), left( ORD->ORD_DATA, 4 ) + "." + ORD->ORD_S, ;
cMod, val( str( ORD->KIEKIS, 9, 3 ) ), alltrim( ORD->COLOR ), ;
left( ORD->RET_DATA, 4 ) + "." + substr( ORD->RET_DATA, 5, 2 ) + "." + substr( ORD->RET_DATA, 7, 2 ), left( ORD->RET_DATA, 4 ) + "." + ORD->RET_S, ;
left( ORD->FAK_DATA, 4 ) + "." + substr( ORD->FAK_DATA, 5, 2 ) + "." + substr( ORD->FAK_DATA, 7, 2 ), left( ORD->FAK_DATA, 4 ) + "." + ORD->FAK_S, ;
if( !empty( ORD->SPEC ), .t., .f. ), alltrim( ORD->M_Z ), alltrim( ORD->ZYMOS ), if( ORD->SVARBU == .t., .t., .f. ), alltrim( ORD->CUT_NR ), ;
alltrim( ORD->SBR ), alltrim( ORD->PASTABA ), alltrim( ORD->BUH_PAST ), alltrim( ORD->ZS_NOTES ), ;
if( ORD->TK == "Z", "ZARASAI", "DANIJA" ), val( str( ORD->KN_PRC, 6, 2 ) ), cPmd, "ut" }
endif
if len( aVls ) > 0
cVls := ar2vls( aVls )
cSql := "INSERT INTO uzsakym " + cFld + " VALUES " + cVls
if z <= 3
MsgInfo( cSql )
z ++
endif
oSqLite:Execute( "BEGIN" )
oSqLite:Execute( cSql )
oSqLite:Execute( "COMMIT" )
endif
ORD->( dbskip() )
enddo
MsgInf( "Duomenys pervesti !" )
return( NIL )
static function ar2fld( aMas )
local m := 0
local cRet := "("
for m := 1 to len( aMas )
cRet += alltrim( aMas[ m ] ) + if( m < len( aMas ), ', ', '' )
next
cRet += ")"
return( cRet )
static function ar2vls( aMas )
local m := 0
local cRet := "("
for m := 1 to len( aMas )
cRet += valtoprg( aMas[ m ] ) + if( m < len( aMas ), ', ', '' )
next
cRet += ")"
return( cRet )
I allways get an error on this line : oSqLite:Execute( cSql ) . "SQL Error [# 1] Class: S1000" . As I can understand it can be problem between fields . But can't understand ...
Copied Sql statement :
INSERT INTO uzsakym (uzsak, telkinys, uzs_data, uzs_sav, preke, uzs_kiekis, uzs_spalv, graz_data, graz_sav, fakt_data, fakt_sav, specai, mazi_did, svarbus, sukirp_lap, subrang, pastabos_ord, pastabos_buh, pastabos_zs, kerpa, kainos_proc, plan_modelis, db) VALUES ("1092944", "", "2011.11.04", "2011.44", "T", 13.000, "", "2011.11.11", "2011.45", "2011.11.11", "2011.45", .F., "T", "", .F., "", "UT", "liniuotes kisene", "0322-765, K.283", "", "DANIJA", 25.00, "T", "ut")
DDL of uzsakym :
CREATE TABLE [uzsakym] (
[uzsak] VARCHAR(20) NOT NULL ON CONFLICT ROLLBACK,
[telkinys] VARCHAR(20) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[uzs_data] vARCHAR(10) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[uzs_sav] VARCHAR(7) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[preke] VARCHAR(30) NOT NULL ON CONFLICT REPLACE DEFAULT (''),
[uzs_kiekis] DECIMAL(9, 3) NOT NULL ON CONFLICT REPLACE DEFAULT 0,
[uzs_spalv] CHAR(10) NOT NULL ON CONFLICT REPLACE DEFAULT (''),
[graz_data] VARCHAR(10) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[graz_sav] VARCHAR(7) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[fakt_data] VARCHAR(10) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[fakt_sav] VARCHAR(7) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[specai] BOOLEAN NOT NULL ON CONFLICT REPLACE DEFAULT 0,
[mazi_did] CHAR(1) NOT NULL ON CONFLICT REPLACE COLLATE NOCASE DEFAULT M,
[zymos] CHAR(15) NOT NULL ON CONFLICT REPLACE DEFAULT (''),
[aud_nuras] BOOLEAN NOT NULL ON CONFLICT REPLACE DEFAULT 0,
[frn_nuras] BOOLEAN NOT NULL ON CONFLICT REPLACE DEFAULT 0,
[invc_nuras] BOOLEAN NOT NULL ON CONFLICT REPLACE DEFAULT 0,
[nav_nuras] BOOLEAN NOT NULL ON CONFLICT REPLACE DEFAULT 0,
[sask_gautos] BOOLEAN NOT NULL ON CONFLICT REPLACE DEFAULT 0,
[pasel_prad] BOOLEAN NOT NULL ON CONFLICT REPLACE DEFAULT 0,
[pokav_prad] BOOLEAN NOT NULL ON CONFLICT REPLACE DEFAULT 0,
[svarbus] BOOLEAN NOT NULL ON CONFLICT REPLACE DEFAULT 0,
[sukirp_lap] VARCHAR(10) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[subrang] VARCHAR(10) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[pastabos_ord] VARCHAR(50) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[pastabos_buh] VARCHAR(50) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[pastabos_zs] VARCHAR(50) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[kerpa] VARCHAR(10) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[kainos_proc] DECIMAL(6, 2) NOT NULL ON CONFLICT REPLACE DEFAULT 0,
[plan_modelis] VARCHAR(30) NOT NULL ON CONFLICT REPLACE DEFAULT (' '),
[db] CHAR(5) NOT NULL ON CONFLICT ROLLBACK,
CONSTRAINT [sqlite_autoindex_uzsakym_1] PRIMARY KEY ([uzsak] ASC, [db]));
Many thanks in advance for any help !