sql support in 2e - home - cm first...

43
9 th CA 2E/CA Plex Worldwide Developer Conference SQL Support in 2E 1

Upload: others

Post on 24-Mar-2020

12 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Support in 2E

1

Page 2: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

Introduction/Welcome Message

Modern CA:2E 8.7 allows us to transform our database from traditional DDS specifications, to more modern and

accepted SQL. This training session will show the process of moving from DDS to SQL, and how this can be done in a

practical setting.

2

Page 3: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

Speakers

3

Jason OlsonCM First Group

Ragu DaitaCA

Page 4: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

Agenda

4

o Housekeeping• Connection to DEVi5• Accessing your specific model.

o What Exactly is SQL?o Benefits of Moving to SQL• Developer Benefits• SQL Performance Benefits

o SQL Objects vs DDS Objectso SQL Source vs DDS Sourceo SQL Specific Data Typeso How to Configure SQL Supporto Hands On Workshop• Re-configure existing model for SQL

Page 5: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

Housekeeping

5

Page 6: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

Housekeeping

6

o Connection to DEVi5.• Address is – DEVi5.cmfirsttech.com• Each profile begins with CON then XX where XX is your student ID number. This

number will be given to you.• When you sign in you will be taken directly into your specific model.

o Breaks• If anyone does need a break just feel free to request one.

o Questions• Please feel free to stop us at anytime if you have questions or comments you wish to

present to us.

Page 7: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

What Exactly is SQL?

7

Page 8: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

What Exactly is SQL?

8

o SQL Stands for Structured Query Language.o Developed at IBM in the Early 1970s.o Consists of a DDL (Data Definition Language) • Examples are, CREATE TABLE, CREATE INDEX

o Consists of a DML (Data Manipulation Language)• Examples are, INSERT INTO, UPDATE, DELETE,

o To a Large Extent Consists of Simple English Statements.

Page 9: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

Benefits of Moving to SQL

9

Page 10: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

Benefits of Moving to SQL

10

o Whole World Uses SQL. New resources are more familiar with SQL then DDS.o Long Field Names are Available to Outside World. YAY! Jo Data is Validated when Written to the Database.o DDL Defined Indexes use a 64K page size vs 8K used by Logical Files.o RPG Programs that Use SQL Access Don’t Need a Re-compile.o Benefits outside of 2E. • Null Capable Fields.• New Data Types (Blob, Clob, Lob)• Automatic Identity Columns.

Page 11: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

Benefits of Moving to SQL

11

o No Enhancements to DDS Language.o Constraints are Built into Database.o Built in Encryption.o Easier Modification of Table Layouts.o RPG Programs that Use SQL Access Don’t Need a Re-compile.o Automatic Identity Columns.

Page 12: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Objects vs DDS Objects

12

Page 13: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Objects vs DDS Objects

13

o DDS Objects Create Physical Files & Logical Files• The Object types are *FILE PF and *FILE LF• Most common source is DDS and stored in QDDSSRC.• Source Member type is PF for Physical files, and LF for Logical Files.• Compiled like a program using option 14 from PDM, or using the CRTPF or CRTLF commands.

o SQL Objects create Physical Files & Logical Files as well.• The Object types are *FILE PF and *FILE LF• Most common source is SQL and stored in QSQLSRC.• Source Member type can be named anything.• In 2E the member types are YSQL.

Page 14: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Objects vs DDS Objects

14

Page 15: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Objects vs DDS Objects

15

Page 16: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Objects vs DDS Objects

16

Page 17: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Source vs DDS Source

17

Page 18: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Source vs DDS Source

18

o SQL Source is stored in source file QSQLSRC.• Most common source file, and 2E uses this as well.

o Source member type can be named anything.• In 2E they are YSQL.

o SQL Objects are created using the RUNSQLSTM command.• Normal GEN process in 2E performs this under the covers.

Page 19: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Source vs DDS Source

19

Page 20: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Source vs DDS Source

20

Page 21: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Source vs DDS Source

21

o Items to Note!• SQL objects are created using the RUNSQLSTM Command.• SQL View And Indexes produce separate IBM i Objects. (LFs) 2E does this as well.• No problem combining SQL Created tables and DDS Created LFs. (Common)

Page 22: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Source vs DDS Source

22

o DML is used to manipulate the data in the database.• SELECT ( to read data )• INSERT ( to insert data )• UPDATE (to update data)• DELETE (to delete data)

o Big advantage is the use of the DB2 Database Engine for automatic index selection.• If an index exists that matches the search criteria then that index will be used automatically. In

standard record level access from RPG this is not the case.o SQL DML Statements can be incorporated directly into an RPG program.• There is no longer a need to use the traditional record level access provided by RPG.

Page 23: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Source vs DDS Source

23

Page 24: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Source vs DDS Source

24

Page 25: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Source vs DDS Source

25

Page 26: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Specific Data Types

26

Page 27: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

SQL Specific Data Types

27

o Items that can be performed outside of 2E.• BLOB data type to store binary data.

§ Examples are text files, audio files, spreadsheets§ SQL Only Data Type! (No DDS Support)§ BLOBs can be up to 2GB in size! YAY!§ Created As Column In Table Definition.§ Cannot Be Modified Outside of Program. (NOT in IFS)§ Takes Advantage of IBM i Security.§ Automatic Replication to Target HA System.

• Others are LOB, and CLOB.• NULLs• SQL only. (No DDS Support)

Page 28: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

How to Configure SQL Support

28

Page 29: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

How to Configure SQL Support

29

o Multiple approaches can be taken to change a model to support SQL.• The model can be changed to use the 2E generated table name, but use longer field name

support. This allows you to expose the longer field names to the outside world. No change to RPG.

• The model can be changed to use both the longer table name, and also the longer field names. Again, easier for the outside world. No change to RPG.

• The model can be changed so generated function to use SQL record level access regardless of the database type.

• The model can be changed to use SQL for the database, and also SQL record access for all the functions. DDS would not be generated at all in this case.

Page 30: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

How to Configure SQL Support

30

o To change the model at the model level, multiple model values need to be configured.

Name Description ValuesYSQLVNM SQLnaming *DDS

YDDLDBA DatabaseAccessMethod *RLA /*SQL

YSQLLEN SQLnaminglength 10 to25

YSQLOPT GenerateSQLOPTIMIZEclause *NO

YSQLFMT GenerateSQLRCDFMTclause *NO

YSQLSTM SQLstatementgenerationtype *EXC

YSQLCOL GenerateSQLCol/LibraryName *YES

YLVLCHK GenerateIDXwithLVLCHK(*YES) *NO

YDBFGEN Methodfordatabasefilegeneration DDS/SQL/DDL

YSQLWHR specifieswhethertouseORor NOTlogicwhengeneratingSQLWHEREclauses.Thedefaultis*OR.

YSQLLCK

Page 31: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

Model Values in Detail

31

Page 32: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

How to Configure SQL Support

32

o YSQLVNM - relates to the naming scheme used for fields and files. • *DDS – Uses the DDS name• *SQL – Use the names of the objects in the model. • *LNG – Use long names for fields and files• *LNF – Use long field names • *LNT – Use long table names

Page 33: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

How to Configure SQL Support

33

o YDDLDBA - specifies the method of accessing the database • *RLA - External function generates with RLA access.• *SQL - External function generates with SQL access.

Page 34: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

How to Configure SQL Support

34

o YDDLDBA - specifies the method of accessing the database • *RLA - External function generates with RLA access.• *SQL - External function generates with SQL access.

Page 35: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

How to Configure SQL Support

35

o YSQLLEN – The length of field names up to 25 characters. • Any number between 10 and 25.• Outside of 2E this number can be much larger.

Page 36: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

How to Configure SQL Support

36

o YSQLFMT - Specifies whether the RCDFMT keyword must be generated for SQL tables, views, and indexes. • *YES - the RCDFMT value is calculated using the same rules as are used

when DDS files are generated. • *NO - the record format is the same as the table, index, or view name.

Page 37: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

How to Configure SQL Support

37

o YDBFGEN – Specifies the language used in creating the logical/view over a physical file/table. • *DDS• *SQL• *DDL

Page 38: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

How to Configure SQL Support

38

o Individual tables and access paths can also be changed without changing model values.

Page 39: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

How to Configure SQL Support

39

o Individual tables and access paths can also be changed without changing model values.

Page 40: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

How to Configure SQL Support

40

o The same can also be changed for functions.

Page 41: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

Hands On Workshop

41

Page 42: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

Hands On Workshop

42

o In this Hands On Workshop we are going to be doing the following.• First we’ll change the bare minimum model values to support SQL.• Second we will change a function to use SQL access instead of standard record level

access. No table or access paths will be changed.• Third we will change a table, it’s access paths, and then functions to be SQL.• Finally we will change the rest of our model’s model values to support SQL.

§ From this point everything generated would be SQL and non DDS.

Page 43: SQL Support in 2E - Home - CM First Groupcmfirstgroup.com/wp-content/uploads/2017/10/Plex2e2017_Day01_CA_2E... · o SQL Source is stored in source file QSQLSRC. • Most common source

9th CA 2E/CA Plex Worldwide Developer Conference

Contact

43

Jason OlsonEmail: [email protected]: www.cmfirstgroup.com

Ragu [email protected]: www.ca.com