CLOSE ALL CLEAR ALL SET TALK OFF SET ECHO OFF SET SAFETY OFF set cpdialog off set reso off ACTIVATE SCREEN CLEAR cConnString ="DRIVER={PostgreSQL Unicode};DATABASE=postgres;"+ ; "SERVER=localhost;PORT=5432;UID=postgres;PWD=xxxx;B9=0" * change this line to sqlstringconnect(): g_server = NEWOBJECT('sqlserver','sqlserver.vcx','',cconnstring) TEXT TO csql TEXTMERGE noshow CREATE temp TABLE klient (kood char(12), nimi char(70), info text ) ; CREATE UNIQUE INDEX klient_nimi_unique_idx ON klient(nimi); CREATE temp TABLE dok( doktyyp char(1) ); insert into klient (kood,nimi) values ('AKU', 'Akuexpert O'); endtext * change this line to SQLEXEC(): IF !sexec(csql) RETURN ENDIF prmkataloog='' prmalias='klient' * change this line to SQLEXEC()(): IF !SExec("SELECT * FROM "+m.prmALIAS+' where false', m.prmALIAS ) RETURN -1 ENDIF sele 0 use dbf(m.prmALIAS) again alias LISADA tempdir='' CREATE CURSOR testk ( kood c(10), nimi c(60), info m) insert into testk (kood,nimi,info) values ('AKU', 'Akuexpert O','') copy stru to (m.tempdir+'ubaas') sele 0 use (m.tempdir+'ubaas') excl * The folowing line cuses vfp go generate insert command for text type * field. Problably this destroys memory. APPEND FROM DBF('testk') prmlisating='.t.' sele UBAAS copy to (m.tempdir+'u2baas') for eval(m.prmlisating) set talk off likvdbf('ubaas') sele 0 use (m.tempdir+'u2baas') excl alias U2BAAS local vfiltreeritud vfiltreeritud = recc() vmasin='' if type('masin')='C' repl all masin with m.vmasin endif prmunivoti='kood' index on &prmUNIVOTI tag t set talk off set order to T sele LISADA set rela to &prmUNIVOTI into U2BAAS priv vkustutatud, vusetimestamp vkustutatud = 0 vusetimestamp = .f. local notadded notadded = 0 loca for !eof('u2baas') and eval(m.prmLISATING) priv vcount * change this to makeupdatable() call: IF !g_server.Prepareforupdate('u2baas',prmalias, SET("Datasession")) return -1 ENDIF use in U2BAAS sele LISADA ON ERROR note * here we continue on error appe from (m.tempdir+'u2baas') ON error *** access violation occurs in this line: * when using psqlODBC 08.01.0102 from pgfoundry.org: * change this line to SQLEXEC()(): IF !SEXEC("SELECT * FROM dok WHERE false",'dok') RETURN .f. ENDIF MESSAGEBOX('Program flow does not reach to this point.') RETURN FUNCTION makeupdatable LPARAMETERS cLocalTable, cRemoteTable, nDataSession, cRemoteTableActualName SET DATASESSION TO m.nDatasession CURSORSETPROP("Tables", m.cRemoteTable, m.cLocalTable ) LOCAL i, lafields, lnFields, cUpdateNameList, cUpdatableFieldList SELECT (m.cLocalTable) lnFields = AFIELDS(laFlds) cUpdateNameList = '' cUpdatableFieldList='' FOR i=1 TO m.lnFields IF (UPPER(m.cLocalTable)='RID_' AND laFlds[m.i,1]='DOKTYYP') OR ; (m.cLocalTable='OMRID_' AND laFlds[m.i,1]='KSUUND') OR ; (m.cLocalTable='YKSUS' AND laFlds[m.i,1]='KLASSIF') OR ; (m.cLocalTable='BILSKEEM' AND laFlds[m.i,1]='JRK') LOOP ENDIF IF !EMPTY(m.cUpdateNameList) cUpdateNameList = m.cUpdateNameList + ', ' ENDIF cUpdateNameList = m.cUpdateNameList + laFlds[m.i,1]+' ' + ; m.cRemotetable+'.'+LOWER(laFlds[m.i,1]) IF !empty(m.cUpdatableFieldList) cUpdatableFieldList = m.cUpdatableFieldList + ',' ENDIF cUpdatableFieldList = m.cUpdatableFieldList + laFlds[m.i,1] ENDFOR CURSORSETPROP("UpdateNameList", m.cUpdateNameList ) CURSORSETPROP("UpdatableFieldList", m.cUpdatableFieldList ) LOCAL cKeyFieldList cKeyFieldList = 'kood' SELECT (m.cLocalTable) CURSORSETPROP("KeyFieldList", m.cKeyFieldList) CURSORSETPROP("SendUpdates", .T.) CURSORSETPROP("fetchmemo", .f.) RETURN .t.