Open Query File
description
Transcript of Open Query File
![Page 1: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/1.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
by Tim JannsenASNA
© Copyright 2007 by ASNA. All rights reserved.
Open Query FileOpen Query File
Dynamically creating logical views.
1
![Page 2: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/2.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
OPNQRYF Heritage
•DclDiskfile at design time:
•File name Properties at runtime:
![Page 3: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/3.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Implementation Differs With Engine
• DataGate Windows– Simple Query
• Implements Select/Omit
• DB2/400– OPNQRYF
• Implements QRYSLT & KEYFLD parameters
• SQL Server– SQL
• Implements SELECT WHERE
![Page 4: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/4.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Basics
• File created in QTEMP – QTEMP in SQL Server introduced: DG-SQL 8.1.433
• Give File any name you wish‡
• *NAME uses DclDiskFile Name keyword value ‡
• *UNIQUE creates a unique name‡ Avoids risk of duplicate file names
• Sequential Access is Intended • Random Access Allowed (some restrictions apply)
![Page 5: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/5.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
QRYSELECT for DataGate Windows
• Select/Omit Rule• Relational Operators:
• Use either ' or " for literal token• Field to Field comparison allowed• No built in functions
> GT Greater than
>= GE Greater than or equal
< LT Less than
<= LE Less than or equal
= EQ Equal
!= <> NE Not equal
& AND
| OR
![Page 6: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/6.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
DataGate Windows Examples
![Page 7: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/7.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
QRYSELECT for DB2/400
• Whatever is valid in QRYSLT • Relational Operators:
• Use either ' or " for literal token• Field to Field comparison allowed• Lots of built in functions
> *GT Greater than >= *GE Greater than or equal
< *LT Less than <= *LE Less than or equal
= *EQ Equal ¬= *NE Not equal
¬> *NG Not greater than ¬< *NL Not less than
& *AND And | *OR Or
&& *XOR Exclusive OR *CT Contains
|| *CAT Concatenate *NOT Not
![Page 8: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/8.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
DB2/400 Examples
![Page 9: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/9.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
QRYSELECT for SQL Server
• Whatever is valid following Select From WHERE • Relational Operators:
• Use only ' for literal token• Field to Field comparison allowed• Lots of built in functions• Wildcards allowed
> Greater than >= Greater than or equal
< Less than <= Less than or equal
= Equal <> != Not equal
!> Not greater than !< Not less than
AND And OR Or
+ Concatenate NOT
![Page 10: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/10.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
SQL Server Examples
![Page 11: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/11.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
QRYKEYFLDS
• Specifies presentation sequence of records – ORG( *indexed and *Arrival )
• Target File can be Logical or Physical• Syntax
– Field name– Ascending or Descending– Absolute value (numeric fields only)
![Page 12: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/12.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
When Things Go Wrong – DG Windows
![Page 13: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/13.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Copy and Paste QRYSelect
![Page 14: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/14.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Need A Little Help? Use Default Select Tab
Notice the Drop
Downs
![Page 15: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/15.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
When Things Go Wrong – DB2/400
What's wrong with this?
![Page 16: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/16.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Check the Job Log for DataGate JobWRKACTJOB
![Page 17: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/17.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
When Things Go Wrong – SQL Server
What's wrong with this?
![Page 18: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/18.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Use SQL Server Management Studio
![Page 19: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/19.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Use SQL Server Management Studio
![Page 20: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/20.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Random or Sequential Processing?
• Open Query intended to be sequential • Random Access commands:
– CHAIN; SETLL; SETGT; nnnRANGE
• Random is OK – If QRYKeyFlds matches compiled file's key parts– If you say so (see Random keyword)
• dclDiskFile's Random Keyword– Tells Compiler of your intention
• *NO raises compiler error if you use random commands
![Page 21: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/21.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Single Source?
• Syntax and punctuation differences can be normalized in code– e.g., use <> instead of *NE
• How do you do know to which engine application is connected at runtime?
![Page 22: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/22.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Database Class Members
![Page 23: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/23.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Database Properties
![Page 24: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/24.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Distinguishing DB Object Properties
• Server Host Name or IP address
of DB server
• Port IP Port for DB service
• Label Identifies DB Instance
• PlatformAttribute Identifies server linkage
• PoolingTimout 0 = No pooling 1-255 = Pool Idle
TimeOut• User
User ID or *DOMAIN• Password
User password if not *DOMAIN
![Page 25: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/25.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Use Server Property?
• IP Address– 10.1.3.25
• Host Name– "S1055523"– "NetServ3500\MySQLServerName"
• Not cast in bronze• *LOCAL
– My Computer for DG Windows instances– My Computer for Default SQL Server instance
![Page 26: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/26.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Use Port Property?
• 0 or 5042– *LOCAL
• 5042– Required for Remote DG SQL Server– Default for DG iSeries
• nnnn– Multiple DG iSeries versions
![Page 27: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/27.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Use PlatformAttribute Property?
• *DATALINK– Native DataGate protocol
• DG iSeries• DG Windows
• *SQLOLEDB– SQL Server 2000 & 2005
![Page 28: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/28.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Use Label Property?
• Identifies DG Windows DG location• Not meaningful for DG iSeries or DG SQL
Server• PlatformAttribute Property distinguishes
iSeries from SQL Server• So, use meaningful Label to identify iSeries
– e.g., "AS400", "iSERIES", "SYSTEM i"
![Page 29: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/29.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Mix in ADO for Embedded SQL
![Page 30: Open Query File](https://reader035.fdocuments.in/reader035/viewer/2022081514/56814fc9550346895dbd875a/html5/thumbnails/30.jpg)
ASN
Apalo
oza
20
07
ASN
Apalo
oza
20
07
© Copyright 2007 by ASNA. All rights reserved.
Open Query FileOpen Query File
30