Solved

Declaring variables

Posted on 2006-06-27
2
1,780 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

11 Experts available now in Live!

Get 1:1 Help Now