Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

writing to a mdb table

Status
Not open for further replies.

ptrj

Programmer
Feb 22, 2006
10
BE
Hello, this is just a simple test code, but it doesnt work.. What's worong?

000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. cvsSchrijf.

ENVIRONMENT DIVISION.

DATA DIVISION.
file section.


working-storage section.
01 einde pic 9 value 0.
01 verder pic x.
01 teller pic 999 value 0.



PROCEDURE DIVISION.
pgm.
perform dbconnect

exec SQL
INSERT INTO student_csv
(
dbkode,
dbstamnummer,
dbnaamstu,
dbvoornaam_stu
)
VALUES
(
'lsdjfk',
'lsqjdf',
'lsdkjf',
'mlksqdjf'
)

end-exec.


perform dbdisconnect
stop run.

dbconnect.
exec SQL
connect to "jdbc:eek:dbc:Driver={Microsoft Access Driver (*.mdb)};
DBQ=C:\sDoc\Stage.mdb"
DRIVER "sun.jdbc.odbc.JdbcOdbcDriver"
end-exec.
exec SQL
set transaction read only
end-exec.

dbdisconnect.
exec SQL
commit
disconnect
end-exec.
 
set transaction read only
probabaly.
using the single quotes as string delimiter
Also a possibility depending on compiler vendor, version and (pre)compile options used



But without knowing your COBOL compiler and version, your OS used, and what is the errors you are getting it is very hard to tell.

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
set transaction read only
???

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
My OS is Windows xp pro nl,
My cobol compiler is percobol
I use office 2003 pro nl >> access 2003

I think read only would not help.. i have to read
anybody with solutions or examples?
 
but it doesnt work
Any chance you could post some more elaborated info such like, say, an error message ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
sorry, i did not see read only,
now it works but he would ony add 1 record.
How can i fix this, so that he add the 3 records in his perform?
code:
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. cvsSchrijf.

ENVIRONMENT DIVISION.

DATA DIVISION.
file section.


working-storage section.
01 einde pic 9 value 0.
01 verder pic x.
01 teller pic 999 value 0.



PROCEDURE DIVISION.
pgm.
perform dbconnect

perform until teller < 2
exec SQL
INSERT INTO student_csv
(
dbkode,
dbstamnummer,
dbnaamstu,
dbvoornaam_stu
)
VALUES
(
'lsdjfk',
'lsqjdf',
'lsdkjf',
'mlksqdjf'
)

end-exec

add 1 to teller

end-perform



perform dbdisconnect
display "done"
accept verder
stop run.

dbconnect.
exec SQL
connect to "jdbc:eek:dbc:Driver={Microsoft Access Driver (*.mdb)};
DBQ=C:\sDoc\Stage.mdb"
DRIVER "sun.jdbc.odbc.JdbcOdbcDriver"
end-exec.
exec SQL
set transaction write only
end-exec.

dbdisconnect.
exec SQL
commit
disconnect
end-exec.
 
perform until teller [!]>[/!] 2

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
ok stupid mistake,
but it stell writes only one record.
Maby he override every time the first record.
but why
can someone help me pls?
 
ptrj,
I'm surprised that the first example where the < was used instead of > wrote anything at all. Perform examines the condition before it does anything and if the condition is met, then does not perform the perform. So, in your first example the field teller would have been 0, so no insert would have taken place.

If you have changed the < to a > then the insert should be performed 3 times, once when teller is 0, once when teller is 1 and once when teller is 2. If this is not happening, then I would suggest looking at the database. Does the table have a key? As the same values for the record are being inserted, is it possible that the insert is not working, throwing back a duplicate key error. I notice that there is no check after the insert to see if it has worked successfully (something like an SQLCODE check)

Let us know if this helps.

Marc
 
Aah I know what the problem is:
in the perform loop I did always the same values >> the record key dbkode was all the time the same value.
Now i have made a teller field and it works
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top