B6: Beginners Guide to OpenEdge® SQL via ODBC or JDBC

Slides:



Advertisements
Similar presentations
Using the SQL Access Advisor
Advertisements

Numbers Treasure Hunt Following each question, click on the answer. If correct, the next page will load with a graphic first – these can be used to check.
1 A B C
1 Senn, Information Technology, 3 rd Edition © 2004 Pearson Prentice Hall James A. Senns Information Technology, 3 rd Edition Chapter 7 Enterprise Databases.
AP STUDY SESSION 2.
Advanced SQL Topics Edward Wu.
1
Copyright © 2003 Pearson Education, Inc. Slide 7-1 Created by Cheryl M. Hughes The Web Wizards Guide to XML by Cheryl M. Hughes.
McGraw-Hill/Irwin Copyright © 2013 by The McGraw-Hill Companies, Inc. All rights reserved. Extended Learning Module D (Office 2007 Version) Decision Analysis.
1 Hyades Command Routing Message flow and data translation.
David Burdett May 11, 2004 Package Binding for WS CDL.
Microsoft Access 2007 Advanced Level. © Cheltenham Courseware Pty. Ltd. Slide No 2 Forms Customisation.
Local Customization Chapter 2. Local Customization 2-2 Objectives Customization Considerations Types of Data Elements Location for Locally Defined Data.
Create an Application Title 1Y - Youth Chapter 5.
Process a Customer Chapter 2. Process a Customer 2-2 Objectives Understand what defines a Customer Learn how to check for an existing Customer Learn how.
Custom Statutory Programs Chapter 3. Customary Statutory Programs and Titles 3-2 Objectives Add Local Statutory Programs Create Customer Application For.
Custom Services and Training Provider Details Chapter 4.
CALENDAR.
1 Chapter 12 File Management Patricia Roy Manatee Community College, Venice, FL ©2008, Prentice Hall Operating Systems: Internals and Design Principles,
Plan My Care Brokerage Training Working in partnership with Improvement and Efficiency South East.
Plan My Care Training Care Management Working in partnership with Improvement and Efficiency South East.
Plan My Care Training Care Management Working in partnership with Improvement and Efficiency South East.
1 Advanced Tools for Account Searches and Portfolios Dawn Gamache Cindy Bylander.
1 Click here to End Presentation Software: Installation and Updates Internet Download CD release NACIS Updates.
© Tally Solutions Pvt. Ltd. All Rights Reserved Shoper 9 License Management December 09.
Welcome. © 2008 ADP, Inc. 2 Overview A Look at the Web Site Question and Answer Session Agenda.
Break Time Remaining 10:00.
Turing Machines.
Table 12.1: Cash Flows to a Cash and Carry Trading Strategy.
13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.
Database Performance Tuning and Query Optimization
PP Test Review Sections 6-1 to 6-6
Employee & Manager Self Service Overview
Chapter 7 Working with Databases and MySQL
Briana B. Morrison Adapted from William Collins
9 Copyright © 2004, Oracle. All rights reserved. Using DDL Statements to Create and Manage Tables.
Introduction to Structured Query Language (SQL)
MySQL Access Privilege System
Displaying Data from Multiple Tables
EIS Bridge Tool and Staging Tables September 1, 2009 Instructor: Way Poteat Slide: 1.
Health Artifact and Image Management Solution (HAIMS)
Bellwork Do the following problem on a ½ sheet of paper and turn in.
Exarte Bezoek aan de Mediacampus Bachelor in de grafische en digitale media April 2014.
Sample Service Screenshots Enterprise Cloud Service 11.3.
Copyright © 2012, Elsevier Inc. All rights Reserved. 1 Chapter 7 Modeling Structure with Blocks.
Note: A bolded number or letter refers to an entire lesson or appendix. A Adding Data Through a View ADD_MONTHS Function 03-22, 03-23, 03-46,
Mobility Tool Fremtidens afrapportering 2013 – Erasmus Mobilitet / IP 2014 – Erasmus+ aktioner.
Adding Up In Chunks.
MaK_Full ahead loaded 1 Alarm Page Directory (F11)
1 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt 10 pt 15 pt 20 pt 25 pt 5 pt Synthetic.
GEtServices Services Training For Suppliers Requests/Proposals.
Before Between After.
: 3 00.
1 hi at no doifpi me be go we of at be do go hi if me no of pi we Inorder Traversal Inorder traversal. n Visit the left subtree. n Visit the node. n Visit.
Speak Up for Safety Dr. Susan Strauss Harassment & Bullying Consultant November 9, 2012.
Chapter 12 Working with Forms Principles of Web Design, 4 th Edition.
Converting a Fraction to %
Numerical Analysis 1 EE, NCKU Tien-Hao Chang (Darby Chang)
Clock will move after 1 minute
Chapter 11 Creating Framed Layouts Principles of Web Design, 4 th Edition.
Physics for Scientists & Engineers, 3rd Edition
Select a time to count down from the clock above
WaveMaker Visual AJAX Studio 4.0 Training
Copyright Tim Morris/St Stephen's School
South Dakota Library Network MetaLib User Interface South Dakota Library Network 1200 University, Unit 9672 Spearfish, SD © South Dakota.
Getting Started With Progress SQL-92
OPS-6: Beginners Guide to OpenEdge ® SQL via ODBC or JDBC Brian Werne Sr. Engineering Manager OpenEdge SQL and OpenEdge Management.
DB-1: OpenEdge ® SQL in a 10.1B multi- database environment for ODBC and JDBC Brian Werne Sr. Engineering Manager, OpenEdge SQL and OpenEdge Management.
Presentation transcript:

B6: Beginners Guide to OpenEdge® SQL via ODBC or JDBC Richard Banville Technical Fellow

Agenda: OpenEdge SQL OpenEdge database OpenEdge SQL specifics Goal: Make you successful with SQL applications! OpenEdge SQL Component overview Initial connection OpenEdge database Setup and maintenance Control and performance OpenEdge SQL specifics Tools Applications Familiar with ABL General theme- compare to ABL

Open Clients (Non-OpenEdge) OpenEdge is Open Crystal Reports WebSphere® JBOSS / JRun Java / JDBC apps J2EE™ / JTA .NET / ODBC apps ADO.NET / VB ABL: OpenEdge SQL (ABL works with relational DBs) Open Clients: Java™ .NET™ Web services (works with OpenEdge RDBMS) .NET Java HTML Open Clients (Non-OpenEdge) OpenEdge ABL Clients Service Interfaces ODBC Clients JDBC Clients OpenEdge DataServers SSL HTTP HTTP/S HTML OpenEdge ABL Server OpenEdge SQL Server What this is, what this is not “Other” RDBMS OpenEdge RDBMS Oracle® MSSQL ODBC Data is fully interoperable: ABL & SQL 3 3

Getting Connected – Client side: ODBC and JDBC drivers Provided in: SQL Client Access License RDBMS Licenses Progress Download Center for OpenEdge (SQL Client Access - free) ODBC Driver - wire protocol driver : 10.1a+ JDBC Driver - Type 4 (pure Java) : 10.1a+

CLASS.FORNAME com.ddtek.jdbc.openedge.OpenEdgeDriver JDBC: Pure Java Driver Type 4 JDBC driver (10.1a+) CLASSPATH ( run ‘sql_env’) Class loader (Loading the JDBC driver) URL for JDBC DriverManager.getConnection $DLC/java: openedge.jar, util.jar, base.jar CLASS.FORNAME com.ddtek.jdbc.openedge.OpenEdgeDriver Run sql_env sqlexp -db database-name -S port | service-name -H host -user userid –password password sqlexp –url jdbc:datadirect:openedge://host:port;databaseName=db_name; servicename=service_name -user userid -password password 1. It must load the JDBC driver. 2. It must connect to the JDBC driver. To load the JDBC driver, call the Class.forName method in the JDBC application. The Class.forName method takes the fully qualified class name of the JDBC driver as its argument. The fully qualified class name for the JDBC driver is com.ddtek.jdbc.openedge.OpenEdgeDriver. This class name is case-sensitive and must be typed exactly as shown. The Class.forName method also registers the specified JDBC driver with the Driver Manager class so that the driver is available for connections. Now that the JDBC driver has been loaded and registered, the DriverManager.getConnection method must be called to establish a connection to the database. The getConnection method takes three arguments: • A string containing a URL. The Driver Manager uses this URL to find a driver that can connect to the database represented by the given URL. Once the driver is found, the URL is used by the Driver class to establish the connection to the database. jdbc:datadirect:openedge://localhost:6748;databaseName=db1

ODBC DSN – single connection Unix- uses a .odbc.ini file - come see me after

ODBC: Multi-Database configuration (10.1B) msdbq:config1 specifies a property file JDBC has same ability, using same means Multiple Databases on same host sports2000.oesql.properties : in database location See PDSN presentation on MDBQ Unix- uses a .odbc.ini file - come see me after

ODBC DSN - Advanced Tab Isolations: defaults have changed between versions Fetch Array Size: Max # rows driver fetches from server “TimeStamp with Timezone” support – what happens when unchecked Suggest using READ COMMITTED – suggest always setting this explicitly - check your default ( varies by release) REPEATABLE_READ will give you closest behavior to ABL, but I think you want READ_COMMITTED or READ_UNCOMMITTED Unicode support - Wide Character changes which types are used in your describe phase Fetch Array Size is not the same as –Mm in ABL T w/TZ: determines native or varchar storage Wide char: varchar: SQL_WVARCHAR vs SQL_VARCHAR

Isolation Level Affect on Lock Type None Share Exclusive SIX Serializable IS IX Repeatable Read Read Committed NoLock --- Read Uncommitted Record Lock Table Lock Isolation Level Fetch Update Go through behavior of each isolation level Need to talk about dirty reads somewhere

Connection – server side

Default server setup SQL client Shared Memory SQL client DB ABL client SQL & ABL Broker ABL Servers Discuss advantages ABL client ABL client

“Recommended” server setup SQL Servers Shared Memory SQL only Broker SQL client DB SQL client ABL Servers Discuss advantages ABL client ABL client ABL only Broker

Recommended parameters example Separating ABL and SQL brokers/servers example Start a primary ABL broker Start a secondary SQL broker proserve myDB -S 6000 -H localhost -ServerType 4GL -Mi 1 -Ma 5 -minport 6100 -maxport 6300 -Mpb 4 -Mn 8 -B<n> -L<n> . . . proserve myDB -S 5000 -H localhost -ServerType SQL -Mi 5 -Ma 10 -minport 5100 -maxport 5300 -Mpb 2 –m3 -Mi minimum number of clients per server -Ma - maximum number of clients per server -ServerTtype specifies that only clients of that type may connect to servers spawned by that broker and is case sensitive. -Mpb is to restrict the number of servers that can be spawned by that broker. There is a slight performance gain by segregating the port ranges. There is a savings of 6 network type system calls. The secondary broker uses 1 one of the -Mn (Specify the maximum number of remote client servers that a broker can start) to ID itself. I suggest using a -Mi of MORE THAN 1 for SQL. Since SQL is threaded it performs better as threads are cheaper than processesd. Some groups of parameters define ‘database access and shared resources’ - DB server performance parameters - DB server internationalization parameters - DB server statistics parameters They are common to all brokers and servers running on a single physical database They are set by the first broker started on the database One group of parameters defines ‘database broker resources’ - The sever network parameters They define the 'client access resources' shared by all servers spawned from the broker In this group you can also find some specific parameters linked to the Admin. Service and java class path for SQL-92 The DB server type parameters allow to start either: An Auto Server (-m1 – This is used internally by PROGRESS) A single DB server (-m2) A secondary login broker (-m3) Helps to separate administration task for SQL-92 and 4GL. NOTE: for a list of the parameters that are in each group, please check the manual called "progress startup command and parameter reference" section 3.4 progress database server parameters Secondary broker uses 1 –Mn for itself

Security Authorization Authentication Authenticate then authorize Being I am who I say I am… What am I allowed to do Authentication Identify who I am Validate I am who I say I am

Security Database authentication Performed at connection SQL ABL ID and passwords Database authentication Performed at connection SQL User ID and password required to authenticate ABL User ID and password NOT required What?

SQL Authentication (Am I who I say I am?) ID and passwords scenarios Case 1: Users have not been created (no rows in _User table) No password validation at connection You are not “authenticated” You can pretend to be someone you are not Unable to do much (not authorized) UNLESS You created the database You know an authorized user Database creator Someone who was granted privileges Trusted user

SQL Authentication (Am I who I say I am?) ID and passwords scenarios…cont’d Case 2: Users have been created (rows exist in _User table) Password validation at connection Valid users defined by a DBA or SA Can be created by SQL or ABL Make sure existing SQL DBA has userid/pswd Invalid login/password error message: “Access denied (Authorisation failed). (8933) Either case there are 2 default DBAs, SYSPROGRESS and <db-owner>.

Authorization – What am I allowed to do? SQL follows GRANT security model By default, a connected userid is not authorized to do anything. Exceptions: the DBA account (full operations) the TABLE owner DBA controls operation privileges with GRANT / REVOKE syntax Table owner – unless DBA revokes DBA account can be <db-owner> or SYSPROGRESS by default , recommend changing this. Make sure to compare to ABL Remember the previous error. How come we don’t return: not authorized?

Comparing ABL & SQL Security Systems Security model GRANT Default DBA n/a <db-owner> SYSPROGRESS Default security administrator “*” Default table access <none> Default field access If we compare the two client’s security systems, you will notice some interesting information. I’ll let you read through the details later, but the highlights are: To many people’s surprise, the ABL core’s authorization implementation employs the GRANT model the same as SQL. Implementation wise in the ABL, no database connection user-id has access unless explicitly granted it. The second is that SQL employs the traditional definition of DBA, which the ABL does not. However, the ABL security system has a defined Security Administrator who is limited to managing user accounts and the data those user accounts can access. The primary difference between ABL and SQL is that the ABL’s defaults are made for a development environment where PUBLIC access is granted to everyone to the entire database. SQL employs a more production site approach in that it denies access to all until it is granted. ABL developers need set any security, but they need to configure security for the production sites. SQL developers need to set security in the development environment but is securely configured for production sites.

Encountering data access errors select count(*) from customer; Access denied (Authorization failed) (7512) Possible reasons for this: No authorization privileges Schema scope Discuss schema PUB schema Column not found

Authorization – What can I do? Privileges syntax: GRANT (2 types) Database wide (system admin or general creation) GRANT { DBA, RESOURCE } TO user_name [, user_name ] , …; Can do anything Can CREATE stuff RESOURCE Allows the specified users to issue CREATE statements. DBA Allows the specified users to create, access, modify, or delete any database object, and to grant other users any privileges. TO username [ , username ] , ... Grants the specified privileges on the table or view to the specified list of users. SELECT Allows the specified users to read data from the table or view. INSERT Allows the specified users to add new rows to the table or view. DELETE Allows the specified users to delete rows from the table or view. INDEX Allows the specified users to create an index on the table or view. UPDATE [ ( column , column , ... ) ] Allows the specified users to modify existing rows in the table or view. If followed by a column list, the users can modify values only in the columns named. REFERENCES [ ( column , column , ... ) ] Allows the specified users to refer to the table from other tables’ constraint definitions. If followed by a column list, constraint definitions can refer only to the columns named. CREATE USER ‘name’,’pass’

Authorization – What can I do? Privileges syntax: GRANT (2 types) Database wide (system admin or general creation) GRANT { DBA, RESOURCE } TO user_name [, user_name ] , …; For specified Tables or Views GRANT { privilege [, privilege ], … | ALL } ON table_name TO { user_name [, user_name ], … | PUBLIC } [ WITH GRANT OPTION ]; RESOURCE Allows the specified users to issue CREATE statements. DBA Allows the specified users to create, access, modify, or delete any database object, and to grant other users any privileges. TO username [ , username ] , ... Grants the specified privileges on the table or view to the specified list of users. SELECT Allows the specified users to read data from the table or view. INSERT Allows the specified users to add new rows to the table or view. DELETE Allows the specified users to delete rows from the table or view. INDEX Allows the specified users to create an index on the table or view. UPDATE [ ( column , column , ... ) ] Allows the specified users to modify existing rows in the table or view. If followed by a column list, the users can modify values only in the columns named. REFERENCES [ ( column , column , ... ) ] Allows the specified users to refer to the table from other tables’ constraint definitions. If followed by a column list, constraint definitions can refer only to the columns named. CREATE USER ‘name’,’pass’ Where ‘privilege’ is: { SELECT | INSERT | DELETE | INDEX | UPDATE [ ( column , column , ... ) ] | REFERENCES [ ( column , column , ... ) ] }

Authorization – What can I do? Example Syntax: GRANT For specified Tables or Views - Example See PSDN whitepaper on authorization for additional details. GRANT select ON PUB.Customer TO richb; GRANT select ON PUB.Order-line TO PUBLIC; COMMIT WORK; ROLLBACK WORK; RESOURCE Allows the specified users to issue CREATE statements. DBA Allows the specified users to create, access, modify, or delete any database object, and to grant other users any privileges. TO username [ , username ] , ... Grants the specified privileges on the table or view to the specified list of users. SELECT Allows the specified users to read data from the table or view. INSERT Allows the specified users to add new rows to the table or view. DELETE Allows the specified users to delete rows from the table or view. INDEX Allows the specified users to create an index on the table or view. UPDATE [ ( column , column , ... ) ] Allows the specified users to modify existing rows in the table or view. If followed by a column list, the users can modify values only in the columns named. REFERENCES [ ( column , column , ... ) ] Allows the specified users to refer to the table from other tables’ constraint definitions. If followed by a column list, constraint definitions can refer only to the columns named. CREATE USER ‘name’,’pass’

Encountering data access errors select count(*) from customer; Access denied (Authorization failed) (7512) Possible reasons for this: No authorization privileges Schema scope Discuss schema PUB schema Column not found Schema scope

Schema: a logical grouping In the “SQL world” schema is NOT meta data nor is it “Area 6” Mysports database richb schema Customer table #4 Contacts table #5 Friends table #6 PUB schema Customer table #1 Order table #2 Schema – logical grouping within a database Order-line table #3

Schemas What is a default schema? Users have a default schema attached to their ID <userid>.<table> richb.customer ABL uses one “hidden” schema – ‘PUB’ Use PUB.customer for access from SQL Avoiding schema qualification in SQL: Can set it as a registry entry in ODBC dsn definition PUBLIC indicates available to all Can set it as a registry entry in ODBC dsn defnition. Also, note that most application will generate full identifiers, including schema. CREATE PUBLIC SYNONYM customer FOR pub.customer;

Solving data access errors select count(*) from customer; Access denied (Authorization failed) (7512) Solution #1: SELECT count(*) FROM richb.customer; Solution #2: SELECT count(*) FROM pub.customer; Discuss schema PUB schema Column not found Solution #3: SET SCHEMA ‘pub’; SELECT count(*) FROM customer;

4 Part Naming – Multi-Database Query Fully Qualified Names – catalog is database name Four level naming convention catalog.schema.table.column-name When connected to auxiliary databases, use the catalog name with OpenEdge SQL query commands to qualify the database to which the query applies. The Primary database is automatically assigned a catalog name the same as the database name. OpenEdge Releases prior to 10.1B support 2 and 3 level names, for schema, tables (and stored procedures) and columns respectively, when referenced. Release 10.1B extends this naming to support 3 and 4 level naming (as defined in the SQL standard) with the addition of the catalog name naming-level. Names, according to the standard SQL syntax, are composed of 1, 2, 3, or 4 components, as described below: Catalog – a catalog is a named collection of schemas. In OpenEdge, a catalog logically corresponds to an Open Edge database. Schema – a named collection of table and other database objects. Tables Columns Tables have up to 3 components or levels: catalog.schema.tablename. Columns have up to 4 components or levels: catalog.schema.table.column-name. Similarly, a stored procedure can be referred to as “catalog.schema.proc-name”. This naming system is supported by many tools, such as Crystal, by competitors such as Microsoft SQL Server, and by related standards such as ODBC and JDBC. Catalog names cannot be used on DDL statements, such as ALTER or CREATE. Catalog names cannot be used with sequences. Synonyms: A public synonym, used without a qualifier, must exist in the set of synonyms defined for the primary database. A public synonym may be qualified with a catalog name, with or without a schema name, in which case the synonym must exist in the set of synonyms defined for the specified catalog. A private synonym must always be qualified by at least the schema name of the schema where that synonym exists. A private synonym, used with only a schema qualifier, must exist in the set of synonyms defined for the primary database. Stored procedures: A stored procedure in an auxiliary catalog can be called by explicitly qualifying the procedure name by the catalog name. The SQL statements executed from within a stored procedure are interpreted in light of the multiple catalogs active. Consider a stored procedure “order_parts” stored in an auxiliary database. Tables referenced from statements in “order_parts”, if they are not qualified by a catalog name, will refer to tables in the default catalog (the Primary database) and NOT the auxiliary database. This may not be what was intended. To avoid such problems, fully qualify table names in stored procedures. call mysports.pub.order_parts(cItemCode)

4 Part Naming – Multi-Database Query Fully Qualified Names – catalog is database name Four level naming convention Example catalog.schema.table.column-name SELECT Pub.Customer.CustNum, SportsPrimary.Pub.Customer.Name, SportsAux1.Pub.Order.OrderNum … When connected to auxiliary databases, use the catalog name with OpenEdge SQL query commands to qualify the database to which the query applies. The Primary database is automatically assigned a catalog name the same as the database name. OpenEdge Releases prior to 10.1B support 2 and 3 level names, for schema, tables (and stored procedures) and columns respectively, when referenced. Release 10.1B extends this naming to support 3 and 4 level naming (as defined in the SQL standard) with the addition of the catalog name naming-level. Names, according to the standard SQL syntax, are composed of 1, 2, 3, or 4 components, as described below: Catalog – a catalog is a named collection of schemas. In OpenEdge, a catalog logically corresponds to an Open Edge database. Schema – a named collection of table and other database objects. Tables Columns Tables have up to 3 components or levels: catalog.schema.tablename. Columns have up to 4 components or levels: catalog.schema.table.column-name. Similarly, a stored procedure can be referred to as “catalog.schema.proc-name”. This naming system is supported by many tools, such as Crystal, by competitors such as Microsoft SQL Server, and by related standards such as ODBC and JDBC. Catalog names cannot be used on DDL statements, such as ALTER or CREATE. Catalog names cannot be used with sequences. Synonyms: A public synonym, used without a qualifier, must exist in the set of synonyms defined for the primary database. A public synonym may be qualified with a catalog name, with or without a schema name, in which case the synonym must exist in the set of synonyms defined for the specified catalog. A private synonym must always be qualified by at least the schema name of the schema where that synonym exists. A private synonym, used with only a schema qualifier, must exist in the set of synonyms defined for the primary database. Stored procedures: A stored procedure in an auxiliary catalog can be called by explicitly qualifying the procedure name by the catalog name. The SQL statements executed from within a stored procedure are interpreted in light of the multiple catalogs active. Consider a stored procedure “order_parts” stored in an auxiliary database. Tables referenced from statements in “order_parts”, if they are not qualified by a catalog name, will refer to tables in the default catalog (the Primary database) and NOT the auxiliary database. This may not be what was intended. To avoid such problems, fully qualify table names in stored procedures. call mysports.pub.order_parts(cItemCode)

4 Part Naming – Multi-Database Query Fully Qualified Names – catalog is database name Four level naming convention Example ABL has 3 level naming convention catalog.schema.table.column-name SELECT Pub.Customer.CustNum, SportsPrimary.Pub.Customer.Name, SportsAux1.Pub.Order.OrderNum … When connected to auxiliary databases, use the catalog name with OpenEdge SQL query commands to qualify the database to which the query applies. The Primary database is automatically assigned a catalog name the same as the database name. OpenEdge Releases prior to 10.1B support 2 and 3 level names, for schema, tables (and stored procedures) and columns respectively, when referenced. Release 10.1B extends this naming to support 3 and 4 level naming (as defined in the SQL standard) with the addition of the catalog name naming-level. Names, according to the standard SQL syntax, are composed of 1, 2, 3, or 4 components, as described below: Catalog – a catalog is a named collection of schemas. In OpenEdge, a catalog logically corresponds to an Open Edge database. Schema – a named collection of table and other database objects. Tables Columns Tables have up to 3 components or levels: catalog.schema.tablename. Columns have up to 4 components or levels: catalog.schema.table.column-name. Similarly, a stored procedure can be referred to as “catalog.schema.proc-name”. This naming system is supported by many tools, such as Crystal, by competitors such as Microsoft SQL Server, and by related standards such as ODBC and JDBC. Catalog names cannot be used on DDL statements, such as ALTER or CREATE. Catalog names cannot be used with sequences. Synonyms: A public synonym, used without a qualifier, must exist in the set of synonyms defined for the primary database. A public synonym may be qualified with a catalog name, with or without a schema name, in which case the synonym must exist in the set of synonyms defined for the specified catalog. A private synonym must always be qualified by at least the schema name of the schema where that synonym exists. A private synonym, used with only a schema qualifier, must exist in the set of synonyms defined for the primary database. Stored procedures: A stored procedure in an auxiliary catalog can be called by explicitly qualifying the procedure name by the catalog name. The SQL statements executed from within a stored procedure are interpreted in light of the multiple catalogs active. Consider a stored procedure “order_parts” stored in an auxiliary database. Tables referenced from statements in “order_parts”, if they are not qualified by a catalog name, will refer to tables in the default catalog (the Primary database) and NOT the auxiliary database. This may not be what was intended. To avoid such problems, fully qualify table names in stored procedures. call mysports.pub.order_parts(cItemCode) catalog.table.column-name

OpenEdge Specifics SQL is a standard, but each vendor has it’s own dialect

OpenEdge SQL Specifics - Quoting Non-SQL standard names Hyphenated names: SELECT cust-num FROM PUB.Customer; Column CUST cannot be found (13865) Solution: quoting (double quotes) Most reporting apps will do this for you already SELECT “cust-num” FROM PUB.Customer; Most reporting applications will do this automatically.

Overstuffed fields - error ABL allows more data than column definition SQL restricted to _field._sql-width value SELECT name from PUB.customer; Column name in table PUB.customer has value exceeding it’s max length. ALTER TABLE <table name> ALTER COLUMN <column name> SET PRO_SQL_WIDTH  <value>; or Connect to the Database via the Progress Data Dictionary and choose menu - Options - SQL Properties - Adjust Field Width. Solution: Fix _sql-width via SQL “ALTER TABLE or Data Dictionary ALTER table… ALTER column… SET PRO_SQL_WIDTH  <value>;

OpenEdge Specifics - Overstuffed fields Strategies for managing: Dbtool : percentage option ($DLC/bin/dbtool) 1. SQL Width & Date Scan w/Report Option 2. SQL Width Scan w/Fix Option Choice: 2 <connect>: (0=single-user 1=self-service >1=#threads)? 3 Padding % above current max: 25 <table>: (Table number or all)? all <area>: (Area number or all)? all Performance impact – more memory allocation on client and server side for result sets Tool is online. Storage wise it’s the same, because everything is packed format. 25% the first time, Probably don’t want 25% each time after that. Using the DBTool utility The DBTool utility allows Progress users to identify when the size of column data in the database exceeds the Data Dictionary definition and therefore the SQLWidth value. The DBTool utility addresses this situation because it allows for the fast updating of Data Dictionary SQLWidth definitions. The following error message is reported to a SQL application when the SQLWidth for a column exceeds the Data Dictionary SQLWidth definition: Column column in table table has value exceeding its max length or precision (7864) The syntax for DBTool is: Syntax dbtool dbname To access DBTool from the command line: Type dbtool and the database name and press Enter. The DBTool option menu appears: Select an option from the menu and press Enter. Table 7–2 describes the options available in the DBTool option menu. Table 7–2: DBTool option menu Option Description 1 Finds the maximum field sizes and reports them. 2 Finds the maximum field sizes and updates their widths. 3 Validates the schema versioning of the records after the records are updated by DBTool. 4 Validates the schema versioning before and after the records are updated in DBTool. 5 Validates db keys while scanning database blocks. 9 Enables or disables file logging. Q Quits the DBTool utility. For more information on the DBTool utility, see OpenEdge Data Management: Database Administration.

OpenEdge Specifics - Overstuffed fields Strategies for managing ABL client startup parameter <progress-client> –checkwidth n where "n" can be one of the following: 0 — Ignore: Default is to ignore _width value. 1 — WARNING: Store the data and generate a warning. 2 — ERROR: Do not store data and generate an error. Using the -checkwidth startup parameter OpenEdge 4GL programmers can override Data Dictionary column definitions in 4GL programs. Therefore, a SQL application cannot read a record if a column contains data greater than the SQLWidth value defined in the Data Dictionary. An attempt to retrieve a column that exceeds the SQLWidth definition generates an error message, and the attempt to access the record fails. Use the -checkwidth startup parameter to specify whether Progress compares CHARACTER, DECIMAL, and RAW field data against the metaschema _width field value before updating a database record. The _width field value specifies the maximum width of the data allowed in a field. The syntax for the -checkwidth startup parameter is: Syntax -checkwidth n The -checkwidth startup parameter can be employed in the following modes: 0 — Ignore the _width field value and store the data. This is the default mode. 1 — Store the data and generate a warning message if the data exceeds the size specified in the _width field. 2 — Do not store data that exceeds the size specified in the _width field and generate an error. Specify this mode if you want the Progress 4GL to behave like SQL. For more information on the -checkwidth startup parameter, see OpenEdge Deployment: Startup Command and Parameter Reference. .lg and screen: Width of data is greater than x.customer.Name _width.

OpenEdge Specifics – Arrays / Extents Selecting array columns as a whole Result: semi-colon separated varchar value 102332.67;330002.77;443434.55;333376.50 Selecting array column individually – SQL99 (10.1a) Result: numeric value 102332.67 SELECT quarterlySales from PUB.MySales; Array syntax[] – same as ABL No ODBC support? No jdbc support? SELECT quarterlySales[1] from PUB.MySales;

OpenEdge Specifics – Arrays / Extents Using views to break out array element CREATE VIEW pubView.QuarterSalesView (qS1, qS2, qS3, qS4) AS SELECT quarterlySales[1], quarterlySales[2], quarterlySales[3], quarterlySales[4] FROM PUB.MySales; GRANT select ON pubView.QuarterSalevVIew TO PUBLIC; See whitepaper on PSDN Needed for Crystal to present Arrays as individual elements. SELECT qS1, qS2, qS3, qS4 FROM pubView.QuarterSalesView; Result: numeric values 102332.67 330002.77 443434.55 333376.50

? TIME = Q: What is it going to cost to run my query? Query Performance Q: What is it going to cost to run my query? ? TIME = The OpenEdge SQL Engine contains a query optimizer that analyzes SQL queries and produces a plan for how SQL should best execute the query. The plan contains information such as which tables to access, in what order, and with which indexes. To produce a good query plan, the optimizer analyzes the query and considers many methods for each query execution step.

TIME = Q: What is it going to cost to run my query? Query Performance The OpenEdge SQL Engine contains a query optimizer that analyzes SQL queries and produces a plan for how SQL should best execute the query. The plan contains information such as which tables to access, in what order, and with which indexes. To produce a good query plan, the optimizer analyzes the query and considers many methods for each query execution step.

Basic Performance: What is the cost? Database without statistics Optimizer: How many rows do I think you have? 100K 50K 10K rows No pre-selected index. At runtime, it decides based on data profile, which index or not is best to use based on “cost”. Optimizer makes decisions based on the statistcis data profile. replace with BAR Graph OrderLines Orders Parts SalesHist Customer

Basic Performance: Here’s the cost. Database with Update Statistics 100K 50K 10K rows No pre-selected index. At runtime, it decides based on data profile, which index or not is best to use based on “cost”. Optimizer makes decisions based on the statistcis data profile. replace with BAR Graph OrderLines Orders Parts SalesHist Customer

Query Performance: Update Statistics UPDATE STATISTICS syntax All Statistics: Table Cardinality, indexes and all columns UPDATE TABLE STATISTICS AND INDEX STATISTICS AND [ALL] COLUMN STATISTICS; Statistics - particular table How often? 20% data change – either adding new data or changing existing data UPDATE TABLE STATISTICS AND INDEX STATISTICS AND [ALL] COLUMN STATISTICS FOR pub.customer;

Query trees : Defined relational algebraic tree representation (query tree / execution tree ) Result set What are query trees What’s in a query – breakdown of a statement ( Define project, restrict, join) What do query trees look like Inverted tree, ‘tree in New England’ The query processor makes extensive use of the relational algebraic tree representation to model and manipulate SQL queries. These trees can be thought of as a series of pipes, valves, and other components through which data flows, entering through the bottom from one or more tables, and leaving through the top as a result set. At various points within the tree, the data are operated on as needed to produce the desired result. Each operation is represented as a node in the tree. Nodes may also have one or more expressions associated with them to specify columns, conditions, and calculations associated with the operation. Some of the operators that may be present in the tree are: Restrictions reduce the number of output rows by eliminating those that fail to satisfy some condition applied to the input. Restrict operators appear in the tree from predicates (WHERE clauses). Projections reduce the number of output columns by eliminating columns not present in a project list. Projection operators appear in the tree from SELECT statements. Joins combine two or more input tables into a single output table that contains some combination of rows from the inputs. Joins appear in the tree from the use of FROM clauses. Sorts change the ordering of rows in an input table to produce an output table in the desired order. Leaf nodes of the tree are always references to database tables. Data Database access

Basic Performance: Viewing Query Plans Viewing query plan constructed by cost-based optimizer SET PRO_SERVER LOG [ ON | OFF ] [ WITH ( { STATEMENT, QUERY_PLAN } ) ]; Query Plans Located in VST “_Sql_Qplan” SELECT SUBSTRING("_Description",1,80) FROM pub."_Sql_Qplan“ WHERE "_Pnumber" = (SELECT MAX( "_Pnumber" ) FROM pub."_Sql_Qplan" WHERE "_Ptype" > 0 ); Create a view to make your life simpler… Select * from my_qplan; Add application query first hard coded VST , not browseable can also do online query plan tracing for whole server- using logging mechanism Remembers last 10 queries for a client

Query plan: What to look for Simple single table select SELECT … FROM pub.customer WHERE “cust-num” between 1000 and 1100 [ NoExecute ] SELECT COMMAND. PROJECT [66] ( | PROJECT [64] ( | | PUB.CUSTOMER. [0]( | | | INDEX SCAN OF ( | | | | cust-num, | | | | | (PUB.CUSTOMER.cust-num) between (1000,1100)) table index Simple indentation to show tree form. Find and consider the highlights shown. Ignore the Project operations, and other less important operations. index keys, predicates

Query plan: What to look for Simple single table select SELECT … FROM pub.customer WHERE ”cust-num” between 3000 and 3100 [ NoExecute ] with index hint WITH (INDEX (name)) SELECT COMMAND. PROJECT [66] ( | PROJECT [64] ( | | PUB.CUSTOMER. [0]( | | | INDEX SCAN OF ( | | | | cust-num, | | | | | (PUB.CUSTOMER.cust-num) between (3000,3100)) table index Simple indentation to show tree form. Find and consider the highlights shown. Ignore the Project operations, and other less important operations. index keys, predicates

In Summary Initial SQL connection Setup and maintenance in OpenEdge database for security and performance Specifics of OpenEdge with SQL applications

For More Information, go to… PSDN Developing Performance-Oriented ODBC/JDBC OpenEdge Applications OpenEdge SQL: Authorization Explained OpenEdge SQL in a 10.1B Multi-Database Environment OpenEdge® Database Run-time Security Revealed OpenEdge Technical Support - KBases Basic Guide to Defining Progress SQL Database Permissions & Security Progress eLearning Community Using OpenEdge SQL Documentation 10.1C OpenEdge Data Management: SQL Development   10.1C OpenEdge Data Management: SQL Reference TS Knowledge base Security – Mike Jacob’s talk

? Questions

Some Questions Answered Is there a way to grant a user select privilege for all tables in one statement? There is no way to grant privileges for all tables in one statement.  Other than grant dba ;) Does the field level extent (array fields) reporting where members are separated by ";" work for ALL data type? yes If so, then how is a ";" handled within a character field?  Is it quoted when encountered to differentiate between an array entry separator?   An embedded semi-colon in a varchar array will be preceded by a ~

Thank You Thank you in many languages