Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Declaring variables

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

How To Install Bash on Windows 10

Windows’ budding partnership with Canonical has certainly led to some great improvements. One of them being the ability to use Bash on your Windows machine without third party applications! This might be one of the greatest things a cloud engineer in a Windows environment can do!

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 (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

664 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