Db2 for i - Commoncommon.nl/images/Presentations/Db2-for-i.pdf · 9 Db2 Web Query Version 2.2.1 •...

45
Cognitive Systems Db2 for i © 2018 IBM Corporation Scott Forstie [email protected] Business Architect Db2 for i

Transcript of Db2 for i - Commoncommon.nl/images/Presentations/Db2-for-i.pdf · 9 Db2 Web Query Version 2.2.1 •...

  • Cognitive Systems

    Db2 for i

    © 2018 IBM Corporation

    Scott Forstie – [email protected] Architect Db2 for i

  • © 2018 IBM Corporation

    Cognitive Systems

    IBM i 7.1

    • End of Support – April 30, 2018

    • End of Extended Support – April 2021

  • © 2018 IBM Corporation

    Cognitive Systems

    3

    Enhancements delivered via Db2 PTF Groups

    www.ibm.com/developerworks/ibmi/techupdates/db2/groupptf

    2017 2018

    7.2 – TR57.3 – TR1

    7.2 – TR67.3 – TR2

    Enhancements timed with TR2 & TR6

    • JSON predicates

    • Additional Database features in ACS

    • New and enhanced SQL Scalar

    Functions

    • New IBM i Services

    • Enhanced Db2 for i Services

    • And more…

    SF99702 Level 14SF99703 Level 3

    SF99702 Level 16SF99703 Level 4

    SF99702 Level 20SF99703 Level 8

    7.2 – TR77.3 – TR3

    Enhancements timed with TR3 & TR7

    • JSON publishing functions

    • Db2 for i generated syslog data

    • More LIMIT & OFFSET support

    • Additional Database features in

    ACS

    • New IBM i Services

    • And more…

    7.2 – TR87.3 – TR4

    7.2 – TR97.3 – TR5

    SF99702 Level xxSF99703 Level x

    Enhancements timed with TR5 & TR9

    • Stay tuned!

    http://www.ibm.com/developerworks/ibmi/techupdates/db2/groupptf

  • © 2018 IBM Corporation

    Cognitive Systems

    4

    Application-centric

    123 Fish, Joe 555 20000 001124 Olson, Ole 501 20000 501125 Smith, Sally 555 32000 555126 Johnson, John 501 38000 001127 Smith, Jim 555 30000 555

    SQL Table or View or DDS Physical or Logical File

    Cobol

    …STARTREAD…

    RPG

    …SETLLREAD…

    C or C++

    …RopenRread…

    Native Interfaces SQL Interfaces

    Extended Dynamic Remote SQL (XDA)

    JDESAP…

    Distributed Relational Database (DRDA)

    JDBC ODBC.NET ADO

    Cobol

    …EXEC SQLFETCH

    …EXEC SQLFETCH

    …EXEC SQLFETCH

    RPG C or C++DB2 Connect Drivers

    Host Server (ZDA)

    IBM i Access Drivers

    JDBC ODBC.NET ADO

    IBM i Access Optimized APIs

    Distributed Data Management (DDM

    Cobol

    …STARTREAD…

    RPG

    …SETLLREAD…

    C or C++

    …RopenRread…

    JDBC

    Toolbox JDBC DriverNative JDBC Driver

    Cobol

    …EXEC SQLFETCH

    …EXEC SQLFETCH

    …EXEC SQLFETCH

    RPG C or C++

    Embedded SQL

    CLI

    Cobol

    …SQLExecDirectSQL FETCH…

    …SQLExecDirectSQLFETCH…

    …SQLExecDirectSQLFETCH…

    RPG C or C++

    Cobol

    …QSQPRCED…

    …QSQPRCED…

    …QSQPRCED…

    RPG C or C++

    QSQPRCEDAPI

    Commands & APIs

    RUNSQL, RUNSQLSTM, STRQRY, CRTDUPOBJ, etc…

    • More expensive to

    build, maintain,

    test, extend

    • Not comprehensive

    • Harder to secure

  • © 2018 IBM Corporation

    Cognitive Systems

    5

    Data-centric

    123 Fish, Joe 555 20000 001124 Olson, Ole 501 20000 501125 Smith, Sally 555 32000 555126 Johnson, John 501 38000 001127 Smith, Jim 555 30000 555

    SQL Table or View or DDS Physical or Logical File

    Cobol

    …STARTREAD…

    RPG

    …SETLLREAD…

    C or C++

    …RopenRread…

    Native Interfaces SQL Interfaces

    Extended Dynamic Remote SQL (XDA)

    JDESAP…

    Distributed Relational Database (DRDA)

    JDBC ODBC.NET ADO

    Cobol

    …EXEC SQLFETCH

    …EXEC SQLFETCH

    …EXEC SQLFETCH

    RPG C or C++DB2 Connect Drivers

    Host Server (ZDA)

    IBM i Access Drivers

    JDBC ODBC.NET ADO

    IBM i Access Optimized APIs

    Distributed Data Management (DDM

    Cobol

    …STARTREAD…

    RPG

    …SETLLREAD…

    C or C++

    …RopenRread…

    JDBC

    Toolbox JDBC DriverNative JDBC Driver

    Cobol

    …EXEC SQLFETCH

    …EXEC SQLFETCH

    …EXEC SQLFETCH

    RPG C or C++

    Embedded SQL

    CLI

    Cobol

    …SQLExecDirectSQL FETCH…

    …SQLExecDirectSQLFETCH…

    …SQLExecDirectSQLFETCH…

    RPG C or C++

    Cobol

    …QSQPRCED…

    …QSQPRCED…

    …QSQPRCED…

    RPG C or C++

    QSQPRCEDAPI

    Commands & APIs

    RUNSQL, RUNSQLSTM, STRQRY, CRTDUPOBJ, etc…

    • Attached to your

    Db2 for i files

    • Enforced by the

    database

    • Easier and cheaper

    to define, test, and

    extend

    • Safe and secure

  • © 2018 IBM Corporation

    Cognitive Systems

    6

    Data-centric enhancements in IBM i 7.2 & IBM i 7.3

    • Everything in IBM i 7.2 is also available in IBM i 7.3

    Temporal Tables Generated Columns for Auditing DB2 SMP –

    Parallel execution of OLAP

    Row Permissions Column Masks Media Preference Memory Preference EVI Only Access

    IBM i 7.2 IBM i 7.3

  • © 2018 IBM Corporation

    Cognitive Systems

    7

    Data-centric enhancements in IBM i 7.2 & IBM i 7.3

    • Everything in IBM i 7.2 is also available in IBM i 7.3

    Temporal Tables Generated Columns for Auditing DB2 SMP –

    Parallel execution of OLAP

    Row Permissions Column Masks Media Preference Memory Preference EVI Only Access

    IBM i 7.2 IBM i 7.3

    Applies to SQL Table and DDS Created Physical Files

  • © 2018 IBM Corporation

    Cognitive Systems

    8

    Enhancements delivered via Db2 PTF Groups

    www.ibm.com/developerworks/ibmi/techupdates/db2/groupptf

    2017 2018

    7.2 – TR57.3 – TR1

    7.2 – TR67.3 – TR2

    Enhancements timed with TR2 & TR6

    • JSON predicates

    • Additional Database features in ACS

    • New and enhanced SQL Scalar

    Functions

    • New IBM i Services

    • Enhanced Db2 for i Services

    • And more…

    SF99702 Level 14SF99703 Level 3

    Enhancements timed with TR1 & TR5

    • JSON_TABLE()

    • INCLUDE for SQL Routines

    • Database features in ACS

    • Faster Scalar Functions

    • More IBM i Services

    • New Db2 for i Services

    • And much more…

    SF99702 Level 16SF99703 Level 4

    SF99702 Level 19SF99703 Level 7

    7.2 – TR77.3 – TR3

    Enhancements timed with TR3 & TR7

    • JSON publishing functions

    • Db2 for i generated syslog data

    • More LIMIT & OFFSET support

    • Additional Database features in

    ACS

    • New IBM i Services

    • And more…

    http://www.ibm.com/developerworks/ibmi/techupdates/db2/groupptf

  • © 2018 IBM Corporation

    Cognitive Systems

    9

    Db2 Web Query Version 2.2.1• Steps beyond traditional Business Intelligence into Data Discovery

    – New data driven Visualization empowers: Users, Analysts, and Data scientists

    – Data layers (e.g., demographics) for geographic mapsWhat is the average income in this zip code?

    • Consolidate, Prepare, and Transform Data with DataMigrator ETL

    – Even augment existing data with data from Watson

    • Install or upgrade in 15 minutes with the “EZ-Install” Package Includes 100’s of sample reports, for the business and I/T

    Learn more at ibm.biz/db2webqueryi& db2webqueryi.blogspot.com

    GA 12/08/2017No Charge Upgrade from previous versions**

    * QRY/400 owners entitled to Web Query Express w/ limited # of user licenses for no charge** Assumes currency on SW Maintenance

    ibm.biz/db2webqueryidb2webqueryi.blogspot.comhttps://webfocusinfocenter.informationbuilders.com/wfbue/videos/Retail_Samples/Visualizations/sales_by_country_and_product.mp4https://webfocusinfocenter.informationbuilders.com/wfbue/videos/Retail_Samples/Visualizations/sales_by_country_and_product.mp4

  • © 2018 IBM Corporation

    Cognitive Systems

    10

    LIMIT and OFFSET

    • Full support in the SQL Query Engine (SQE)– Supported in all selects including subqueries and derived tables– Allowed in views (not at the outermost level) and MQTs– Offset and Limit row count can be zero or an expression

    ---- Process a window of data--SELECT * FROM cartonsWHERE palletid = :from_pallet_IDOFFSET :page_countLIMIT IFNULL(:move_quantity, 10);

    SQE

  • © 2018 IBM Corporation

    Cognitive Systems

    11

    DELETE and UPDATE pagination

    • Use ORDER BY, OFFSET and LIMIT on DELETE and UPDATE

    SQE

    UPDATE cartonsSET palletid = :to_Pallet_IDWHERE palletid = :from_pallet_IDLIMIT :move_quantity;

    DELETE FROM ordersWHERE custid = :cust_IDORDER BY order_time ASCLIMIT :max_rows_to_delete;

  • © 2018 IBM Corporation

    Cognitive Systems

    12

    Ask a Question… get an Answer…

  • © 2018 IBM Corporation

    Cognitive Systems

    13

    Ask a Question… get an Answer…

    Hi Scott, Hope you are doing well.

    I‘m struggling with sql and try to convert a char(14) column to timestamp :)

    The string looks like 01122018073421 and I want 2018-01-12-07.34.21.000000

    Please advice. Have a nice evening.

  • © 2018 IBM Corporation

    Cognitive Systems

    14

    Ask a Question… get an Answer…

    ---- SQL Built-ins can work magic--SELECT

    TIMESTAMP_FORMAT( '01122018073421', 'MMDDRRRRHHMISS') AS MY_TIME_HAS_COME

    FROM SYSIBM.SYSDUMMY1;

  • © 2018 IBM Corporation

    Cognitive Systems

    15

    Ask a Question… get an Answer…

    If a butterfly flaps its wings in Texas…

    www.itjungle.com/2018/03/26/guru-more-date-and-time-conversions-using-sql

    http://www.itjungle.com/2018/03/26/guru-more-date-and-time-conversions-using-sql

  • © 2018 IBM Corporation

    Cognitive Systems

    16

    Maximize your Return On Investment

    www.ibm.com/developerworks/ibmi/techupdates/db2

    http://www.ibm.com/developerworks/ibmi/techupdates/db2

  • © 2018 IBM Corporation

    Cognitive Systems

    17

    Access Client Solutions – Why use it?

    Strategic solution for Accessing and Managing your IBM i Runs on:

    WindowsMac Linux – All distributions

    Database tools The “best” 5250 Emulator Integrated File System Print

  • © 2018 IBM Corporation

    Cognitive Systems

    18

    Access Client Solutions – Why use it?

    IBM i Access for Windows (5733XE1) End of Life April, 2019

  • © 2018 IBM Corporation

    Cognitive Systems

    19

    Access Client Solutions – What version are you using?

    Stay current!ACS is updated 3-4 times per year

  • © 2018 IBM Corporation

    Cognitive Systems

    20

    Access Client Solutions – What version are you using?

    Stay current!Use the ‘Check for Updates’ action

  • © 2018 IBM Corporation

    Cognitive Systems

    21

    Access Client Solutions – How popular is it?

    Who is using ACS? Some admins download

    & deploy to all users

    20168167 downloads

    5879 users

    2017 36733 downloads

    20045 users

    Through Feb 2018 6702 downloads

    5323 users

  • © 2018 IBM Corporation

    Cognitive Systems

    22

    ACS Version 1.1.7.2 (released October 27,2017)

    • Database Maintenance– Alter Tables

    – Index Builds

    – Reorganize Physical File Member

    – Other long running DB operations

    • Schemas– More actions

    – More columns for Tables

    • Run SQL Scripts– Custom Border Settings

    – More Insert from Examples

  • © 2018 IBM Corporation

    Cognitive Systems

    23

    ACS Version 1.1.8.x (planned for June, 2018)

  • © 2018 IBM Corporation

    Cognitive Systems

    24

    Access Client Solutions – Don’t have it?

    Download it here:

    http://ibm.biz/IBMi_ACS

    http://ibm.biz/IBMi_ACS

  • © 2018 IBM Corporation

    Cognitive Systems

    25

    IBM i Services Timeline

    2017

    Services in 2016:

    • HISTORY_LOG_INFO

    • JOB_INFO

    • OUTPUT_QUEUE_INFO

    • AUTHORITY_COLLECTION

    • Many enhanced services

    2018

    Services in 1Q/2017:

    • OBJECT_PRIVILEGES

    • MESSAGE_QUEUE_INFO

    • LICENSE_EXPIRATION_CHECK

    • Enhanced USER_INFO

    • Enhanced LICENSE_INFO

    • AUTHORIZATION_LIST_INFO

    • AUTHORIZATION_LIST_USER_INFO

    7.2 – TR57.3 – TR1

    7.2 – TR67.3 – TR2

    7.2 – TR77.3 – TR3

    Services in 4Q/2017:

    • Syslog detail returned from

    DISPLAY_JOURNAL &

    HISTORY_LOG_INFO

    • ASP_INFO

    • ASP_VARY_INFO

    • JOB_QUEUE_INFO

    • STACK_INFO

    • And more…

    http://ibm.biz/Db2foriServices

    http://ibm.biz/DB2foriServices

  • © 2018 IBM Corporation

    Cognitive Systems

    PTF Services

    QSYS2.GROUP_PTF_INFO – VIEW

    QSYS2.PTF_INFO – VIEW

    SYSTOOLS.GROUP_PTF_CURRENCY – VIEW

    SYSTOOLS.GROUP_PTF_DETAILS – VIEW

    http://ibm.biz/Db2foriServices

    http://www.ibm.com/developerworks/ibmi/techupdates/db2/landscape

    Security Services

    QSYS2.AUTHORITY_COLLECTION – VIEW

    QSYS2.AUTHORIZATION_LIST_INFO – VIEW

    QSYS2.AUTHORIZATION_LIST_USER_INFO – VIEW

    QSYS2.DRDA_AUTHENTICATION_ENTRY_INFO – VIEW

    QSYS2.FUNCTION_INFO – VIEW

    QSYS2.FUNCTION_USAGE – VIEW

    QSYS2.GROUP_PROFILE_ENTRIES – VIEW

    QSYS2.OBJECT_PRIVILEGES – VIEW

    QSYS2.SQL_CHECK_AUTHORITY – UDF

    QSYS2.USER_INFO – VIEW

    SYSPROC.SET_COLUMN_ATTRIBUTE – PROCEDURE

    Communication Services

    QSYS2.NETSTAT_INFO – VIEW

    QSYS2.NETSTAT_INTERFACE_INFO – VIEW

    QSYS2.NETSTAT_JOB_INFO – VIEW

    QSYS2.NETSTAT_ROUTE_INFO – VIEW

    QSYS2.SERVER_SBS_ROUTING – VIEW

    QSYS2.SET_SERVER_SBS_ROUTING – PROCEDURE

    QSYS2.TCPIP_INFO – VIEW

    SYSIBMADM.ENV_SYS_INFO – VIEW

    Work Management Services

    QSYS2.ACTIVE_JOB_INFO – UDTF

    QSYS2.GET_JOB_INFO – UDTF

    QSYS2.JOB_INFO – UDTF

    QSYS2.JOB_QUEUE_INFO – VIEW

    QSYS2.MEMORY_POOL – UDTF

    QSYS2.MEMORY_POOL_INFO – VIEW

    QSYS2.OBJECT_LOCK_INFO – VIEW

    QSYS2.RECORD_LOCK_INFO – VIEW

    QSYS2.SCHEDULED_JOB_INFO – VIEW

    QSYS2.SYSTEM_STATUS – UDTF

    QSYS2.SYSTEM_STATUS_INFO – VIEW

    QSYS2.SYSTEM_VALUE_INFO – VIEW

    System Health ServicesQSYS2.SYSLIMITS – VIEW

    QSYS2.SYSLIMTBL – TABLE

    Application Services

    Journal Services

    QSYS2.DISPLAY_JOURNAL – UDTF

    QSYS2.JOURNAL_INFO – VIEW

    Storage Services

    QSYS2.ASP_INFO – VIEW

    QSYS2.ASP_VARY_INFO – VIEW

    QSYS2.MEDIA_LIBRARY_INFO – VIEW

    QSYS2.SYSDISKSTAT – VIEW

    QSYS2.SYSTMPSTG – VIEW

    QSYS2.USER_STORAGE – VIEW

    IBM® i Services

    QSYS2.ENVIRONMENT_VARIABLE_INFO – VIEW

    QSYS2.QCMDEXC – PROCEDURE

    QSYS2.SERVICES_INFO – TABLE

    QSYS2.SET_PASE_SHELL_INFO – PROCEDURE

    QSYS2.STACK_INFO – UDTF

    Librarian Services

    QSYS2.LIBRARY_LIST_INFO – VIEW

    QSYS2.OBJECT_STATISTICS – UDTF

    Message Handling Services

    QSYS2.HISTORY_LOG_INFO – UDTF

    QSYS2.JOBLOG_INFO – UDTF

    QSYS2.MESSAGE_QUEUE_INFO – VIEW

    QSYS2.REPLY_LIST_INFO – VIEW

    Java Services

    QSYS2.JVM_INFO – VIEW

    QSYS2.SET_JVM – PROCEDURE

    IBM i Services

    QSYS2.LICENSE_INFO – VIEW

    SYSTOOLS.LICENSE_EXPIRATION_CHECK – PROCEDURE

    QSYS2.OUTPUT_QUEUE_ENTRIES – VIEW

    QSYS2.OUTPUT_QUEUE_ENTRIES – UDTF

    QSYS2.OUTPUT_QUEUE_INFO – VIEW

    Product Services

    Spool Services

    http://ibm.biz/Db2foriServiceshttp://www.ibm.com/developerworks/ibmi/techupdates/db2/landscape

  • © 2018 IBM Corporation

    Cognitive Systems

    27

    ASP_VARY_INFO

    • Alternative to the Display ASP Status (DSPASPSTS) command• Detail available for the 64 most recent operations, per iASP

    ---- Review the most expensive steps in-- recent iASP vary ON operations--SELECT v.* FROM qsys2.asp_vary_info v WHERE OPERATION_TYPE = 'VARY ON'AND END_TIMESTAMP >

    CURRENT TIMESTAMP – 7 DAYS ORDER BY duration DESC;

  • © 2018 IBM Corporation

    Cognitive Systems

    28

    ASP_INFO

    • Alternative to the Work with Configuration Status (WRKCFGSTS) command and Open List of ASPs (QYASPOL) API

    • Existing interfaces return less detail and are harder to consume

    select * from qsys2.asp_info;

  • © 2018 IBM Corporation

    Cognitive Systems

    29

    syslog – Powered by Db2 for i

    • syslog lets you plug your IBM i into your Security Information Event Management (SIEM) providing a holistic approach to IT security

    Syslog

    SIEM

  • © 2018 IBM Corporation

    Cognitive Systems

    30

    syslog – Powered by Db2 for i

    • History log and Audit Journal, returned in syslog format• Use DISPLAY_JOURNAL() or HISTORY_LOG_INFO() optional

    parameters and new return columns• User controlled output format:

    – RFC3164 tools.ietf.org/html/rfc3164– RFC5424 tools.ietf.org/html/rfc5424

    tools.ietf.org/html/rfc3164tools.ietf.org/html/rfc5424

  • © 2018 IBM Corporation

    Cognitive Systems

    31

    syslog – Audit Journal example

    SELECT SYSLOG_EVENT, SYSLOG_SEVERITY FROM table(qsys2.display_journal('QSYS', 'QAUDJRN',

    JOURNAL_CODES => 'T', JOURNAL_ENTRY_TYPES => 'AF,PW',STARTING_TIMESTAMP => CURRENT DATE,GENERATE_SYSLOG => 'RFC5424')) J;

  • © 2018 IBM Corporation

    Cognitive Systems

    32

    syslog – Powered by Db2 for i

    • Extensive audit journal entry type support: (30 of 70)AD – Auditing ChangeAF – Authority FailureAX – Row and Column Access ControlCA – Authority ChangesCD – Command StringCO – Create ObjectCP – User Profile ChangesDO – Delete OperationDS – DST security password resetGR – Generic RecordGS – Give Descriptor LD – Link, unlink, or look up directory entryOM – Object move or renameOR – Object RestoreOW – Ownership Change

    PA – Program Adopt PG – Change of an object’s primary groupPW – Invalid passwordRA – Authority change during restoreRJ – Restoring Job Description RO – Change of object owner during restoreRP – Restoring adopted authority program RU – Restoring user profile authorityRZ – Changing a primary group during restoreSE – Change of Subsystem Routing Entry SO – Server Security User Information Actions ST – Use of service toolsSV – System value changedZC – Object accessed (change)ZR – Object accessed (read)

  • © 2018 IBM Corporation

    Cognitive Systems

    33

    syslog – History Log example

    SELECT SYSLOG_EVENT, SYSLOG_SEVERITY, SEVERITY, MESSAGE_TYPE

    FROM table(qsys2.history_log_info( GENERATE_SYSLOG => 'RFC3164')) J

    order by SYSLOG_SEVERITY ASClimit 1000;

  • © 2018 IBM Corporation

    Cognitive Systems

    34

    i Can – Read about Db2 for i support for syslog

    ibmsystemsmag.com/blogs/i-can/november-2017/ibm-i-embraces-syslog/

    http://ibmsystemsmag.com/blogs/i-can/november-2017/ibm-i-embraces-syslog/

  • © 2018 IBM Corporation

    Cognitive Systems

    35

    JSON support in Db2 for i

    Db2 JSON Store

    June

    2015

    JSON_TABLE()

    November

    2016

    JSON Predicates:• IS JSON• JSON_EXISTS

    JSON Scalar functions:• JSON_QUERY• JSON_VALUEJSON Publishing functions:• JSON_ARRAY• JSON_ARRAYAGG• JSON_OBJECT• JSON_OBJECTAGG

    March

    2017

    October

    2017

  • © 2018 IBM Corporation

    Cognitive Systems

    36

    Consuming web services with Db2 for i

    IBM i 7.1 and higher

    IBM i 7.2 and higherOctober, 2016

  • © 2018 IBM Corporation

    Cognitive Systems

    37

    Publishing web services with Db2 for i

    IBM i 7.1 and higher

    IBM i 7.2 and higherOctober, 2017

  • © 2018 IBM Corporation

    Cognitive Systems

    38

    JSON Programming in SQL

    www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/sqlp/rbafyjson.htm

    • Say something goodabout our documentation!

    http://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/sqlp/rbafyjson.htm

  • © 2018 IBM Corporation

    Cognitive Systems

    39

    JSON Publishing – Turn a table into JSON

    values coolstuff.generate_json_for_a_table(p_schema_name => 'SHOESTORE', p_table_name => 'EMPLOYEE',p_pagination => default);

  • © 2018 IBM Corporation

    Cognitive Systems

    40

    JSON Publishing – Turn a table into JSON

    values coolstuff.generate_json_for_a_table(p_schema_name => 'SHOESTORE', p_table_name => 'EMPLOYEE',p_pagination => default);

    Look at the companion SQL script for details

  • © 2018 IBM CorporationApril, 2018

    Db2 for i and Watson Services

  • © 2018 IBM Corporation

    Cognitive Systems

    42

    Watson and Db2 for i

  • © 2018 IBM Corporation

    Cognitive Systems

    43

    Watson and Db2 for i

  • © 2018 IBM Corporation

    Cognitive Systems

    44

    Questions?

  • Cognitive Systems

    dank je

    45