Embedded SQL and Fujitsu COBOL 
Author Message
 Embedded SQL and Fujitsu COBOL

We have been using embedded SQL for a good portion of the semester, but
only to retrieve portions of a table (e.g. the first five entries).  For
the final exam (ouch), I have asked students to retrieve an entire
table.  Using the samples given in the supplied documentation we have
come up with the following code.  The only error message we receive
(using Fujitsu v3) is "SYNTAX OF WHENEVER STATEMENT IS INVALID."  Yet it
appears to match that given in the documentation.

Are we missing something?  Is there another (or better) technique for
retrieving an entire table?  Is checking SQLSTATE a better way to go?
Thanks for any comments.

IDENTIFICATION DIVISION.
PROGRAM-ID.                     SQL-Test.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER.  IBM-PC.
OBJECT-COMPUTER.  IBM-PC.

DATA DIVISION.
WORKING-STORAGE SECTION.
     exec sql
         begin declare section
     end-exec.
01   sqlstate                   pic X(5).
01   counter                    pic S9(9).
01   CharTrip                   pic S9(9)    comp-5.
01   ModName                    pic X(50).
     exec sql
         end declare section
     end-exec.          

01   OUT-CharTrip               pic 99999.
01   OUT-ModName                pic X(50).

PROCEDURE DIVISION.
SQL-Test-paragraph.
        exec sql
                WHENEVER NOT FOUND GO TO LoopEnd
        end-exec

        exec sql
                CONNECT TO default
        end-exec

        exec sql
          declare PlaneType cursor STATIC
          for select Charter.Char_Trip, Model.Mod_Name
                     from Charter, Model, Aircraft
                     where Charter.AC_Number = Aircraft.AC_Number
                           and Aircraft.Mod_Code = Model.Mod_Code
                           and Model.Mod_Name = 'Navajo
Chieftain'                      
        end-exec

        exec sql
                open PlaneType
        end-exec                                                        
        .

Looper.    
        exec sql
                  fetch PlaneType into :CharTrip, :ModName
        end-exec

        move CharTrip to OUT-CharTrip
        move ModName to OUT-ModName
        display OUT-CharTrip, "   ", OUT-ModName
        GO TO Looper
        .

LoopEnd.    
        exec sql
                  close PlaneType
        end-exec

        exec sql
                  rollback work
        end-exec

        exec sql
                  disconnect default
        end-exec

        stop run
        .                

--
+-----------------------------------------------------------+
|                      Floyd H. Johnson                     |
+-----------------------------+-----------------------------+
| Voice  : (716) 594 - 0942   | 87 Parkway Drive            |

+-----------------------------+-----------------------------+
|                 http://www.*-*-*.com/ ;                |
+-----------------------------------------------------------+
| If you think you understand Him,                          |
|               then you really do not know HIM !!          |
+-----------------------------------------------------------+



Sat, 31 May 2003 23:50:30 GMT  
 Embedded SQL and Fujitsu COBOL
We have been using embedded SQL for a good portion of the semester, but
only to retrieve portions of a table (e.g. the first five entries).  For
the final exam (ouch), I have asked students to retrieve an entire
table.  Using the samples given in the supplied documentation we have
come up with the following code.  The only error message we receive
(using Fujitsu v3) is "SYNTAX OF WHENEVER STATEMENT IS INVALID."  Yet it
appears to match that given in the documentation.

Are we missing something?  Is there another (or better) technique for
retrieving an entire table?  Is checking SQLSTATE a better way to go?
Thanks for any comments.

IDENTIFICATION DIVISION.
PROGRAM-ID.                     SQL-Test.

ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SOURCE-COMPUTER.  IBM-PC.
OBJECT-COMPUTER.  IBM-PC.

DATA DIVISION.
WORKING-STORAGE SECTION.
     exec sql
         begin declare section
     end-exec.
01   sqlstate                   pic X(5).
01   counter                    pic S9(9).
01   CharTrip                   pic S9(9)    comp-5.
01   ModName                    pic X(50).
     exec sql
         end declare section
     end-exec.          

01   OUT-CharTrip               pic 99999.
01   OUT-ModName                pic X(50).

PROCEDURE DIVISION.
SQL-Test-paragraph.
        exec sql
                WHENEVER NOT FOUND GO TO LoopEnd
        end-exec

        exec sql
                CONNECT TO default
        end-exec

        exec sql
          declare PlaneType cursor STATIC
          for select Charter.Char_Trip, Model.Mod_Name
                     from Charter, Model, Aircraft
                     where Charter.AC_Number = Aircraft.AC_Number
                           and Aircraft.Mod_Code = Model.Mod_Code
                           and Model.Mod_Name = 'Navajo
Chieftain'                      
        end-exec

        exec sql
                open PlaneType
        end-exec                                                        
        .

Looper.    
        exec sql
                  fetch PlaneType into :CharTrip, :ModName
        end-exec

        move CharTrip to OUT-CharTrip
        move ModName to OUT-ModName
        display OUT-CharTrip, "   ", OUT-ModName
        GO TO Looper
        .

LoopEnd.    
        exec sql
                  close PlaneType
        end-exec

        exec sql
                  rollback work
        end-exec

        exec sql
                  disconnect default
        end-exec

        stop run
        .                

--
+-----------------------------------------------------------+
|                      Floyd H. Johnson                     |
+-----------------------------+-----------------------------+
| Voice  : (716) 594 - 0942   | 87 Parkway Drive            |

+-----------------------------+-----------------------------+
|                 http://bounce.to/Roberts                  |
+-----------------------------------------------------------+
| If you think you understand Him,                          |
|               then you really do not know HIM !!          |
+-----------------------------------------------------------+



Sat, 31 May 2003 23:50:54 GMT  
 Embedded SQL and Fujitsu COBOL


Quote:
> The only error message we receive
> (using Fujitsu v3) is "SYNTAX OF WHENEVER STATEMENT IS INVALID."
PROCEDURE DIVISION.
>...
>SQL-Test-paragraph.
> exec sql
> WHENEVER NOT FOUND GO TO LoopEnd
> end-exec

Try "WHENEVER NOT FOUND GO TO :LoopEnd" since you are still in a Exec SQL
statement.

Brad Prothero
Clarica Life Insurance
Fargo, ND



Sun, 01 Jun 2003 05:15:10 GMT  
 Embedded SQL and Fujitsu COBOL
We have tried this - in fact we started there and then tried it without
the colon.  I thought I had sent the version with the colon - though
obviously, I did not.  However, we get the same error message either
way.

exec sql
     WHENEVER NOT FOUND GO TO :LoopEnd
end-exec

SYNTAX OF WHENEVER STATEMENT IS INVALID.

Thanks for the note.

Floyd Johnson

===============================

Quote:

> Try "WHENEVER NOT FOUND GO TO :LoopEnd" since you are still in a Exec SQL
> statement.

> Brad Prothero
> Clarica Life Insurance
> Fargo, ND

--
+-----------------------------------------------------------+
|                      Floyd H. Johnson                     |
+-----------------------------+-----------------------------+
| Voice  : (716) 594 - 0942   | 87 Parkway Drive            |

+-----------------------------+-----------------------------+
|                 http://bounce.to/Roberts                  |
+-----------------------------------------------------------+
| If you think you understand Him,                          |
|               then you really do not know HIM !!          |
+-----------------------------------------------------------+


Sun, 01 Jun 2003 05:49:10 GMT  
 Embedded SQL and Fujitsu COBOL

I took your code and fiddled withit and got it to work. All I did was
capatalize the LOOPEND in the Whenever statement and it compiled cleanly.

Brad Prothero
Clarica Life Insurance
Fargo, ND



Sun, 01 Jun 2003 06:17:12 GMT  
 Embedded SQL and Fujitsu COBOL
Okay - I will try caps - I missed that.  Thanks.

: I took your code and fiddled withit and got it to work. All I did was
: capatalize the LOOPEND in the Whenever statement and it compiled cleanly.

: Brad Prothero
: Clarica Life Insurance
: Fargo, ND

--
--
+-----------------------------------------------------------+
|                      Floyd H. Johnson                     |
+-----------------------------+-----------------------------+    
| Voice  : (716) 594 - 0942   | 87 Parkway Drive            |

+-----------------------------+-----------------------------+
|                 http://bounce.to/Roberts                  |
+-----------------------------------------------------------+
| If you think you understand Him,                          |
|               then you really do not know HIM !!          |
+-----------------------------------------------------------+



Sun, 01 Jun 2003 06:45:45 GMT  
 Embedded SQL and Fujitsu COBOL
It seems to work.  What is the principle that requires caps in the SQL
statement?  Neither COBOL or SQL requires caps?

Thanks for the assist.

Floyd Johnson

: Okay - I will try caps - I missed that.  Thanks.


: : I took your code and fiddled withit and got it to work. All I did was
: : capatalize the LOOPEND in the Whenever statement and it compiled cleanly.

: : Brad Prothero
: : Clarica Life Insurance
: : Fargo, ND

: --
: --
: +-----------------------------------------------------------+
: |                      Floyd H. Johnson                     |
: +-----------------------------+-----------------------------+    
: | Voice  : (716) 594 - 0942   | 87 Parkway Drive            |

: +-----------------------------+-----------------------------+
: |                 http://bounce.to/Roberts                  |
: +-----------------------------------------------------------+
: | If you think you understand Him,                          |
: |               then you really do not know HIM !!          |
: +-----------------------------------------------------------+

--
--
+-----------------------------------------------------------+
|                      Floyd H. Johnson                     |
+-----------------------------+-----------------------------+    
| Voice  : (716) 594 - 0942   | 87 Parkway Drive            |

+-----------------------------+-----------------------------+
|                 http://bounce.to/Roberts                  |
+-----------------------------------------------------------+
| If you think you understand Him,                          |
|               then you really do not know HIM !!          |
+-----------------------------------------------------------+



Sun, 01 Jun 2003 06:59:01 GMT  
 Embedded SQL and Fujitsu COBOL
Quote:

> It seems to work.  What is the principle that requires caps in the SQL
> statement?  Neither COBOL or SQL requires caps?

<snip>

I had a similar problem and discussed this with Fujitsu while
doing a 90 day trial of V5.  What I found is, anything to do with
SQL should be done in UPPER CASE to avoid all ambiguities.

--
Steve Thompson
OSP LLC
330/335-9907 office
330/334-2097 fax

Remove "_" in email address to contact me -- anti-spam measures
in use



Mon, 02 Jun 2003 00:11:35 GMT  
 Embedded SQL and Fujitsu COBOL
: > It seems to work.  What is the principle that requires caps in the SQL
: > statement?  Neither COBOL or SQL requires caps?

: I had a similar problem and discussed this with Fujitsu while
: doing a 90 day trial of V5.  What I found is, anything to do with
: SQL should be done in UPPER CASE to avoid all ambiguities.

Very interesting.  We had a similar problem with quotation marks.  A
student had a SQL statement that worked in an interactive mode, but when
used within a COBOL program it bombed.  At least this was compiling and
sending messages to the ODBC driver and we could look at the trace.  The
offending SQL SELECT statement was being sent to the driver with two
trailing double quotation marks.  When we changed the double quotes to
single quotes, all worked well.  

Thanks for the feedback.

Floyd

--
--
+-----------------------------------------------------------+
|                      Floyd H. Johnson                     |
+-----------------------------+-----------------------------+    
| Voice  : (716) 594 - 0942   | 87 Parkway Drive            |

+-----------------------------+-----------------------------+
|                 http://bounce.to/Roberts                  |
+-----------------------------------------------------------+
| If you think you understand Him,                          |
|               then you really do not know HIM !!          |
+-----------------------------------------------------------+



Mon, 02 Jun 2003 01:07:22 GMT  
 Embedded SQL and Fujitsu COBOL

: I had a similar problem and discussed this with Fujitsu while
: doing a 90 day trial of V5.  What I found is, anything to do with
: SQL should be done in UPPER CASE to avoid all ambiguities.

Hmmm .... I would be interested in knowing if this "feature" is a function
of Fujitsu's SQL parser or ODBC interface, the intermediate ODBC tool
itself, or the SQL interpreter on the DB Server?

I would guess that it is a Fujitsu problem.  If the problem were with the
ODBC tool or the SQL Server, then students (some student took our intro
and carried it further) who used REXX or VB would have reported similar
problems.  Is this the standard found in other versions of COBOL as well?

Learning as I go --

Floyd Johnson

--
--
+-----------------------------------------------------------+
|                      Floyd H. Johnson                     |
+-----------------------------+-----------------------------+    
| Voice  : (716) 594 - 0942   | 87 Parkway Drive            |

+-----------------------------+-----------------------------+
|                 http://bounce.to/Roberts                  |
+-----------------------------------------------------------+
| If you think you understand Him,                          |
|               then you really do not know HIM !!          |
+-----------------------------------------------------------+



Mon, 02 Jun 2003 02:54:00 GMT  
 Embedded SQL and Fujitsu COBOL
    We shouldn't be surprised about the capitals only "feature".
some things are a given.

    A real unix programmer does not need capital letters.
    A real Cobol programmer uses nothing else.
    A real soldier does not have a first name anymore.


Quote:

> : I had a similar problem and discussed this with Fujitsu while
> : doing a 90 day trial of V5.  What I found is, anything to do
with
> : SQL should be done in UPPER CASE to avoid all ambiguities.

> Hmmm .... I would be interested in knowing if this "feature" is
a function
> of Fujitsu's SQL parser or ODBC interface, the intermediate
ODBC tool
> itself, or the SQL interpreter on the DB Server?

> I would guess that it is a Fujitsu problem.  If the problem
were with the
> ODBC tool or the SQL Server, then students (some student took
our intro
> and carried it further) who used REXX or VB would have reported
similar
> problems.  Is this the standard found in other versions of
COBOL as well?

> Learning as I go --

> Floyd Johnson

> --
> --
> +-----------------------------------------------------------+
> |                      Floyd H. Johnson                     |
> +-----------------------------+-----------------------------+
> | Voice  : (716) 594 - 0942   | 87 Parkway Drive            |

> +-----------------------------+-----------------------------+
> |                 http://bounce.to/Roberts                  |
> +-----------------------------------------------------------+
> | If you think you understand Him,                          |
> |               then you really do not know HIM !!          |
> +-----------------------------------------------------------+



Mon, 02 Jun 2003 16:26:20 GMT  
 Embedded SQL and Fujitsu COBOL
A little of both.

Later versions of Fujitsu do better with ODBC -- but even so, using C
and C++ and COBOL we found that for COBOL the Oracle Pro*COBOL
pre-compiler gave the best results.  Using ODBC, I had to use the MS
ODBC Oracle drivers with Fujitsu COBOL -- the Oracle ones didn't work
well (or was it the other way around?) anyway, using ASP pages we find
that from C++ Oracle drivers work better, but from ASP MS Drivers do
the best.  Wierd.


Quote:

>: I had a similar problem and discussed this with Fujitsu while
>: doing a 90 day trial of V5.  What I found is, anything to do with
>: SQL should be done in UPPER CASE to avoid all ambiguities.

>Hmmm .... I would be interested in knowing if this "feature" is a function
>of Fujitsu's SQL parser or ODBC interface, the intermediate ODBC tool
>itself, or the SQL interpreter on the DB Server?

>I would guess that it is a Fujitsu problem.  If the problem were with the
>ODBC tool or the SQL Server, then students (some student took our intro
>and carried it further) who used REXX or VB would have reported similar
>problems.  Is this the standard found in other versions of COBOL as well?

>Learning as I go --

>Floyd Johnson

>--
>--
>+-----------------------------------------------------------+
>|                      Floyd H. Johnson                     |
>+-----------------------------+-----------------------------+    
>| Voice  : (716) 594 - 0942   | 87 Parkway Drive            |

>+-----------------------------+-----------------------------+
>|                 http://bounce.to/Roberts                  |
>+-----------------------------------------------------------+
>| If you think you understand Him,                          |
>|               then you really do not know HIM !!          |
>+-----------------------------------------------------------+

---
Try a better search engine:  http://www.google.com
My personal web site: http://www.geocities.com/Eureka/2006/


Fri, 06 Jun 2003 10:59:29 GMT  
 
 [ 12 post ] 

 Relevant Pages 

1. Fujitsu Cobol 3.0 - Embedded SQL

2. Fujitsu COBOL -- 45,000 Developers Receive Fujitsu COBOL at Microsoft Developer Days

3. SQL Fujitsu's COBOL V.3

4. ACCESS 97 SQL and Fujitsu COBOL

5. Fujitsu Cobol SQL Access

6. SQL/ODBC for fujitsu cobol

7. Fujitsu COBOL and SQL

8. SQL SUBSTRING format in Fujitsu COBOL (PARADOX)

9. embedded SQL/COBOL TimeStamp

10. COBOL and embedded SQL

11. Writing transportable COBOL and embedded SQL.

12. Embedding SQL in Microfocus Cobol

 

 
Powered by phpBB® Forum Software