[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

DB2 SQL - How can I provide for a variable substitution in my SQL where clause?

Posted on 2012-12-31
6
Medium Priority
?
1,366 Views
Last Modified: 2013-01-09
Hi All,

I need to be able to substitute  two variables in this simple SQL code:

The JCL:
//SETVAR SET SSNODE=DBO1,DBOI=P1,DBOO=D2,
//           TRK=OG1,LOADIR=TEST,
//           PARMDIR=OGDBA,
//           PDBNAME='OG1DD%1',  <<-----Database name
//           PTSNAME='OG1SC%'       <<-----Tablespace Name

//SYSTSIN DD *
  DSN SYSTEM(DBO1) RETRY(3)
  RUN   PROGRAM(DSNTIAUL) PLAN(DSNTIB81) -
       LIB('SYS2.DB2.TEST.RUNLIB.LOAD') PARMS('SQL')
  END
/*
//SYSIN    DD *
  SELECT '-START DB('||DBNAME||') SPACENAM('||NAME||') ACCESS(UT)'  <<<------SQL
  FROM SYSIBM.SYSTABLESPACE
  WHERE DBNAME LIKE %PDBNAME
  AND NAME LIKE           %PTSNAME

//           PDBNAME='OG1DD%1',  <<-----Database name
//           PTSNAME='OG1SC%'       <<-----Tablespace Name


How can make this work?  I am getting errors every which way I try!

Your expert help will be highly appreciated
0
Comment
Question by:Enyinnaya
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 37

Expert Comment

by:momi_sabag
ID: 38733972
there is no simple way to do that
you can either write a program that gets those parameters and put them in the sql query and then execute the query or generate the input file for dsntiaul, or you can try to use iebgener to modify the input file for dsntiaiul
0
 

Author Comment

by:Enyinnaya
ID: 38737768
Ok, moni_sabag, could you kindly describe in more detail with example of what or how you will go about doing what you have in mind?



Thanks
0
 
LVL 37

Expert Comment

by:momi_sabag
ID: 38737795
could you explain what is the point of having those as parameters that are hard coded in the JCL?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:Enyinnaya
ID: 38740640
First, we are do not have many of the avaiable DBMS management toolset available to us so I am not privileged in that regard.
I have several application tracks and the associated databases. I do not want to have to update many many jobs every time a change is made/added/dropped, etc to tablespaces or tables if I want to QUIESCE, or put Tablespaces in utility mode during DB maintenance.

Also, I want to try to use only one Procedure for all my DB2 environments: 6 QA environment and 4 Test environment not to mention my production environments. Each environment has at least 7 applications/database tracks. My good news is that the database and tablespace are identical in almost everyway. By using symbolic substitution method, I can do this easily I believe.

The problem is, and as you so rightfully stated earlier, there is no easy way (or is there?) to get DNSTIAUL to accept parameter substitution the way I have it in the SQL that you saw before.

All I really trying to achieve here is be able to specify a database and/or tablespaces, select all tablespace that I specify and put them in utility mode or return them to read/write at will without doing any hardcoding!.

This SQL works just fine only if I hardcode a database or a tablespace name. I want to substitute to two parameters dynamically.

I hope this help to clarify what I am trying to achieve.

Thanks
0
 

Accepted Solution

by:
Enyinnaya earned 0 total points
ID: 38744337
Ok, I think this question is/was wrongly worded hence the lack of responses or answers. I am going to close it...rephrase the question to more accurately reflect what I need assistance with...no points awarded.

Thanks
0
 

Author Closing Comment

by:Enyinnaya
ID: 38758226
No valid answer, no example...rephrasing the question...
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question