ibm-information-center/dist/eclipse/plugins/i5OS.ic.ddp_5.4.0.1/rbal1excreatecollection.htm

216 lines
12 KiB
HTML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Example: Program definitions" />
<meta name="DC.subject" content="example, programming, database setup" />
<meta name="keywords" content="example, programming, database setup" />
<meta name="DC.Relation" scheme="URI" content="rbal1progxmp.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rbal1excreatecollection" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Example: Program definitions</title>
</head>
<body id="rbal1excreatecollection"><a name="rbal1excreatecollection"><!-- --></a>
<img src="./delta.gif" alt="Start of change" /><!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Example: Program definitions</h1>
<div><div class="section"> <div class="note"><span class="notetitle">Note:</span> By using the code examples, you agree to the terms of the <a href="codedisclaimer.htm">Code license and disclaimer information</a>.</div>
</div>
<div class="example"> <div class="fignone" id="rbal1excreatecollection__rbal1crtdbx"><a name="rbal1excreatecollection__rbal1crtdbx"><!-- --></a><span class="figcap">Figure 1. Create a collection and tables</span><pre>/******************************************************************************/
/* Local Database */
/******************************************************************************/
CREATE COLLECTION DRDA
CREATE TABLE DRDA/PART_STOCK (PART_NUM CHAR(5) NOT NULL,
PART_UM CHAR(2) NOT NULL,
PART_QUANT INTEGER NOT NULL WITH DEFAULT,
PART_ROP INTEGER NOT NULL,
PART_EOQ INTEGER NOT NULL,
PART_BIN CHAR(6) NOT NULL WITH DEFAULT
)
CREATE UNIQUE INDEX DRDA/PART_STOCI ON DRDA/PART_STOCK (PART_NUM ASC)
/******************************************************************************/
/* Remote Database */
/******************************************************************************/
CREATE COLLECTION DRDA
CREATE TABLE DRDA/PART_ORDER (ORDER_NUM SMALLINT NOT NULL,
ORIGIN_LOC CHAR(4) NOT NULL,
ORDER_TYPE CHAR(1) NOT NULL,
ORDER_STAT CHAR(1) NOT NULL,
NUM_ALLOC SMALLINT NOT NULL WITH DEFAULT,
URG_REASON CHAR(1) NOT NULL WITH DEFAULT,
CREAT_TIME TIMESTAMP NOT NULL,
ALLOC_TIME TIMESTAMP,
CLOSE_TIME TIMESTAMP,
REV_REASON CHAR(1)
)
CREATE UNIQUE INDEX DRDA/PART_ORDEI ON DRDA/PART_ORDER (ORDER_NUM ASC)
CREATE TABLE DRDA/PART_ORDLN (ORDER_NUM SMALLINT NOT NULL,
ORDER_LINE SMALLINT NOT NULL,
PART_NUM CHAR(5) NOT NULL,
QUANT_REQ INTEGER NOT NULL,
LINE_STAT CHAR(1) NOT NULL
)
CREATE UNIQUE INDEX PART_ORDLI ON DRDA/PART_ORDLN (ORDER_NUM ASC,
ORDER_LINE ASC)
CREATE TABLE DRDA/SHIPMENTLN (SHIP_NUM SMALLINT NOT NULL,
SHIP_LINE SMALLINT NOT NULL,
ORDER_LOC CHAR(4) NOT NULL,
ORDER_NUM SMALLINT NOT NULL,
ORDER_LINE SMALLINT NOT NULL,
PART_NUM CHAR(5) NOT NULL,
QUANT_SHIP INTEGER NOT NULL,
QUANT_RECV INTEGER NOT NULL WITH DEFAULT
)
CREATE UNIQUE INDEX SHIPMENTLI ON DRDA/SHIPMENTLN (SHIP_NUM ASC,
SHIP_LINE ASC) </pre>
</div>
</div>
<div class="example"> <div class="fignone" id="rbal1excreatecollection__rbal1insdb"><a name="rbal1excreatecollection__rbal1insdb"><!-- --></a><span class="figcap">Figure 2. Insert data into the tables</span><pre>/******************************************************************************/
/* Local Database */
/******************************************************************************/
/******************************************************************************/
/* PART_STOCK */
/******************************************************************************/
INSERT INTO DRDA/PART_STOCK VALUES('14020','EA',038,050,100,' ')
INSERT INTO DRDA/PART_STOCK VALUES('14030','EA',043,050,050,' ')
INSERT INTO DRDA/PART_STOCK VALUES('14040','EA',030,020,030,' ')
INSERT INTO DRDA/PART_STOCK VALUES('14050','EA',010,005,015,' ')
INSERT INTO DRDA/PART_STOCK VALUES('14060','EA',110,045,090,' ')
INSERT INTO DRDA/PART_STOCK VALUES('14070','EA',130,080,160,' ')
INSERT INTO DRDA/PART_STOCK VALUES('18020','EA',013,025,050,' ')
INSERT INTO DRDA/PART_STOCK VALUES('18030','EA',015,005,010,' ')
INSERT INTO DRDA/PART_STOCK VALUES('21010','EA',029,030,050,' ')
INSERT INTO DRDA/PART_STOCK VALUES('24010','EA',025,020,040,' ')
INSERT INTO DRDA/PART_STOCK VALUES('24080','EA',054,050,050,' ')
INSERT INTO DRDA/PART_STOCK VALUES('24090','EA',030,025,050,' ')
INSERT INTO DRDA/PART_STOCK VALUES('24100','EA',020,015,030,' ')
INSERT INTO DRDA/PART_STOCK VALUES('24110','EA',052,050,080,' ')
INSERT INTO DRDA/PART_STOCK VALUES('25010','EA',511,300,600,' ')
INSERT INTO DRDA/PART_STOCK VALUES('36010','EA',013,005,010,' ')
INSERT INTO DRDA/PART_STOCK VALUES('36020','EA',110,030,060,' ')
INSERT INTO DRDA/PART_STOCK VALUES('37010','EA',415,100,200,' ')
INSERT INTO DRDA/PART_STOCK VALUES('37020','EA',010,020,040,' ')
INSERT INTO DRDA/PART_STOCK VALUES('37030','EA',154,055,060,' ')
INSERT INTO DRDA/PART_STOCK VALUES('37040','EA',223,120,120,' ')
INSERT INTO DRDA/PART_STOCK VALUES('43010','EA',110,020,040,' ')
INSERT INTO DRDA/PART_STOCK VALUES('43020','EA',067,050,050,' ')
INSERT INTO DRDA/PART_STOCK VALUES('48010','EA',032,030,060,' ')
/******************************************************************************/</pre>
</div>
<div class="fignone"><span class="figcap">Figure 3. Insert data into the tables (continued)</span><pre>/* Remote Database */
/******************************************************************************/
/******************************************************************************/
/* PART_ORDER TABLE */
/******************************************************************************/
INSERT INTO DRDA/PART_ORDER VALUES(1,'DB2B','U','O',0,' ','1991-03-12-17.00.00',
NULL,NULL,NULL)
INSERT INTO DRDA/PART_ORDER VALUES(2,'SQLA','U','O',0,' ','1991-03-12-17.01.00',
NULL,NULL,NULL)
INSERT INTO DRDA/PART_ORDER VALUES(3,'SQLA','U','O',0,' ','1991-03-12-17.02.00',
NULL,NULL,NULL)
INSERT INTO DRDA/PART_ORDER VALUES(4,'SQLA','U','O',0,' ','1991-03-12-17.03.00',
NULL,NULL,NULL)
INSERT INTO DRDA/PART_ORDER VALUES(5,'DB2B','U','O',0,' ','1991-03-12-17.04.00',
NULL,NULL,NULL)
/******************************************************************************/
/* PART_ORDLN TABLE */
/******************************************************************************/
INSERT INTO DRDA/PART_ORDLN VALUES(1,1,'24110',005,'O')
INSERT INTO DRDA/PART_ORDLN VALUES(1,2,'24100',021,'O')
INSERT INTO DRDA/PART_ORDLN VALUES(1,3,'24090',018,'O')
INSERT INTO DRDA/PART_ORDLN VALUES(2,1,'14070',004,'O')
INSERT INTO DRDA/PART_ORDLN VALUES(2,2,'37040',043,'O')
INSERT INTO DRDA/PART_ORDLN VALUES(2,3,'14030',015,'O')
INSERT INTO DRDA/PART_ORDLN VALUES(3,2,'14030',025,'O')
INSERT INTO DRDA/PART_ORDLN VALUES(3,1,'43010',003,'O')
INSERT INTO DRDA/PART_ORDLN VALUES(4,1,'36010',013,'O')
INSERT INTO DRDA/PART_ORDLN VALUES(5,1,'18030',005,'O')
/******************************************************************************/
/* SHIPMENTLN TABLE */
/******************************************************************************/
INSERT INTO DRDA/SHIPMENTLN VALUES(1,1,'DB2B',1,1,'24110',5,5)
INSERT INTO DRDA/SHIPMENTLN VALUES(1,2,'DB2B',1,2,'24100',10,1)
INSERT INTO DRDA/SHIPMENTLN VALUES(2,1,'SQLA',2,1,'14070',4,4)
INSERT INTO DRDA/SHIPMENTLN VALUES(2,2,'SQLA',2,2,'37040',45,25)
INSERT INTO DRDA/SHIPMENTLN VALUES(2,3,'SQLA',2,3,'14030', 5,5)
INSERT INTO DRDA/SHIPMENTLN VALUES(3,1,'SQLA',2,3,'14030', 5,5) </pre>
</div>
</div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbal1progxmp.htm" title="This example application for distributed relational database use is written in RPG/400, COBOL/400, Java and ILE C/400 programming languages. This example shows how to use a distributed relational database for functional specification tasks.">Examples: Application programming</a></div>
</div>
</div>
<img src="./deltaend.gif" alt="End of change" /></body>
</html>