Skip to main content

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
Interesting, I've not heard I$IO being able to invoke a stored procedure in MSSQL. If this is possible I'd sure like to know about it as well. I wonder if the SQL.ACU program that comes with Acu4GL does anything like this.

Could someone from Acucorp please comment on this?

There are other ways to call MSSQL stored procedures from Acucobol-GT, such as using Acu4GL and calling the SQL.ACU program passing it your stored procedure call and parameters in a string.
AcuSQL can of course EXEC stored procedures directly.
You can run the ISQL and OSQL mssql client programs to call a stored procedure and output results to a text file.
You can use ADO with ActiveX/COM calls to run stored procedures and return result sets.
I'm pretty sure I mentioned all this in a prior post, sorry for repeating myself.

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
Interesting, I've not heard I$IO being able to invoke a stored procedure in MSSQL. If this is possible I'd sure like to know about it as well. I wonder if the SQL.ACU program that comes with Acu4GL does anything like this.

Could someone from Acucorp please comment on this?

There are other ways to call MSSQL stored procedures from Acucobol-GT, such as using Acu4GL and calling the SQL.ACU program passing it your stored procedure call and parameters in a string.
AcuSQL can of course EXEC stored procedures directly.
You can run the ISQL and OSQL mssql client programs to call a stored procedure and output results to a text file.
You can use ADO with ActiveX/COM calls to run stored procedures and return result sets.
I'm pretty sure I mentioned all this in a prior post, sorry for repeating myself.

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
Dan,
Is the coding for executing a stored procedure in AcuSQL just
EXEC sp_name END-EXEC?

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
A sample can be found here:

http://www.acucorp.com/support/public/sample_programs/files/asqlsp.zip

Look in the sqlsp.cbl file at the last paragraph named Exec-StoredP.

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
The i$io routine has an execute mode (15) that fires a raw command to a file system driver. What happenes then depends on how that driver was coded. I would expect most of the 4gl drivers would pass the command parameter to the database.

Of course, this not useful if you need results from the procedure. Also, you may need to null terminate your strings.

Merlin

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
The i$io routine has an execute mode (15) that fires a raw command to a file system driver. What happenes then depends on how that driver was coded. I would expect most of the 4gl drivers would pass the command parameter to the database.

Of course, this not useful if you need results from the procedure. Also, you may need to null terminate your strings.

Merlin

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
Hmm, in reading the documentation about I$IO code 15 it sounds like the runtime would have to have the desired file system support installed, for instance MSSQL, which requires the purchase of Acu4GL for MSSQL. Am I wrong about this?

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
Yes, the I$IO routine interfaces with the runtime calls to file systems available to the runtime only. This basically means 4gl runtimes.

With some clever hacking, it is possible to write a custom file sytem, but that's a topic of another conversation ;)

Another possible tricky way to execute stored procedure would be to open a pipe to a command line sql interface (not sure if isql allows this) and write to it like a sequential file.

Merlin

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
Before using Acu4GL, I used osql in a similiar way where I made a C$SYSTEM call in acucobol with a command line similiar to this:

osql -SMySqlServer -Usa -Psa -Q "exec Northwind.dbo.CustOrderHist 'ALFKI' " -oresults.txt -w500 -s"|"

...and then opened the sequential file and parsed the results.

It's not fancy, nor is it efficient for large and varied quieries, but it works well for calling stored procedures and doesn't require Acu4GL or AcuSQL. osql also supports inputfile queries, so if you don't want to pass a long command line you could put your query into a sequential file first and add it to command line with -i switch.
ex. osql -SMysqlServer -Usa -Psa -isqlscript.sql -n -oresults.txt -w500 -s"|"

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
Before using Acu4GL, I used osql in a similiar way where I made a C$SYSTEM call in acucobol with a command line similiar to this:

osql -SMySqlServer -Usa -Psa -Q "exec Northwind.dbo.CustOrderHist 'ALFKI' " -oresults.txt -w500 -s"|"

...and then opened the sequential file and parsed the results.

It's not fancy, nor is it efficient for large and varied quieries, but it works well for calling stored procedures and doesn't require Acu4GL or AcuSQL. osql also supports inputfile queries, so if you don't want to pass a long command line you could put your query into a sequential file first and add it to command line with -i switch.
ex. osql -SMysqlServer -Usa -Psa -isqlscript.sql -n -oresults.txt -w500 -s"|"

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
right. Since you can call c routines from cobol, it's possible to make odbc calls. That's a lot of coding though, becuase c and cobol types are so differnt.

Merlin

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
The C routines option is interesting, but would it be easiar to do it with ADO calls through Acucobol-GT COM interoperability?

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
probably. I haven't worked a whole lot with com, but I would imagine that would be the best way if you wanted to work through an ado driver.

For top performance, thought, it's faster to make direct sql calls to the database.

Merlin

[Migrated content. Thread originally posted on 06 October 2004]

I have heard it is possible to execute a SQL Server Stored Procedure from a cobol program using "I$IO". Is this true, and if so does anyone have an example of the necessary coding?

Thanks a lot!:confused:
probably. I haven't worked a whole lot with com, but I would imagine that would be the best way if you wanted to work through an ado driver.

For top performance, thought, it's faster to make direct sql calls to the database.

Merlin