Page 1 of 1

Simulating the EXPLAIN of an embedded SQL statement

PostPosted: Mon Oct 28, 2013 11:09 pm
by nikesh_rai
Hi Guys,

I got a question on net asked by an interviewer that how to simulate the EXPLAIN of an embedded SQL statements in SPUFI/QMF.
Everywhere I got the same answer with same query without any explanation.. :) (seems like copy-paste nothing else)

Use a question mark in place of a host variable (or an unknown value), e.g.
SELECT EMP_NAME
FROM EMP
WHERE EMP_SALARY >?


Can anyone please suggest me on this or explain me how a question mark can simulate EXPLAIN and before that if this answer is correct or not. Actually I was checking Mullin's developers guide.. but I didn't get anything about EXPLAIN on embedded SQL. So please suggest.. :)

Re: Simulating the EXPLAIN of an embedded SQL statement

PostPosted: Thu Nov 21, 2013 10:19 pm
by nikesh_rai
yet to get replies.. :(

Re: Simulating the EXPLAIN of an embedded SQL statement

PostPosted: Fri Nov 22, 2013 2:13 am
by dick scherrer
Hello,

What happens when you try this?

Re: Simulating the EXPLAIN of an embedded SQL statement

PostPosted: Fri Nov 22, 2013 9:31 am
by nikesh_rai
Currently I don't have access to mainframe.. so couldn't check it..

Re: Simulating the EXPLAIN of an embedded SQL statement

PostPosted: Mon Sep 08, 2014 5:53 pm
by nikesh_rai
Hi,

If anyone knows about it, please help me.

Re: Simulating the EXPLAIN of an embedded SQL statement

PostPosted: Thu Nov 27, 2014 12:54 am
by alexm
Hi nikesh_rai,

you cannot simulate an EXPLAIN of an SQL statement, nor a question mark somewhere in an SQL statement simulates an EXPLAIN.

Provided you have access to a set of Explain Tables, you can execute an EXPLAIN statement for an explainable SQL statement.

E.g., to explain "SELECT IBMREQD FROM SYSIBM.SYSDUMMYE WHERE IBMREQD > ?" you would use something similar to
EXPLAIN PLAN SET QUERYNO=1234 FOR
SELECT IBMREQD                   
FROM   SYSIBM.SYSDUMMYE           
WHERE  IBMREQD > ?               

You can use this in Spufi, QMF, DSNTEP2, in your application program, wherever.
The output of that EXPLAIN is stored in the Explain Tables, from where you can query it, see Interpreting data access by using EXPLAIN

NB-1: In your context, the question mark is a parameter marker. Parameter markers are replaced by the values of host variables when the statement is executed. You may want to look at the Application Programming and SQL Guide for some related information.
NB-2: all links address DB2 10 for z/OS manuals.

Re: Simulating the EXPLAIN of an embedded SQL statement

PostPosted: Thu Nov 27, 2014 8:44 pm
by nikesh_rai
Thanks a lot Alexm.. :)