HP c-tree-SQL ISQL and Tools manual Manage, Rollback Work

Page 25

Quick Tour

2.4.3Manage

This step provides data management functionality for the applica- tion. In this example we will add records to the itemmast and cust- mast tables, intended as static data. Then, sales orders will be processed as a transaction and "commited" or "rolled back" depending on the validity of the data. The final step will be to dis- play the result of the transaction processing by dumping the con- tents of the orderlist and orderitems tables.

INSERT INTO - This will add a record by inserting it into the table

SELECT - Fetch records according to select criteria

DELETE FROM - Delete records from a table.

COMMIT WORK - Make changes permanent.

The following excerpt from iSQL_Tutorial4 shows the SQL syntax that would be used to implement the entry of an order and related items as a transaction. The items and the order are inserted, then a select statement is used to verify the existence of the item and customer num- ber. iSQL is a tool that requires the user to interact. This script automatically implements the appropriate commit or rollback statement based on the results of the verification.

INSERT INTO orderitems VALUES ('1', 1, 2, '1');

INSERT INTO orderitems VALUES ('1', 2, 1, '2');

INSERT INTO orderlist VALUES ('9/1/2002', '9/5/2002', '1', '1001');

SELECT orderitems.oi_itemnum, itemmast.im_itemnum

FROM orderitems, itemmast

WHERE orderitems.oi_itemnum = itemmast.im_itemnum;

SELECT orderlist.ol_custnum, custmast.cm_custnum

FROM orderlist, custmast

WHERE orderlist.ol_custnum = custmast.cm_custnum;

COMMIT WORK;

INSERT INTO orderitems VALUES ('2', 1, 1, '3');

INSERT INTO orderitems VALUES ('2', 2, 3, '4');

INSERT INTO orderlist VALUES ('9/2/2002', '9/6/2002', '2', '9999');

SELECT orderitems.oi_itemnum, itemmast.im_itemnum

FROM orderitems, itemmast

WHERE orderitems.oi_itemnum = itemmast.im_itemnum;

SELECT orderlist.ol_custnum, custmast.cm_custnum

FROM orderlist, custmast

WHERE orderlist.ol_custnum = custmast.cm_custnum;

ROLLBACK WORK;

INSERT INTO orderitems VALUES ('3', 1, 2, '3'); INSERT INTO orderitems VALUES ('3', 2, 3, '99');

INSERT INTO orderlist VALUES ('9/22/2002', '9/26/2002', '3', '1002'); SELECT orderitems.oi_itemnum, itemmast.im_itemnum

FROM orderitems, itemmast

WHERE orderitems.oi_itemnum = itemmast.im_itemnum;

FairCom Corporation

2-15

Image 25
Contents For use with c-treeSQL Server Isql and Tools Reference GuidePage Table of Contents Data Load Utility dbload Iii Tutorial Source CodeFairCom Corporation Documentation Overview Syntax Diagram ConventionsPurpose of this Manual AudienceIsql and Tools Related DocumentationOverview IntroductionIsql and Tools FairCom Corporation Introductory Tutorial Quick TourInit IsqlManage DefineIsql Create Table Custmast Isql Commit Work CustmastComplete Introductory Tutorial Code DoneQuick Tour ISQLTutorial2.sql Relational Model and Indexing TutorialQuick Tour Values Insert Into Insert IntoValues QTY Price Commit WorkComplete Relational Model and Indexing Tutorial Source Code ISQLTutorial3.sql Locking Tutorial@ISQL @iSQLTutorial3.sql Isql Delete from Custmast Complete Locking Tutorial Source Code ISQLTutorial4.sql Transaction Processing TutorialTransaction Rollback Work Complete Transaction Processing Tutorial Source Code Starting Interactive SQL Isql StatementsSyntax ArgumentsStatement History Support PasswordUsername ConnectstringIsql Statements Formatting Output of Isql QueriesIsql Statements for Statement History Support Statement SummaryDisplay Isql Statements for Query Formatting SummaryCustomername Customercity Orderid Ordervalue Example 3-1 Unformatted Query Display from IsqlExample 3-2 Controlling Display Width of Character Columns Formatting Column Display with the Column StatementOrdervalue Example 3-3 Customizing Format of Numeric Column DisplaysCustomername Customercity Example 3-4 Specifying Column Breaks and Values with Display Numorders Customername Example 3-6 Specifying a Query Header and Footer with Title Transaction Support Help and Table Statements1 @ Execute Syntax Isql ReferenceDescription ExampleBreakspec Break SyntaxSkip n ExamplesCustomername History Clear SyntaxColumn Syntax ArgumentOption Break Column Compute Display TitleFormat formatstring ColumnnameHeading headingtext Character Description Date-Time Format Strings for the Column StatementNot Null INT Null ? Type Length ColnameChar Amount OrderinfoSysdate Column Title FLDNEW Title ComputeVariablename AVG MAX MIN SUM CountValue Define SyntaxDisplayvalue ColpositionCOL columnnumber @columnnameEdit Syntax Related Statements Exit or Quit SyntaxExit Isql GET query.sql 10 GET SyntaxIsql RUN Help Syntax Help CommandsclausesHistory Syntax Orderstate LotlocationFollowing example illustrates usage of the History statement Host or SH or Syntax HostcommandFrom List Syntax 16 RUN Syntax Quit or Exit SyntaxQuit Isql History18 SET Syntax Save SyntaxPagesize LinesizePagesize numberlines Transaction Isolation Level isolationlevel Connection databasename DefaultIsql Break on Isql Select TBL from Systables TBL TBLShow Syntax Spool Syntax Is Default ?Filename on Database ConnectionsArgument … Start SyntaxIsql Spool STK on Isql Spool OFFNot Null Varchar Null ? Type Length Colname Not Null INTType Length Colname Null ? TablenameDate Left Center Right COL n Title SyntaxText DoubleIsql Clear Title Isql and Tools FairCom Corporation Introduction Data Load Utility dbloadCommandsfile Dbload Command Line SyntaxPrerequisites for Dbload OptionsData Load Utility dbload Data File FormatsVariable Length Records Commands FileFixed Length Records Next RecordChar Short Long Float Double Define Record StatementNull For Each StatementExamples Example 4-1 Sample dbload commands filesRecord name redefined Compilation ErrorsPosition not specified for fixed length record Fatal Errors Isql and Tools FairCom Corporation Prerequisites for Dbdump Data Unload Utility dbdumpDbdump Command Line Syntax Short Long Float Double Data Unload Utility dbdumpFor Record Statement Define Record custrec of Fixed Length 37 AS Isql and Tools FairCom Corporation Schema Export Utility dbschema Outfile Username.procedurenameUsername.tablename Username.triggernameDbschema Schema Export Utility dbschemaImport Begin ENDIsql and Tools FairCom Corporation Commit Work Select * from Custmast Delete from Custmast Tutorial Source CodeMoney IntegerVARCHAR6 Commit Work Delete from Custmast Tutorial Source CodeImdesc VARCHAR48 Select * from orderlist Select * from orderitems Isql and Tools FairCom Corporation Index-i SymbolsIndex-ii FairCom Corporation IsqlIndex-iii FairCom Corporation Index