Example Of Explain Statement Using Odbc; Example Of Explain Statement Using Jdbc - HP Neoview SQL Reference Manual

Hide thumbs Also See for Neoview SQL:
Table of Contents

Advertisement

Example of EXPLAIN Statement Using ODBC

Suppose an application prepares a SELECT statement: "SELECT * FROM
ODBC_PERSNL.EMPLOYEE". Use SQLGetCursorName to find the statement name. In this
example, the returned statement name is "SQL_CUR_21".
To get the plan for "SELECT * FROM ODBC_PERSNL.EMPLOYEE", the application must allocate
another statement handle and issue SQLExecDirect on "EXPLAIN options 'f' SQL_CUR_21".
The plan is returned as a result-set. Use SQLFetch to retrieve the result.
SQLPrepare: StatementText = " SELECT * FROM ODBC_PERSNL.EMPLOYEE;"
SQLGetCursorName: Out:*CursorName = "SQL_CUR_21"
SQLAllocHandle: HandleType = SQL_HANDLE_STMT=3
SQLExecDirect: StatementText = "EXPLAIN options 'f' "SQL_CUR_21"
SQLPrepare:
In: StatementHandle = 0x003B1A10,
StatementText = "select * from odbc_persnl.employee;", TextLength = 35
Return: SQL_SUCCESS=0
SQLGetCursorName:
In: StatementHandle = 0x003B1A10, CursorName = 0x001577E8,
BufferLength = 300, NameLengthPtr = 0x001552C0
Return:
SQL_SUCCESS=0
Out:
*CursorName = "SQL_CUR_3", *NameLengthPtr = 9
SQLAllocHandle:
In: HandleType = SQL_HANDLE_STMT=3, InputHandle = 0x003B1908,
OutputHandlePtr = 0x00157F68
Return:
SQL_SUCCESS=0
Out:
*OutputHandlePtr = 0x003B2FF0
SQLExecDirect:
In: Statementhandle = 0x003B2FF0,
StatementText = "explain options 'f' SQL_CUR_3", Statementlength = 29
Return: SQL_SUCCESS=0
Get Data All:
"EXPLAIN OUTPUT(FORMATTED)"
" "
"LC
RC
OP
"---
---
---
" "
"3
.
4
"2
.
3
"1
.
2
".
.
1
8 rows fetched from 1 column.

Example of EXPLAIN Statement Using JDBC

import common.*;
import java.sql.*;
public class j1
{
public static void main(String args[])
{
Connection
Statement
PreparedStatement
ResultSet
DatabaseMetaData
int
String table
String sqlText = "explain select * from " + table;
try
{
connection = expUtils.getPropertiesConnection();
132
SQL Statements
OPERATOR
--------------------
root
split_top
partition_access
file_scan
connection;
stmt;
pStmt;
rs;
dbMeta;
rowNo;
= "cat_expR2.sch_expR2.nation";
OPT
DESCRIPTION
--------
--------------------
1:64(hash2)
fs fr
EMPLOYEE
CARD
"
---------"
1.76E+003"
1.76E+003"
1.76E+003"
1.76E+003"

Advertisement

Table of Contents
loading

Table of Contents