SlideShare a Scribd company logo
• An alternative database interface language
• NOT a database management system
• High level, simple statement formats
• A language used for:
• Data Definition (DDL)
• Data Manipulation (DML)
• Completely interchangeable data methods
• SQL tables may be accessed with native language
• DDS created files can be access with SQL
• Great for selecting and manipulating groups of data
• If you want to update/delete all the records in a file matching a certain
criteria, use SQL. SQL can change or delete a group of records in a single
statement, whereas native I/O would require you to loop through a file
and issue individual update or delete statements.
• Columnar functions allow for column/field manipulation during
the record selection phase
• SQL has many columnar functions designed to tally, total, summarize,
manipulate, and calculate columns of data. Many program features such
as substringing, averaging, and math functions can be performed
during the record selection phase. Columns can even be returned that
don't exist in the file, such as counts, calculations, literals, and dates.
• Aggregate data
• if you wanted to find a list of all the different zip codes in a mailing
address file and count how many addresses were in each zip code, SQL
can easily accomplish this in a single statement. In native I/O you would
have to loop through a file and increment counter fields or use arrays
and/or multiple-occurrence data structures to aggregate like data.
• Interactive SQL
STRSQL
Quick ad-hoc queries
• Embedded SQL
Alternative to native file I/O
Allows for SQL functionality in RPG or COBOL
• STRSQL (Green Screen)
• System i Navigator
• Most Common SQL Statements
The SELECT statement is used to select data from a database. The result is
stored in a result table, called the result-set.
The UPDATE statement is used to update existing records in a table.
The DELETE statement is used to delete rows in a table.
• SELECT *
FROM EMPLOYEE
• SELECT EMPNO, LASTNAME, BIRTHDATE, SALARY
FROM EMPLOYEE
WHERE SALARY > 30000
• SELECT LASTNAME, SALARY, BONUS, COM
FROM EMPLOYEE
WHERE SALARY > 22000 AND BONUS = 400
OR BONUS = 500 AND COM < 1900
ORDER BY LASTNAME
• UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
• Be careful when updating records !!!
If you omit the WHERE, all records get
updated
• Example:
UPDATE EMPLOYEE
SET SALARY = SALARY + 1000
WHERE WORKDEPT = 'C01'
• DELETE FROM table_name
WHERE some_column=some_value
• BE CAREFUL WHEN DELETING RECORDS!
Like the UPDATE statement, if you omit the
WHERE clause, all records get deleted.
BACK IT UP!
• Example:
DELETE FROM TESTEMP
WHERE EMPNO = '000111'
• Static SQL
The simplest form of embedding SQL in RPG or COBOL
The SQL statement is hard coded in your program
• Dynamic SQL
The SQL statement is assembled at run-time
Requires more resource at run-time for preparing the statement
Makes an application very dynamic
Can become very sophisticated
• Most variables defined in RPG or COBOL can be used in a SQL
statement
• Variables are preceded by a colon, ( : ).
• Example:
To use RPG or COBOL’s variable field name
ITMNBR in SQL use it as :ITMNBR
COST OF ON HAND INVENTORY
ITEM# DESCRIPTION COST QTY OH COST OH
20001 Telephone, one line 15.00 10 150.00
20002 Telephone, two line 89.00 5 445.00
20003 Speaker Telephone 85.00 6 510.00
20004 Telephone Extension Cord 1.10 25 27.50
20005 Dry Erase Marker Packs 2.25 428 963.00
20006 Executive Chairs 325.00 10 3,250.00
20007 Secretarial Chairs 55.00 13 715.00
20008 Desk Calendar Pads 5.00 56 280.00
20009 Diskette Mailers .20 128 25.60
20010 Address Books 6.00 1,680 10,080.00
20011 Desk lamp, brass 20.00 3 60.00
20012 Blue pens 20.00 7 140.00
20013 Red pens 100.00 14 1,400.00
20014 Black pens 150.00 25 3,750.00
20015 Number 2 pencils 2.50 150 375.00
20016 Number 3 pencils 4.50 25 112.50
20017 Two Drawer File Cabinets 5.50 15 82.50
20018 Manilla folders 4.00 50 200.00
20019 Hanging file folders 3.00 150 450.00
20020 Metal desk 125.00 2 250.00
::::: :::::::::::::::::::: :::: ::::: ::::::
20045 Blue paper, 8 1/2 X 11 2.95 75 221.25
20046 Continuous 8,5 X 11 paper 20.00 24 480.00
20047 Yellow paper, 8 1/2 X 11 2.95 199 587.05
20048 3 hole white paper 3.35 35 117.25
20049 3 hole lined paper 3.85 10 38.50
20050 Heavy duty stapler 9.15 5 45.75
TOTAL COST OF INVENTORY ON HAND: 51,755.90
• Step 1 – calculate average Item cost
• Read all item records and calculate the ITMCOST average
• Put the average result in AVGCOST
• Step 2 – Select Item cost > Average cost
• Re-Read all item records again and compare the ITMCOST to
AVGCOST
• If the ITMCOST > AVGCOST calculate the amount of
ITMCOST * ITMQTYOH to ITMCOSTOH and print the record,
if NOT read next records
• Print a total of ITMCOSTOH after all records have been
read.
• select avg(itmcost) from item_pf
0001.00 010313
0002.00 FItpCost2 O E Printer OflInd(PrtOver) 150612
0003.00 Drecend s n 150614
0004.00 DITEMDS E DS EXTNAME(ITEM_PF:ITEM_FMT) 091212
0005.00 Drata s 5 2 150612
0006.00 020125
0007.00 /Free 020125
0008.00 150614
0009.00 Write Heading; 020125
0010.00 010313
0011.00 EXEC SQL select avg(itmcost) into :rata from item_pf; 150614
0012.00 150614
0013.00 EXEC SQL DECLARE C1 CURSOR FOR SELECT itmnbr, 150614
0014.00 itmdescr, itmcost, itmqtyoh, itmcost * itmqtyoh as 150614
0015.00 OnHand from item_pf where itmcost > :rata; 150614
0016.00 150614
0017.00 EXEC SQL OPEN C1; 091212
0018.00 150614
0019.00 EXEC SQL FETCH C1 INTO :itmnbr, :itmdescr, :itmcost, :itmqtyoh, 150614
0020.00 :itmcostoh; 150614
0021.00 150612
0022.00 DoW not recend; 150327
0023.00 If PrtOver; // Check for overflow 020128
0024.00 Write Heading; 020125
0025.00 PrtOver = *Off; 020125
0026.00 Endif; 020125
0027.00 010313
0028.00 Write Detail; // Print detail record format 150614
0029.00 150612
0030.00 EXEC SQL FETCH C1 INTO :itmnbr, :itmdescr, :itmcost, :itmqtyoh, 150614
0031.00 :itmcostoh; 150614
0032.00 // *** Check whether no more recors to be processed 150614
0033.00 150327
0034.00 recend = (SQLCODE <> 0); 150614
0035.00 150327
0036.00 Enddo; 150614
0037.00 150612
0038.00 EXEC SQL select sum(itmcost * itmqtyoh) into :totcostoh from item_pf 150614
0039.00 where itmcost > :rata; 150614
0040.00 150614
0041.00 EXEC SQL CLOSE C1; 091212
0042.00 Write Total; // Print total record format 030731
0043.00 *InLR = *On; 020125
0044.00 /End-free 020125
Public Training SQL Implementation & Embedded Programming in IBM i

More Related Content

What's hot

Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005
rainynovember12
 
Advanced MySQL Query Tuning
Advanced MySQL Query TuningAdvanced MySQL Query Tuning
Advanced MySQL Query Tuning
Alexander Rubin
 
Lab
LabLab
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
Balqees Al.Mubarak
 
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Serban Tanasa
 
Billion Goods in Few Categories: how Histograms Save a Life?
Billion Goods in Few Categories: how Histograms Save a Life?Billion Goods in Few Categories: how Histograms Save a Life?
Billion Goods in Few Categories: how Histograms Save a Life?
Sveta Smirnova
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?
Sveta Smirnova
 
New SQL features in latest MySQL releases
New SQL features in latest MySQL releasesNew SQL features in latest MySQL releases
New SQL features in latest MySQL releases
Georgi Sotirov
 
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageJanuary 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
Zurich_R_User_Group
 
Sql
SqlSql
Migration from mysql to elasticsearch
Migration from mysql to elasticsearchMigration from mysql to elasticsearch
Migration from mysql to elasticsearch
Ryosuke Nakamura
 
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Sergey Petrunya
 

What's hot (13)

Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005Optimizing Data Accessin Sq Lserver2005
Optimizing Data Accessin Sq Lserver2005
 
Advanced MySQL Query Tuning
Advanced MySQL Query TuningAdvanced MySQL Query Tuning
Advanced MySQL Query Tuning
 
Lab
LabLab
Lab
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
 
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
Get up to Speed (Quick Guide to data.table in R and Pentaho PDI)
 
Ddl commands
Ddl commandsDdl commands
Ddl commands
 
Billion Goods in Few Categories: how Histograms Save a Life?
Billion Goods in Few Categories: how Histograms Save a Life?Billion Goods in Few Categories: how Histograms Save a Life?
Billion Goods in Few Categories: how Histograms Save a Life?
 
Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?Billion Goods in Few Categories: How Histograms Save a Life?
Billion Goods in Few Categories: How Histograms Save a Life?
 
New SQL features in latest MySQL releases
New SQL features in latest MySQL releasesNew SQL features in latest MySQL releases
New SQL features in latest MySQL releases
 
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table packageJanuary 2016 Meetup: Speeding up (big) data manipulation with data.table package
January 2016 Meetup: Speeding up (big) data manipulation with data.table package
 
Sql
SqlSql
Sql
 
Migration from mysql to elasticsearch
Migration from mysql to elasticsearchMigration from mysql to elasticsearch
Migration from mysql to elasticsearch
 
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
Common Table Expressions in MariaDB 10.2 (Percona Live Amsterdam 2016)
 

Viewers also liked

đau đầu Gối ở Trẻ Em
đau đầu Gối ở Trẻ Emđau đầu Gối ở Trẻ Em
đau đầu Gối ở Trẻ Emmariano271
 
Lactancia materna
Lactancia maternaLactancia materna
CPU Performance in Java.
CPU Performance in Java.CPU Performance in Java.
CPU Performance in Java.
Dzmitry Hil
 
Yibamboo furniture category 2017
Yibamboo furniture category 2017Yibamboo furniture category 2017
Yibamboo furniture category 2017
Julian Chen
 
Good Transboundary Water Governance
Good Transboundary Water GovernanceGood Transboundary Water Governance
Good Transboundary Water GovernanceZo Cuthbert
 
paulina koza prezentacja
paulina koza prezentacjapaulina koza prezentacja
paulina koza prezentacja
Paulina Koza
 
11 платформа microsoft office расширенные возможности
11 платформа microsoft office   расширенные возможности11 платформа microsoft office   расширенные возможности
11 платформа microsoft office расширенные возможности
KewpaN
 
DIGITAL WATERMARKING USING DIFFERENT CHAOTIC EQUATIONS
DIGITAL WATERMARKING USING DIFFERENT CHAOTIC EQUATIONSDIGITAL WATERMARKING USING DIFFERENT CHAOTIC EQUATIONS
DIGITAL WATERMARKING USING DIFFERENT CHAOTIC EQUATIONSdebasis sahoo
 
Thoai Hoa Khop Xuong
Thoai Hoa Khop XuongThoai Hoa Khop Xuong
Thoai Hoa Khop Xuongjune498
 
0 wiki технологии
0 wiki технологии0 wiki технологии
0 wiki технологии
KewpaN
 
14 расширенные возможности корпоративных субд
14 расширенные возможности корпоративных субд14 расширенные возможности корпоративных субд
14 расширенные возможности корпоративных субд
KewpaN
 
VIDEO JUEGOS
VIDEO JUEGOSVIDEO JUEGOS
VIDEO JUEGOS
Juan Esteban
 
2014 IHBI Advances Edition 20
2014 IHBI Advances Edition 202014 IHBI Advances Edition 20
2014 IHBI Advances Edition 20Shanchita Khan
 
Whitney houston......................
Whitney houston......................Whitney houston......................
Whitney houston......................
crystinn
 
Alona nieva presentation
Alona nieva   presentationAlona nieva   presentation
Alona nieva presentation
alonanieva
 
A development approach SUPERVISION
A development approach SUPERVISIONA development approach SUPERVISION
A development approach SUPERVISION
Badruzzaman_007
 
QUINCYCHUGH-PORTFOLIOPortfolio
QUINCYCHUGH-PORTFOLIOPortfolioQUINCYCHUGH-PORTFOLIOPortfolio
QUINCYCHUGH-PORTFOLIOPortfolio
Quuincy Chugh
 

Viewers also liked (20)

đau đầu Gối ở Trẻ Em
đau đầu Gối ở Trẻ Emđau đầu Gối ở Trẻ Em
đau đầu Gối ở Trẻ Em
 
biomass
biomassbiomass
biomass
 
Lactancia materna
Lactancia maternaLactancia materna
Lactancia materna
 
CPU Performance in Java.
CPU Performance in Java.CPU Performance in Java.
CPU Performance in Java.
 
Yibamboo furniture category 2017
Yibamboo furniture category 2017Yibamboo furniture category 2017
Yibamboo furniture category 2017
 
Good Transboundary Water Governance
Good Transboundary Water GovernanceGood Transboundary Water Governance
Good Transboundary Water Governance
 
paulina koza prezentacja
paulina koza prezentacjapaulina koza prezentacja
paulina koza prezentacja
 
11 платформа microsoft office расширенные возможности
11 платформа microsoft office   расширенные возможности11 платформа microsoft office   расширенные возможности
11 платформа microsoft office расширенные возможности
 
DIGITAL WATERMARKING USING DIFFERENT CHAOTIC EQUATIONS
DIGITAL WATERMARKING USING DIFFERENT CHAOTIC EQUATIONSDIGITAL WATERMARKING USING DIFFERENT CHAOTIC EQUATIONS
DIGITAL WATERMARKING USING DIFFERENT CHAOTIC EQUATIONS
 
Thoai Hoa Khop Xuong
Thoai Hoa Khop XuongThoai Hoa Khop Xuong
Thoai Hoa Khop Xuong
 
ใบงานที่ 1
ใบงานที่ 1ใบงานที่ 1
ใบงานที่ 1
 
Anmipro Presentation
Anmipro PresentationAnmipro Presentation
Anmipro Presentation
 
0 wiki технологии
0 wiki технологии0 wiki технологии
0 wiki технологии
 
14 расширенные возможности корпоративных субд
14 расширенные возможности корпоративных субд14 расширенные возможности корпоративных субд
14 расширенные возможности корпоративных субд
 
VIDEO JUEGOS
VIDEO JUEGOSVIDEO JUEGOS
VIDEO JUEGOS
 
2014 IHBI Advances Edition 20
2014 IHBI Advances Edition 202014 IHBI Advances Edition 20
2014 IHBI Advances Edition 20
 
Whitney houston......................
Whitney houston......................Whitney houston......................
Whitney houston......................
 
Alona nieva presentation
Alona nieva   presentationAlona nieva   presentation
Alona nieva presentation
 
A development approach SUPERVISION
A development approach SUPERVISIONA development approach SUPERVISION
A development approach SUPERVISION
 
QUINCYCHUGH-PORTFOLIOPortfolio
QUINCYCHUGH-PORTFOLIOPortfolioQUINCYCHUGH-PORTFOLIOPortfolio
QUINCYCHUGH-PORTFOLIOPortfolio
 

Similar to Public Training SQL Implementation & Embedded Programming in IBM i

SQL NAD DB.pptx
SQL NAD DB.pptxSQL NAD DB.pptx
SQL NAD DB.pptx
muhammadhumza26
 
Vendor session myFMbutler DoSQL 2
Vendor session myFMbutler DoSQL 2Vendor session myFMbutler DoSQL 2
Vendor session myFMbutler DoSQL 2
Koen Van Hulle
 
Microsoft SQL 000000000000000000001.pptx
Microsoft SQL 000000000000000000001.pptxMicrosoft SQL 000000000000000000001.pptx
Microsoft SQL 000000000000000000001.pptx
HaribabuKonakanchi1
 
In memory databases presentation
In memory databases presentationIn memory databases presentation
In memory databases presentation
Michael Keane
 
Etl2
Etl2Etl2
Database & Technology 2 _ Richard Foote _ 10 things you probably dont know ab...
Database & Technology 2 _ Richard Foote _ 10 things you probably dont know ab...Database & Technology 2 _ Richard Foote _ 10 things you probably dont know ab...
Database & Technology 2 _ Richard Foote _ 10 things you probably dont know ab...InSync2011
 
dbs class 7.ppt
dbs class 7.pptdbs class 7.ppt
dbs class 7.ppt
MARasheed3
 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
Dave Stokes
 
8. sql
8. sql8. sql
8. sql
khoahuy82
 
Erik_van_Roon.pdf
Erik_van_Roon.pdfErik_van_Roon.pdf
Erik_van_Roon.pdf
DetchDuvanGaelaCamar
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorial
Mohd Tousif
 
DBMS Chapter-3.ppsx
DBMS Chapter-3.ppsxDBMS Chapter-3.ppsx
DBMS Chapter-3.ppsx
DharmikPatel745100
 
AWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDB
AWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDBAWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDB
AWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDB
Amazon Web Services
 
IR SQLite Session #1
IR SQLite Session #1IR SQLite Session #1
IR SQLite Session #1
InfoRepos Technologies
 
about-SQL AND ETC.pptx
about-SQL AND ETC.pptxabout-SQL AND ETC.pptx
about-SQL AND ETC.pptx
jwhuqyqtayaw
 
MariaDB Server 10.3 - Temporale Daten und neues zur DB-Kompatibilität
MariaDB Server 10.3 - Temporale Daten und neues zur DB-KompatibilitätMariaDB Server 10.3 - Temporale Daten und neues zur DB-Kompatibilität
MariaDB Server 10.3 - Temporale Daten und neues zur DB-Kompatibilität
MariaDB plc
 
Triggers n Cursors.ppt
Triggers n Cursors.pptTriggers n Cursors.ppt
Triggers n Cursors.ppt
VADAPALLYPRAVEENKUMA1
 

Similar to Public Training SQL Implementation & Embedded Programming in IBM i (20)

SQL NAD DB.pptx
SQL NAD DB.pptxSQL NAD DB.pptx
SQL NAD DB.pptx
 
Vendor session myFMbutler DoSQL 2
Vendor session myFMbutler DoSQL 2Vendor session myFMbutler DoSQL 2
Vendor session myFMbutler DoSQL 2
 
Microsoft SQL 000000000000000000001.pptx
Microsoft SQL 000000000000000000001.pptxMicrosoft SQL 000000000000000000001.pptx
Microsoft SQL 000000000000000000001.pptx
 
In memory databases presentation
In memory databases presentationIn memory databases presentation
In memory databases presentation
 
Etl2
Etl2Etl2
Etl2
 
Database & Technology 2 _ Richard Foote _ 10 things you probably dont know ab...
Database & Technology 2 _ Richard Foote _ 10 things you probably dont know ab...Database & Technology 2 _ Richard Foote _ 10 things you probably dont know ab...
Database & Technology 2 _ Richard Foote _ 10 things you probably dont know ab...
 
dbs class 7.ppt
dbs class 7.pptdbs class 7.ppt
dbs class 7.ppt
 
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
MySQL 8 -- A new beginning : Sunshine PHP/PHP UK (updated)
 
8. sql
8. sql8. sql
8. sql
 
Sql 2006
Sql 2006Sql 2006
Sql 2006
 
Erik_van_Roon.pdf
Erik_van_Roon.pdfErik_van_Roon.pdf
Erik_van_Roon.pdf
 
SQL
SQLSQL
SQL
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorial
 
SQL Notes
SQL NotesSQL Notes
SQL Notes
 
DBMS Chapter-3.ppsx
DBMS Chapter-3.ppsxDBMS Chapter-3.ppsx
DBMS Chapter-3.ppsx
 
AWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDB
AWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDBAWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDB
AWS December 2015 Webinar Series - Design Patterns using Amazon DynamoDB
 
IR SQLite Session #1
IR SQLite Session #1IR SQLite Session #1
IR SQLite Session #1
 
about-SQL AND ETC.pptx
about-SQL AND ETC.pptxabout-SQL AND ETC.pptx
about-SQL AND ETC.pptx
 
MariaDB Server 10.3 - Temporale Daten und neues zur DB-Kompatibilität
MariaDB Server 10.3 - Temporale Daten und neues zur DB-KompatibilitätMariaDB Server 10.3 - Temporale Daten und neues zur DB-Kompatibilität
MariaDB Server 10.3 - Temporale Daten und neues zur DB-Kompatibilität
 
Triggers n Cursors.ppt
Triggers n Cursors.pptTriggers n Cursors.ppt
Triggers n Cursors.ppt
 

More from Hany Paulina

PELATIHAN SYSTEM zSERIES
PELATIHAN SYSTEM zSERIESPELATIHAN SYSTEM zSERIES
PELATIHAN SYSTEM zSERIES
Hany Paulina
 
Pelatihan AS/400
Pelatihan AS/400Pelatihan AS/400
Pelatihan AS/400
Hany Paulina
 
Register Now
Register NowRegister Now
Register Now
Hany Paulina
 
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (13-17...
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (13-17...Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (13-17...
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (13-17...
Hany Paulina
 
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (24-28...
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (24-28...Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (24-28...
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (24-28...
Hany Paulina
 
Ikuti Public Training Structure,Tailoring & Performance Analysis (03-06 Septe...
Ikuti Public Training Structure,Tailoring & Performance Analysis (03-06 Septe...Ikuti Public Training Structure,Tailoring & Performance Analysis (03-06 Septe...
Ikuti Public Training Structure,Tailoring & Performance Analysis (03-06 Septe...
Hany Paulina
 
Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...
Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...
Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...
Hany Paulina
 
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (17-21...
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (17-21...Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (17-21...
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (17-21...
Hany Paulina
 
Ikuti Public Training AS/400 Managing Jobs,Database & Security (03-07 Septemb...
Ikuti Public Training AS/400 Managing Jobs,Database & Security (03-07 Septemb...Ikuti Public Training AS/400 Managing Jobs,Database & Security (03-07 Septemb...
Ikuti Public Training AS/400 Managing Jobs,Database & Security (03-07 Septemb...
Hany Paulina
 
Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...
Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...
Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...
Hany Paulina
 
Ikuti Public Training AS/400 Control Language Programming (26-29 Maret 2018)
Ikuti Public Training AS/400 Control Language Programming (26-29 Maret 2018)Ikuti Public Training AS/400 Control Language Programming (26-29 Maret 2018)
Ikuti Public Training AS/400 Control Language Programming (26-29 Maret 2018)
Hany Paulina
 
Ikuti Public Training AS/400 System Administration & Control (12-16 Maret 2018)
Ikuti Public Training AS/400 System Administration & Control (12-16 Maret 2018)Ikuti Public Training AS/400 System Administration & Control (12-16 Maret 2018)
Ikuti Public Training AS/400 System Administration & Control (12-16 Maret 2018)
Hany Paulina
 
Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)
Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)
Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)
Hany Paulina
 
Ingin Belajar System AS/400, Security, Back Up Recovery & Problem Determintat...
Ingin Belajar System AS/400, Security, Back Up Recovery & Problem Determintat...Ingin Belajar System AS/400, Security, Back Up Recovery & Problem Determintat...
Ingin Belajar System AS/400, Security, Back Up Recovery & Problem Determintat...
Hany Paulina
 
Ikuti Public Training AS/400 System Administration & Control (29 Januari - 02...
Ikuti Public Training AS/400 System Administration & Control (29 Januari - 02...Ikuti Public Training AS/400 System Administration & Control (29 Januari - 02...
Ikuti Public Training AS/400 System Administration & Control (29 Januari - 02...
Hany Paulina
 
Public Training AS/400 Structure, Tailoring & Performance Analysis (22-25 Jan...
Public Training AS/400 Structure, Tailoring & Performance Analysis (22-25 Jan...Public Training AS/400 Structure, Tailoring & Performance Analysis (22-25 Jan...
Public Training AS/400 Structure, Tailoring & Performance Analysis (22-25 Jan...
Hany Paulina
 
Public Training AS/400 System Administration & Control (06-10 November 2017)
Public Training AS/400 System Administration & Control (06-10 November 2017)Public Training AS/400 System Administration & Control (06-10 November 2017)
Public Training AS/400 System Administration & Control (06-10 November 2017)
Hany Paulina
 
Public Training AS/400 Structure,Tailoring & Performance Analysis (23-26 Okto...
Public Training AS/400 Structure,Tailoring & Performance Analysis (23-26 Okto...Public Training AS/400 Structure,Tailoring & Performance Analysis (23-26 Okto...
Public Training AS/400 Structure,Tailoring & Performance Analysis (23-26 Okto...
Hany Paulina
 
Ingin Belajar AS/400 System Tuning & Performance Tips & Techniques
Ingin Belajar AS/400 System Tuning & Performance Tips & TechniquesIngin Belajar AS/400 System Tuning & Performance Tips & Techniques
Ingin Belajar AS/400 System Tuning & Performance Tips & Techniques
Hany Paulina
 
Program Oktober Ceria untuk Public Training AS/400 Programming
Program Oktober Ceria untuk Public Training  AS/400 Programming Program Oktober Ceria untuk Public Training  AS/400 Programming
Program Oktober Ceria untuk Public Training AS/400 Programming
Hany Paulina
 

More from Hany Paulina (20)

PELATIHAN SYSTEM zSERIES
PELATIHAN SYSTEM zSERIESPELATIHAN SYSTEM zSERIES
PELATIHAN SYSTEM zSERIES
 
Pelatihan AS/400
Pelatihan AS/400Pelatihan AS/400
Pelatihan AS/400
 
Register Now
Register NowRegister Now
Register Now
 
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (13-17...
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (13-17...Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (13-17...
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (13-17...
 
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (24-28...
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (24-28...Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (24-28...
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (24-28...
 
Ikuti Public Training Structure,Tailoring & Performance Analysis (03-06 Septe...
Ikuti Public Training Structure,Tailoring & Performance Analysis (03-06 Septe...Ikuti Public Training Structure,Tailoring & Performance Analysis (03-06 Septe...
Ikuti Public Training Structure,Tailoring & Performance Analysis (03-06 Septe...
 
Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...
Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...
Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...
 
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (17-21...
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (17-21...Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (17-21...
Ikuti Public Training AS/400 SQL Implementation & Embedded Programming (17-21...
 
Ikuti Public Training AS/400 Managing Jobs,Database & Security (03-07 Septemb...
Ikuti Public Training AS/400 Managing Jobs,Database & Security (03-07 Septemb...Ikuti Public Training AS/400 Managing Jobs,Database & Security (03-07 Septemb...
Ikuti Public Training AS/400 Managing Jobs,Database & Security (03-07 Septemb...
 
Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...
Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...
Ikuti Public Training AS/400 System Administration & Control (27-31 Augustus ...
 
Ikuti Public Training AS/400 Control Language Programming (26-29 Maret 2018)
Ikuti Public Training AS/400 Control Language Programming (26-29 Maret 2018)Ikuti Public Training AS/400 Control Language Programming (26-29 Maret 2018)
Ikuti Public Training AS/400 Control Language Programming (26-29 Maret 2018)
 
Ikuti Public Training AS/400 System Administration & Control (12-16 Maret 2018)
Ikuti Public Training AS/400 System Administration & Control (12-16 Maret 2018)Ikuti Public Training AS/400 System Administration & Control (12-16 Maret 2018)
Ikuti Public Training AS/400 System Administration & Control (12-16 Maret 2018)
 
Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)
Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)
Ikuti Public Training AS/400 Query for Data Processing (19-21 Februari 2018)
 
Ingin Belajar System AS/400, Security, Back Up Recovery & Problem Determintat...
Ingin Belajar System AS/400, Security, Back Up Recovery & Problem Determintat...Ingin Belajar System AS/400, Security, Back Up Recovery & Problem Determintat...
Ingin Belajar System AS/400, Security, Back Up Recovery & Problem Determintat...
 
Ikuti Public Training AS/400 System Administration & Control (29 Januari - 02...
Ikuti Public Training AS/400 System Administration & Control (29 Januari - 02...Ikuti Public Training AS/400 System Administration & Control (29 Januari - 02...
Ikuti Public Training AS/400 System Administration & Control (29 Januari - 02...
 
Public Training AS/400 Structure, Tailoring & Performance Analysis (22-25 Jan...
Public Training AS/400 Structure, Tailoring & Performance Analysis (22-25 Jan...Public Training AS/400 Structure, Tailoring & Performance Analysis (22-25 Jan...
Public Training AS/400 Structure, Tailoring & Performance Analysis (22-25 Jan...
 
Public Training AS/400 System Administration & Control (06-10 November 2017)
Public Training AS/400 System Administration & Control (06-10 November 2017)Public Training AS/400 System Administration & Control (06-10 November 2017)
Public Training AS/400 System Administration & Control (06-10 November 2017)
 
Public Training AS/400 Structure,Tailoring & Performance Analysis (23-26 Okto...
Public Training AS/400 Structure,Tailoring & Performance Analysis (23-26 Okto...Public Training AS/400 Structure,Tailoring & Performance Analysis (23-26 Okto...
Public Training AS/400 Structure,Tailoring & Performance Analysis (23-26 Okto...
 
Ingin Belajar AS/400 System Tuning & Performance Tips & Techniques
Ingin Belajar AS/400 System Tuning & Performance Tips & TechniquesIngin Belajar AS/400 System Tuning & Performance Tips & Techniques
Ingin Belajar AS/400 System Tuning & Performance Tips & Techniques
 
Program Oktober Ceria untuk Public Training AS/400 Programming
Program Oktober Ceria untuk Public Training  AS/400 Programming Program Oktober Ceria untuk Public Training  AS/400 Programming
Program Oktober Ceria untuk Public Training AS/400 Programming
 

Recently uploaded

Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 

Recently uploaded (20)

Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 

Public Training SQL Implementation & Embedded Programming in IBM i

  • 1.
  • 2. • An alternative database interface language • NOT a database management system • High level, simple statement formats • A language used for: • Data Definition (DDL) • Data Manipulation (DML) • Completely interchangeable data methods • SQL tables may be accessed with native language • DDS created files can be access with SQL
  • 3. • Great for selecting and manipulating groups of data • If you want to update/delete all the records in a file matching a certain criteria, use SQL. SQL can change or delete a group of records in a single statement, whereas native I/O would require you to loop through a file and issue individual update or delete statements. • Columnar functions allow for column/field manipulation during the record selection phase • SQL has many columnar functions designed to tally, total, summarize, manipulate, and calculate columns of data. Many program features such as substringing, averaging, and math functions can be performed during the record selection phase. Columns can even be returned that don't exist in the file, such as counts, calculations, literals, and dates. • Aggregate data • if you wanted to find a list of all the different zip codes in a mailing address file and count how many addresses were in each zip code, SQL can easily accomplish this in a single statement. In native I/O you would have to loop through a file and increment counter fields or use arrays and/or multiple-occurrence data structures to aggregate like data.
  • 4. • Interactive SQL STRSQL Quick ad-hoc queries • Embedded SQL Alternative to native file I/O Allows for SQL functionality in RPG or COBOL
  • 5. • STRSQL (Green Screen) • System i Navigator • Most Common SQL Statements The SELECT statement is used to select data from a database. The result is stored in a result table, called the result-set. The UPDATE statement is used to update existing records in a table. The DELETE statement is used to delete rows in a table.
  • 6. • SELECT * FROM EMPLOYEE • SELECT EMPNO, LASTNAME, BIRTHDATE, SALARY FROM EMPLOYEE WHERE SALARY > 30000 • SELECT LASTNAME, SALARY, BONUS, COM FROM EMPLOYEE WHERE SALARY > 22000 AND BONUS = 400 OR BONUS = 500 AND COM < 1900 ORDER BY LASTNAME
  • 7.
  • 8.
  • 9.
  • 10. • UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value • Be careful when updating records !!! If you omit the WHERE, all records get updated • Example: UPDATE EMPLOYEE SET SALARY = SALARY + 1000 WHERE WORKDEPT = 'C01'
  • 11. • DELETE FROM table_name WHERE some_column=some_value • BE CAREFUL WHEN DELETING RECORDS! Like the UPDATE statement, if you omit the WHERE clause, all records get deleted. BACK IT UP! • Example: DELETE FROM TESTEMP WHERE EMPNO = '000111'
  • 12. • Static SQL The simplest form of embedding SQL in RPG or COBOL The SQL statement is hard coded in your program • Dynamic SQL The SQL statement is assembled at run-time Requires more resource at run-time for preparing the statement Makes an application very dynamic Can become very sophisticated
  • 13. • Most variables defined in RPG or COBOL can be used in a SQL statement • Variables are preceded by a colon, ( : ). • Example: To use RPG or COBOL’s variable field name ITMNBR in SQL use it as :ITMNBR
  • 14. COST OF ON HAND INVENTORY ITEM# DESCRIPTION COST QTY OH COST OH 20001 Telephone, one line 15.00 10 150.00 20002 Telephone, two line 89.00 5 445.00 20003 Speaker Telephone 85.00 6 510.00 20004 Telephone Extension Cord 1.10 25 27.50 20005 Dry Erase Marker Packs 2.25 428 963.00 20006 Executive Chairs 325.00 10 3,250.00 20007 Secretarial Chairs 55.00 13 715.00 20008 Desk Calendar Pads 5.00 56 280.00 20009 Diskette Mailers .20 128 25.60 20010 Address Books 6.00 1,680 10,080.00 20011 Desk lamp, brass 20.00 3 60.00 20012 Blue pens 20.00 7 140.00 20013 Red pens 100.00 14 1,400.00 20014 Black pens 150.00 25 3,750.00 20015 Number 2 pencils 2.50 150 375.00 20016 Number 3 pencils 4.50 25 112.50 20017 Two Drawer File Cabinets 5.50 15 82.50 20018 Manilla folders 4.00 50 200.00 20019 Hanging file folders 3.00 150 450.00 20020 Metal desk 125.00 2 250.00 ::::: :::::::::::::::::::: :::: ::::: :::::: 20045 Blue paper, 8 1/2 X 11 2.95 75 221.25 20046 Continuous 8,5 X 11 paper 20.00 24 480.00 20047 Yellow paper, 8 1/2 X 11 2.95 199 587.05 20048 3 hole white paper 3.35 35 117.25 20049 3 hole lined paper 3.85 10 38.50 20050 Heavy duty stapler 9.15 5 45.75 TOTAL COST OF INVENTORY ON HAND: 51,755.90
  • 15. • Step 1 – calculate average Item cost • Read all item records and calculate the ITMCOST average • Put the average result in AVGCOST • Step 2 – Select Item cost > Average cost • Re-Read all item records again and compare the ITMCOST to AVGCOST • If the ITMCOST > AVGCOST calculate the amount of ITMCOST * ITMQTYOH to ITMCOSTOH and print the record, if NOT read next records • Print a total of ITMCOSTOH after all records have been read.
  • 16. • select avg(itmcost) from item_pf
  • 17.
  • 18.
  • 19. 0001.00 010313 0002.00 FItpCost2 O E Printer OflInd(PrtOver) 150612 0003.00 Drecend s n 150614 0004.00 DITEMDS E DS EXTNAME(ITEM_PF:ITEM_FMT) 091212 0005.00 Drata s 5 2 150612 0006.00 020125 0007.00 /Free 020125 0008.00 150614 0009.00 Write Heading; 020125 0010.00 010313 0011.00 EXEC SQL select avg(itmcost) into :rata from item_pf; 150614 0012.00 150614 0013.00 EXEC SQL DECLARE C1 CURSOR FOR SELECT itmnbr, 150614 0014.00 itmdescr, itmcost, itmqtyoh, itmcost * itmqtyoh as 150614 0015.00 OnHand from item_pf where itmcost > :rata; 150614 0016.00 150614 0017.00 EXEC SQL OPEN C1; 091212 0018.00 150614 0019.00 EXEC SQL FETCH C1 INTO :itmnbr, :itmdescr, :itmcost, :itmqtyoh, 150614 0020.00 :itmcostoh; 150614 0021.00 150612 0022.00 DoW not recend; 150327 0023.00 If PrtOver; // Check for overflow 020128 0024.00 Write Heading; 020125 0025.00 PrtOver = *Off; 020125 0026.00 Endif; 020125 0027.00 010313 0028.00 Write Detail; // Print detail record format 150614 0029.00 150612 0030.00 EXEC SQL FETCH C1 INTO :itmnbr, :itmdescr, :itmcost, :itmqtyoh, 150614 0031.00 :itmcostoh; 150614 0032.00 // *** Check whether no more recors to be processed 150614 0033.00 150327 0034.00 recend = (SQLCODE <> 0); 150614 0035.00 150327 0036.00 Enddo; 150614 0037.00 150612 0038.00 EXEC SQL select sum(itmcost * itmqtyoh) into :totcostoh from item_pf 150614 0039.00 where itmcost > :rata; 150614 0040.00 150614 0041.00 EXEC SQL CLOSE C1; 091212 0042.00 Write Total; // Print total record format 030731 0043.00 *InLR = *On; 020125 0044.00 /End-free 020125