Quantcast
Channel: Srinimf » SQL statements
Viewing all articles
Browse latest Browse all 2

1 More Addition Of Global Variables in DB2 V11

$
0
0
COBOL+JCL+Mainframe+Jobs

COBOL+JCL+Mainframe+Jobs

Traditionally within a relational database system, most interactions between an application and the DBMS are in the form of SQL statements within a connection.

To share information between SQL statements within the same application context, the application that issued the SQL statements has to do this work by copying the values from the output arguments, such as host variables, of one statement to the input host variables of another. Similarly, when applications issue host-language calls to another application, host variables need to be passed among applications as input or output parameters for the applications to share common variable. Furthermore, SQL statements that are defined and contained within the DBMS, such as the SQL statements in the trigger bodies, cannot access this shared information.

Mainframe+DB2+Jobs | CLOUD+IT+JOBS | Bigdata+JOBS

These restrictions limit the flexibility of relational database systems and, thus, the ability of users of such systems to implement complex, interactive models within the database itself. Users of such systems are forced to put supporting logic inside their applications to access and transfer user application information and internal database information within a relational database system. Ensuring the security of the information that is transferred and accessed is also left to the user to enforce in their application logic.

How to create global variables?

CREATE VARIABLE BATCH_START_TS TIMESTAMP
DEFAULT CURRENT TIMESTAMP;


The new SYSIBM.SYSVARIABLES table includes one row for each global variable that is created.

The new SYSIBM.SYSVARIABLEAUTH table includes one row for each privilege of each authorization ID that has privileges on a global variable.

The SYSIBM.SYSVARIABLES_TEXT table is an auxiliary table for the DEFAULTTEXT column of the SYSIBM.SYSVARIABLES table.

How a global variable response can be accessed in different contexts?

— Initial execution of the SQL
SELECT BATCH_START_TS, CURRENT TIMESTAMP
FROM SYSIBM.SYSDUMMY1
;
— Result set from the initial execution
BATCH_START_TS CURRENT TIMESTAMP
2013-08-02-14.59.46.423414 2013-08-02-14.59.46.423414
— Second execution of the same SQL statement in the same SPUFI session

SELECT BATCH_START_TS, CURRENT TIMESTAMP
FROM SYSIBM.SYSDUMMY1
;
— Result set from the second execution
BATCH_START_TS CURRENT TIMESTAMP

2013-08-02-14.59.46.423414 2013-08-02-14.59.46.424678

— Third execution of the same SQL statement in the same SPUFI session

SELECT BATCH_START_TS, CURRENT TIMESTAMP
FROM SYSIBM.SYSDUMMY1
;
— Result set from the third execution
BATCH_START_TS CURRENT TIMESTAMP

 


Filed under: Big Data, Cloud, DB2, DB2 V11, Mainframe Tagged: Global Variables in DB2 V11, relational database system, SQL statement, SQL statements

Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images