Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Wrong numeric field size from SQLEXEC() call
Message
From
15/12/2005 06:13:56
 
 
To
14/12/2005 10:57:41
General information
Forum:
Visual FoxPro
Category:
Client/server
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01077250
Message ID:
01078161
Views:
29
>I had a look at the links you posted but without having repro code I cannot tell you if SQLEXECEX would work.

Christian,

here is the simplified repro code. It needs some minor modifications (see comments) to use VFP built-in SQLEXEC() and STRINGCONNECT(). Also it needs cleanup.

Can you post the repro code, confirm that C5 error exist in standard SQLEXEC() and post result of SQLEXECEX() call?
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.
Andrus
Previous
Reply
Map
View

Click here to load this message in the networking platform