Solved

Declaring variables

Posted on 2006-06-27
2
1,782 Views
Last Modified: 2008-03-03
I normally use MSSQL and am not as familiar with DB2.  In MSSQL, I can declare and set variables like this:

DECLARE @begdate DECIMAL(8,0)
DECLARE @enddate DECIMAL(8,0)

SET @begdate = '20060101'
SET @enddate = '20060626'

How would I do the same thing in DB2?

I am trying to run an SQL statement against an i5 database using iSeries Navigator.

Thanks.

Derrick
0
Comment
Question by:dnsvh
2 Comments
 
LVL 45

Accepted Solution

by:
Kdo earned 250 total points
ID: 16996443
Hi  Derrick,

You can't create DB2 variables in most SQL client interfaces.  You'll have to code a Stored Procedure or Function to do that.

But the syntax is similar:

  DELARE NAME VARCHAR(24);


Kent
0
 
LVL 4

Author Comment

by:dnsvh
ID: 16996447
Thanks, Kent.
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
teradata sql olap functions 2 274
db2 connect on mac 3 490
Tsm library capacity monitor warning 5 167
How to create a stored procedure in AS400 1 51
November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

932 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now