IBM AS/400 manual Using SQL Statements

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 79
Image 79
Using SQL Statements

Using SQL Statements

A*****************************************************************

A* DESCRIPTION: This

is the

DDS

for the physical file EMPMST.

*

A*

It

contains

one

record

format

called EMPREC.

*

A*

This

file contains one

record

for each employee *

A*

of

the company.

 

 

 

*

A*****************************************************************

A*

AR EMPREC

A

ENUM

5

0

TEXT('EMPLOYEE NUMBER')

A

ENAME

20

 

TEXT('EMPLOYEE NAME')

A

ETYPE

1

 

TEXT('EMPLOYEE TYPE')

A

EDEPT

3

0

TEXT('EMPLOYEE

DEPARTMENT')

A

ENHRS

3

1

TEXT('EMPLOYEE

NORMAL WEEK HOURS')

AK ENUM

Figure 29. DDS for EMPRPT

To create a program from this source use the CRTBNDRPG command, speci DFTACTGRP(*NO).

Using SQL Statements

The

DB2

UDB

for AS/400database can

be

accessed from

an

ILE RPG pro

by

embedding

SQL statements into your program source. Use the follow

enter your SQL

statements:

 

 

 

 

 

¹

Enter

your

SQL

statements

on the

Calculation specification

 

¹

Start

your

SQL

statements

using the

delimiter /EXEC SQL

in

positions 7-

 

(with

the

/

in position

7)

 

 

 

 

¹You can start entering your SQL statements on the same line as the delimiter

¹

Use

the

continuation line

delimiter

(a

+

in

position 7)

to

continue

 

ments

on

any subsequent

lines

 

 

 

 

 

 

 

¹

Use

the

ending

delimiter

/END-EXEC in

positions

7-15

(with

the

slash

 

tion

7) to signal the end of your SQL statements.

 

 

 

Note: SQL

statements

cannot

go

past position

80

in

your

program.

 

Figure 30 on page 56 shows an example of embedded SQL statements.

Chapter 5. Entering Source Statements55

Page 79
Image 79
IBM AS/400 manual Using SQL Statements