HP c-tree-SQL ISQL and Tools manual For Each Statement, Null

Page 76

ISQL and Tools

start_position is the position where the field starts. It must be an unsigned integer.

end_position is the position where the field ends. It must be an unsigned integer. The first position of each record is 1 and not 0.

If date and time types are to be inserted they can be specified as characters in the data file. If it is a fixed length record then the type specification can be CHAR.

The following is an example of the DEFINE RECORD statement for fixed length records:

DEFINE RECORD rec_one OF FIXED LENGTH 20 AS (

fld1 POSITION (1:4) SHORT, fld2 POSITION (5:15) CHAR, fld3 POSITION (16:20) CHAR

) ;

4.5.2The FOR EACH Statement

The FOR EACH statement scans for each valid record in the data file and inserts the record into the database. The syntax for the FOR EACH statement is shown below:

FOR EACH RECORD record_name FROM data_file_name, ...

INSERT INTO owner_name.target_table [ (field_name, ...) ]

VALUES (value, ...) ;

NEXT RECORD

The following are the variable descriptions of the FOR EACH statement:

record_name is the record name that is specified in the DEFINE RECORD statement.

data_file_name is the name of the input data file name.

owner_name.target_table is the target table name identified along with the owner name of the table. The target_table must already exist in the database and must have appropriate permissions for inserting the records.

field_name is the name of the field or column in the table.

value is the value that must be inserted into the table.

The target_table can also be a synonym on another table with the INSERT access. The list of values that are to be inserted must follow the VALUES keyword. The values that can be inserted are:

Name of the field in the input data file

A constant (both numeric as well as character)

NULL

The values specified in the VALUES list must correspond one to one with that in the target table list. The list can be in any order compared to the list specified in the DEFINE RECORD

4-6

FairCom Corporation

Image 76
Contents Isql and Tools Reference Guide For use with c-treeSQL ServerPage Table of Contents Data Load Utility dbload Tutorial Source Code IiiFairCom Corporation Syntax Diagram Conventions Documentation OverviewPurpose of this Manual AudienceRelated Documentation Isql and ToolsIntroduction OverviewIsql and Tools FairCom Corporation Quick Tour Introductory TutorialInit IsqlDefine ManageIsql Create Table Custmast Isql Commit Work CustmastComplete Introductory Tutorial Code DoneQuick Tour Relational Model and Indexing Tutorial ISQLTutorial2.sqlQuick Tour Values Insert Into Insert IntoValues Commit Work QTY PriceComplete Relational Model and Indexing Tutorial Source Code Locking Tutorial ISQLTutorial3.sql@ISQL @iSQLTutorial3.sql Isql Delete from Custmast Complete Locking Tutorial Source Code Transaction Processing Tutorial ISQLTutorial4.sqlTransaction Rollback Work Complete Transaction Processing Tutorial Source Code Isql Statements Starting Interactive SQLSyntax ArgumentsPassword Statement History SupportUsername ConnectstringFormatting Output of Isql Queries Isql StatementsIsql Statements for Statement History Support Statement SummaryIsql Statements for Query Formatting Summary DisplayExample 3-1 Unformatted Query Display from Isql Customername Customercity Orderid OrdervalueFormatting Column Display with the Column Statement Example 3-2 Controlling Display Width of Character ColumnsOrdervalue 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 Help and Table Statements Transaction SupportIsql Reference 1 @ Execute SyntaxDescription ExampleBreak Syntax BreakspecSkip n ExamplesCustomername Clear Syntax HistoryArgument Column SyntaxOption Break Column Compute Display TitleFormat formatstring ColumnnameHeading headingtext Date-Time Format Strings for the Column Statement Character DescriptionNot Null INT Null ? Type Length ColnameChar Amount OrderinfoSysdate FLD Column TitleNEW Title ComputeAVG MAX MIN SUM Count VariablenameDefine Syntax ValueColposition DisplayvalueCOL columnnumber @columnnameEdit Syntax Related Statements Exit or Quit SyntaxExit 10 GET Syntax Isql GET query.sqlIsql RUN Help Commandsclauses Help SyntaxHistory Syntax Orderstate LotlocationFollowing example illustrates usage of the History statement Host or SH or Syntax HostcommandFrom List Syntax Quit or Exit Syntax 16 RUN SyntaxQuit Isql HistorySave Syntax 18 SET SyntaxPagesize LinesizePagesize numberlines Connection databasename Default Transaction Isolation Level isolationlevelIsql Break on Isql Select TBL from Systables TBL TBLShow Syntax Is Default ? Spool SyntaxFilename on Database ConnectionsStart Syntax Argument …Isql Spool STK on Isql Spool OFFNull ? Type Length Colname Not Null INT Not Null VarcharType Length Colname Null ? TablenameDate Title Syntax Left Center Right COL nText DoubleIsql Clear Title Isql and Tools FairCom Corporation Data Load Utility dbload IntroductionDbload Command Line Syntax CommandsfilePrerequisites for Dbload OptionsData File Formats Data Load Utility dbloadCommands File Variable Length RecordsFixed Length Records Next RecordDefine Record Statement Char Short Long Float DoubleFor Each Statement NullExample 4-1 Sample dbload commands files ExamplesRecord name redefined Compilation ErrorsPosition not specified for fixed length record Fatal Errors Isql and Tools FairCom Corporation Data Unload Utility dbdump Prerequisites for DbdumpDbdump Command Line Syntax Data Unload Utility dbdump Short Long Float DoubleFor Record Statement Define Record custrec of Fixed Length 37 AS Isql and Tools FairCom Corporation Schema Export Utility dbschema Username.procedurename OutfileUsername.tablename Username.triggernameSchema Export Utility dbschema DbschemaImport Begin ENDIsql and Tools FairCom Corporation Tutorial Source Code Commit Work Select * from Custmast Delete from CustmastMoney IntegerVARCHAR6 Tutorial Source Code Commit Work Delete from CustmastImdesc VARCHAR48 Select * from orderlist Select * from orderitems Isql and Tools FairCom Corporation Symbols Index-iIsql Index-ii FairCom CorporationIndex Index-iii FairCom Corporation