Highlighted
Outstanding Contributor.
Outstanding Contributor.
184 views

Create database on MSSQL with problem

Jump to solution

on mssql tool the database is created, with visual Cobol not, i become mssql-error-code -102 or -226

What is wrong?

Please see the Notepad document in attachment

 

to create tables is not the Problem! create DATABASE

 

 

 

 

0 Likes
1 Solution

Accepted Solutions
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Create database on MSSQL with problem

Jump to solution

Hello Greiner,

 

I believe the 226 error is caused by the fact that you are trying to execute a CREATE DATABASE statement in transaction mode, when SQL Server does not allow such statements (CREATE DATABASE, ALTER DATABASE) to be executed in a program that uses SQL transactions.

 

By default, Visual COBOL uses transaction mode with OpenESQL. To instead have this statement committed as soon as it is executed (momentarily turn off transaction mode), you can use:

 

EXEC SQL SET AUTOCOMMIT ON END-EXEC

 

just before the CREATE DATABASE statement, and then use:

 

EXEC SQL SET AUTOCOMMIT OFF END-EXEC

 

just after the CREATE DATABASE to resume transaction support in your COBOL program.

 

(note, fixed a couple of typo's above...)

Blair McDonald

View solution in original post

0 Likes
5 Replies
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Create database on MSSQL with problem

Jump to solution

Hello Greiner,

 

I believe the 226 error is caused by the fact that you are trying to execute a CREATE DATABASE statement in transaction mode, when SQL Server does not allow such statements (CREATE DATABASE, ALTER DATABASE) to be executed in a program that uses SQL transactions.

 

By default, Visual COBOL uses transaction mode with OpenESQL. To instead have this statement committed as soon as it is executed (momentarily turn off transaction mode), you can use:

 

EXEC SQL SET AUTOCOMMIT ON END-EXEC

 

just before the CREATE DATABASE statement, and then use:

 

EXEC SQL SET AUTOCOMMIT OFF END-EXEC

 

just after the CREATE DATABASE to resume transaction support in your COBOL program.

 

(note, fixed a couple of typo's above...)

Blair McDonald

View solution in original post

0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: Create database on MSSQL with problem

Jump to solution
Thank you for this Information, i will test it today and give you a answer so soon as possible!
0 Likes
Highlighted
Outstanding Contributor.
Outstanding Contributor.

Re: Create database on MSSQL with problem

Jump to solution
Yes, it works perfectly!
0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Create database on MSSQL with problem

Jump to solution

Glad to hear it worked out for you. Thank you for letting us know!

Blair McDonald

0 Likes
Highlighted
Micro Focus Expert
Micro Focus Expert

Re: Create database on MSSQL with problem

Jump to solution
Glad to hear it worked out for you - thanks for letting us know.


Blair McDonald

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.