One other reccomendation.. I would construct the whole command into a text variable and then execute it with the ampersand...
Like: SET VAR vm_cmd1 TEXT = 'INSERT INTO bilder (ut) VALUES' SET VAR vm_cmd2 TEXT = '(['C:/inetpub/wwwroot/Hjortmar/formbilder/220.jpg'])' SET VAR vm_cmd TEXT = (.vm_cmd1 + ' ' + .vm_cmd2) &vm_cmd
I have had a lot better luck running code like this, plus makes it easier to trace when you can see the value of vm_cmd just before it executes.
I know some of the pure codists on this list would think it's a bit much to go this route, but as I said, I have had a lot better luck doing this, and besides, there have been some commands I have had to concatenate together in this fashion just to get it to work. They wouldn't work straight out.
Jim Limburg
Christian Hjortmar wrote:
Can a variable be used as value in a valuelist?
This is what the manual says I should do and it works:
INSERT INTO bilder (ut) VALUES (['C:/inetpub/wwwroot/Hjortmar/formbilder/220.jpg'])
but this is what I am trying to use:
INSERT INTO bilder (ut) VALUES .vbild
.vbild is a variable that contains the text (['C:/inetpub/wwwroot/Hjortmar/formbilder/220.jpg'])
I would like to insert images in my database and the images are all in the same directory.
Being a lazy boy I figured out the following code.
This is my little eep:
SET VAR vtal INTEGER = 219
SET VAR vbild TEXT = ' '
SET VAR vbildfil INTEGER = 1
SET VAR vfram TEXT = '(['
SET VAR vbak TEXT = '])'
SET VAR vparfr TEXT = '
SET VAR vparbak TEXT = '
WHILE vtal < 16500 THEN
vbild = 'C:/inetpub/wwwroot/Hjortmar/formbilder/' + (CTXT(.vtal)) + '.jpg'
vbildfil = (CHKFILE(.vbild))
vbild = .vfram + .vparfr + 'C:/inetpub/wwwroot/Hjortmar/formbilder/' + (CTXT(.vtal)) + '.jpg' + .vparbak + .vbak
IF vbildfil = 0 THEN
vbild = .vbild
ELSE
---*** INSERT INTO bilder (ut) VALUES (['C:/inetpub/wwwroot/Hjortmar/formbilder/220.jpg']) ***---
---*** A variable containing the same thing as the text above does not work in an insert command !!! ***---
INSERT INTO bilder (ut) VALUES .vbild
ENDIF
SET VAR vtal = (.vtal + 1)
ENDWHILE
RETURN
Regards from Christian Hjortmar
+ 46 46 2119142

