B6: Beginners Guide to OpenEdge - PowerPoint PPT Presentation

About This Presentation
Title:

B6: Beginners Guide to OpenEdge

Description:

B6: Beginners Guide to OpenEdge SQL via ODBC or JDBC Richard Banville Technical Fellow Agenda: OpenEdge SQL Component overview Initial connection OpenEdge database ... – PowerPoint PPT presentation

Number of Views:489
Avg rating:3.0/5.0
Slides: 51
Provided by: downloadP
Category:

less

Transcript and Presenter's Notes

Title: B6: Beginners Guide to OpenEdge


1
B6 Beginners Guide to OpenEdge SQL via ODBC
or JDBC
Richard Banville
Technical Fellow
2
Agenda
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

3
OpenEdge is Open
Crystal Reports WebSphere JBOSS / JRun Java /
JDBC apps J2EE / JTA .NET / ODBC apps ADO.NET /
VB
ABL
OpenEdge SQL
Open Clients Java .NET Web services
(ABL works with relational DBs)
(works with OpenEdge RDBMS)
.NETJavaHTML
ODBC Clients
JDBC Clients
OpenEdge ABL Clients
ServiceInterfaces
Open Clients(Non-OpenEdge)
OpenEdgeDataServers
OpenEdgeABL Server
OpenEdgeSQL Server
SSL HTTP HTTP/S HTML
OpenEdgeRDBMS
OtherRDBMS
OracleMSSQLODBC
Data is fully interoperable ABL SQL
4
Getting Connected Client side ODBC
and JDBC drivers
5
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.OpenEdgeDri
ver
jdbcdatadirectopenedge//localhost6748database
Namedb1
6
ODBC DSN single connection
7
ODBC Multi-Database configuration (10.1B)
8
ODBC DSN - Advanced Tab
  • Isolations defaults have changed between
    versions
  • Fetch Array Size Max rows driver fetches from
    server
  • T w/TZ determines native or varchar storage
  • Wide char varchar SQL_WVARCHAR vs SQL_VARCHAR

9
Isolation Level Affect on Lock Type
10
Connection server side
11
Default server setup
SQL Servers
Shared Memory
SQL client
SQL client
SQL ABL Broker
ABL client
ABL client
12
Recommended server setup
SQL Servers
Shared Memory
SQL only Broker
SQL client
SQL client
ABL client
ABL client
ABL only Broker
13
Recommended parameters example
Separating ABL and SQL brokers/servers example
Start a secondary SQL broker
Start a primary ABL broker
proserve myDB -S 5000 -H localhost
-ServerType SQL -Mi 5 -Ma 10 -minport
5100 -maxport 5300 -Mpb 2 m3
proserve myDB -S 6000 -H localhost
-ServerType 4GL -Mi 1 -Ma 5 -minport
6100 -maxport 6300 -Mpb 4 -Mn
8 -Bltngt -Lltngt . . .
Secondary broker uses 1 Mn for itself
14
Security
Authenticate then authorize
Authentication
  • Identify who I am
  • Validate I am who I say I am

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

What?
16
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

17
SQL Authentication (Am I who I say I am?)
ID and passwords scenarioscontd
  • 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)

18
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

19
Comparing ABL SQL Security Systems
ABL SQL
Security model GRANT GRANT
Default DBA n/a ltdb-ownergtSYSPROGRESS
Default security administrator n/a
Default table access ltnonegt
Default field access ltnonegt
20
Encountering data access errors
select count() from customer
Access denied (Authorization failed) (7512)
  • Possible reasons for this
  • No authorization privileges
  • Schema scope

21
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 CREATE stuff
Can do anything
22
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
  • Where privilege is
  • SELECT INSERT DELETE INDEX
  • UPDATE ( column , column , ... )
    REFERENCES ( column , column , ... )

23
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
24
Encountering data access errors
select count() from customer
Access denied (Authorization failed) (7512)
  • Possible reasons for this
  • No authorization privileges
  • Schema scope

Schema scope
25
Schema a logical grouping
In the SQL world schema is NOT meta data nor is
it Area 6
Mysports database
PUB schema
Customer table 1
Order table 2
Order-line table 3
26
Schemas
What is a default schema?
  • Users have a default schema attached to their ID
  • ltuseridgt.lttablegt 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

CREATE PUBLIC SYNONYM customer FOR
pub.customer
27
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
Solution 3
SET SCHEMA pub SELECT count() FROM customer

28
4 Part Naming Multi-Database Query
Fully Qualified Names catalog is database name
  • Four level naming convention

catalog.schema.table.column-name
29
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
30
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
catalog.table.column-name
31
OpenEdge Specifics
  • SQL is a standard,
  • but each vendor has its own dialect

32
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)

SELECT cust-num FROM PUB.Customer
Most reporting applications will do this
automatically.
33
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 its max length.
  • Solution

Fix _sql-width via SQL ALTER TABLE or Data
Dictionary
ALTER table ALTER column SET PRO_SQL_WIDTH 
ltvaluegt
34
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
ltconnectgt (0single-user 1self-service
gt1threads)? 3 Padding above current
max 25 lttablegt (Table number or
all)? all ltareagt (Area number or
all)? all
35
OpenEdge Specifics - Overstuffed fields
  • Strategies for managing
  • ABL client startup parameter

ltprogress-clientgt checkwidth nwhere
"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.
.lg and screen Width of data is greater than
x.customer.Name _width.
36
OpenEdge Specifics Arrays / Extents
  • Selecting array columns as a whole
  • Result semi-colon separated varchar value
  • 102332.67330002.77443434.55333376.50
  • Selecting array column individually SQL99
    (10.1a)
  • Result numeric value
  • 102332.67

SELECT quarterlySales from PUB.MySales
SELECT quarterlySales1 from PUB.MySales
37
OpenEdge Specifics Arrays / Extents
  • Using views to break out array element

CREATE VIEW pubView.QuarterSalesView
(qS1, qS2, qS3, qS4) AS
SELECT quarterlySales1, quarterlySales2,
quarterlySales3,
quarterlySales4 FROM
PUB.MySales
GRANT select ON pubView.QuarterSalevVIew
TO PUBLIC
SELECT qS1, qS2, qS3, qS4
FROM pubView.QuarterSalesView
Result numeric values 102332.67 330002.77
443434.55 333376.50
38
Query Performance
  • Q What is it going to cost to run my query?

?
TIME
39
Query Performance
  • Q What is it going to cost to run my query?

TIME
40
Basic Performance What is the cost?
Database without statistics
Optimizer How many rows do I think you have?
100K
50K
10K rows
OrderLines
Parts
SalesHist
Orders
Customer
41
Basic Performance Heres the cost.
Database with Update Statistics
100K
50K
10K rows
OrderLines
Parts
SalesHist
Orders
Customer
42
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

UPDATE TABLE STATISTICS AND
INDEX STATISTICS AND ALL COLUMN
STATISTICS FOR pub.customer
43
Query trees Defined
  • relational algebraic tree representation
  • (query tree / execution tree )

Result set
Data
Database access
44
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" gt 0 )
Remembers last 10 queries for a client
45
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))
46
Query plan What to look for
with index hint
  • Simple single table select
  • SELECT FROM pub.customer
  • WHERE cust-num between 3000 and 3100
    NoExecute

WITH (INDEX (name))
SELECT COMMAND. PROJECT 66 ( PROJECT 64
( PUB.CUSTOMER. 0( INDEX
SCAN OF ( cust-num,
(PUB.CUSTOMER.cust-num)
between (3000,3100))
47
In Summary
  • Initial SQL connection
  • Setup and maintenance in OpenEdge database for
    security and performance
  • Specifics of OpenEdge with SQL applications

48
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

49
?
Questions
50
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

51
Thank You
52
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com