Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Declaring variables

Posted on 2006-06-27
2
Medium Priority
?
1,805 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 46

Accepted Solution

by:
Kent Olsen earned 1000 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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

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

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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses
Course of the Month13 days, 1 hour left to enroll

972 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