Panel Command to Display All DB2 Database Components

Mandalika
Updated on 01-Dec-2020 05:01:29

198 Views

Problem: Give and explain the panel command to display all the components of DB2 database DSNDB01 along with their status.SolutionA DB2 is a relational database which can be visualized to have both physical as well as logical structures. The physical structure contains components like log files, bufferpools, control files etc. On the other logical structure contains components like tablespace, indexspace, tables, views, packages, plans, etc.The components of physical structure have restricted access and only DBAs can access those files. However, it is possible for us to view components of logical structure using any of the below 2 options.Using DB2 administration ... Read More

Get Current Date and Time from the Internet in Android Using Kotlin

Azhar
Updated on 01-Dec-2020 05:01:02

697 Views

This example demonstrates how to get the current date and time from the internet in Android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.             Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import java.text.SimpleDateFormat import java.util.* class MainActivity : AppCompatActivity() {    lateinit var calendar: Calendar    lateinit var simpleDateFormat: SimpleDateFormat    lateinit var date: String    lateinit ... Read More

Bind Multiple Versions of a DB2 Program into a Package

Mandalika
Updated on 01-Dec-2020 04:58:10

886 Views

Packages are DB2 database objects which hold the executable forms of SQLs which are used in COBOL-DB2 programs. The packages are stored in a catalog table and contain the strategy/tables/columns/predicate associated with the SQL statements.If there is a DB2 table ORDERS_TEST in test environment and ORDERS_PROD in production environment, then we need two versions of COBOL-DB2 program (which will access these tables) — one for test and the other for production.Although both programs will be carbon copy of each other, the only difference lies in the SQL statements. The test version of the program will use table ORDERS_TEST in SQL ... Read More

Write Files to Assets Folder in Android Using Kotlin

Azhar
Updated on 01-Dec-2020 04:58:07

1K+ Views

This example demonstrates how to write files to the assets folder in android using Kotlin.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml.             Step 3 − Add the following code to src/MainActivity.ktimport android.os.Bundle import android.widget.Button import android.widget.TextView import androidx.appcompat.app.AppCompatActivity import java.io.IOException import java.io.InputStream class MainActivity : AppCompatActivity() {    lateinit var textView: TextView    lateinit var button: Button    override fun onCreate(savedInstanceState: Bundle?) {       super.onCreate(savedInstanceState) ... Read More

Timestamp Mismatch in DBRM and Load Module

Mandalika
Updated on 01-Dec-2020 04:57:26

895 Views

When the COBOL-DB2 source code is given as an input in the pre-compilation stage, we get 2 important components — DBRM and modified source code.In modified source code, the SQL statements are replaced by COBOL calls and the DBRM contains all the SQL statements which are present in the COBOL-DB2 program. The pre-compiler inserts the timestamp in both DBRM and modified source code.In case of DBRM bind directly to the plan, the system compares the timestamp of the DBRM and load module when the COBOL-DB2 program is executed. In case there is a mismatch in the timestamp the JCL step ... Read More

Concept of Integrity in DB2 and Its Types

Mandalika
Updated on 01-Dec-2020 04:53:43

846 Views

Problem: What is INTEGRITY in a DB2? Explain DOMAIN, ENTITY and REFERENTIAL integrity with the help of an example in ORDERS table.SolutionThe integrity refers to the accuracy, consistency and correctness of data present in the DB2 database. Data integrity is imposed during the database design to make sure that data residing in the database remains complete, accurate and reliable.There are three types of integrity described in below figure.Domain integrityIt ensures that column data in the DB2 table adhere to the permissible set of values. For example, in the ORDERS table, the domain integrity on the ORDER_DATE column ensures that data ... Read More

Find Duplicate Invoice IDs in DB2 Orders Table

Mandalika
Updated on 01-Dec-2020 04:51:10

1K+ Views

The duplicate INVOICE_ID in ORDERS DB2 table can be found by using a combination of GROUP BY with HAVING clause and COUNT function. The GROUP BY will enable us to group the result invoice wise and COUNT function will enable us to count the number of occurrences in each group. We can use predicate in HAVING clause to filter the results for groups having count greater than one.Below is the SQL query which we can use to find duplicate invoices in ORDERS DB2 table.ExampleSELECT INVOICE_ID FROM ORDERS    GROUP BY INVOICE_ID    HAVING COUNT(INVOICE_ID) > 1For example, if we have ... Read More

SQL Query Example: COUNT Function and GROUP BY

Mandalika
Updated on 01-Dec-2020 04:49:56

359 Views

Problem: Write a query on TRANSACTIONS DB2 table to list down the number of orders (ORDER_ID) assigned to a particular transaction (TRANSACTION_ID).SolutionWe can use the below query to find out the number of orders assigned to a particular transaction id on TRANSACTIONS DB2 table.ExampleSELECT TRANSACTION_ID, COUNT(ORDER_ID) FROM TRANSACTIONS    GROUP BY TRANSACTION_IDWe will use GROUP BY function on the ORDER_ID to fetch the result order wise. The COUNT function will count the number of orders. For example, we have below DB2 ORDERS table.TRANSACTION_IDORDER_IDIRN22345A23118IRN22345A45901IRN22345A67990IRN56902A23119IRN99781A67921IRN56902A23167 The result of our DB2 query will return the below result.TRANSACTION_IDCOUNT(ORDER_ID)IRN223453IRN569022IRN997811Read More

Understanding 551 Error Code in DB2 and Its Resolution

Mandalika
Updated on 01-Dec-2020 04:48:36

5K+ Views

When we get -551 in the SQLCODE then there is some privilege level issue. It signifies that the user does not have access to the database/tablespace/view/table that he is trying to access. As per the IBM documentation -551 SQLCODE states that.Example-551 auth-id DOES NOT HAVE THE PRIVILEGE TO PERFORM OPERATION operation ON OBJECT object-nameThere are DCL (Data control language) statements which are used by DBAs in order to control the access on DB2 objects. We can raise a request with DBA to provide access to the particular object for which user is getting -551 SQLCODE.Following DCL statement will give access ... Read More

Difference Between QMF and SPUFI for Accessing DB2 Tables

Mandalika
Updated on 01-Dec-2020 04:47:26

2K+ Views

Both QMF and SPUFI are tools built to access DB2 databases in a mainframe environment. Using these tools, we can SELECT, UPDATE and DELETE the data from the DB2 database. QMF stands for Query Management Facility and SPUFI stands for SQL Processor Using File Input.Below are the differences between QMF and SPUFI.SPUFI is a free tool which comes with mainframe DB2 installation, while QMF is a separate licensed toolQMF is an interactive tool which can be used for reporting and formatting purposes, but in case of SPUFI, we need to write the SQL queries in the mainframe dataset and the ... Read More

Advertisements