473,406 Members | 2,847 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Set Declared Variables...

4
I'm a SQL Server (T-SQL) developer. I'm used to being able to declare a variable in a stored procedure, and set it using either SET or SELECT.

T-SQL:
DECLARE @variable INT

SET @variable = 10


How do I do the equivalent in DB2 SQL? I've tried about every combination I can think of.

My stored procedure stub:
CREATE PROCEDURE DB.PINVENTORY_TOTALS (
IN VAR_DATE DATE )

DYNAMIC RESULT SETS 1
LANGUAGE SQL
SPECIFIC DB.PINVENTORY_TOTALS
NOT DETERMINISTIC
MODIFIES SQL DATA
CALLED ON NULL INPUT

BEGIN

DECLARE VAR_YEAR INTEGER ;
DECLARE VAR_PERIOD INTEGER ;

DECLARE C_RETURN CURSOR WITH RETURN FOR

SET VAR_YEAR = (SELECT YEAR FROM CALENDAR WHERE VAR_DATE = CALDATE) ;

<Select statement here>

-- Get the result set
OPEN C_RETURN ;

END ;
Jun 4 '07 #1
0 1562

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: harry | last post by:
Hi, During compilation, a C# project in my solution triggers the following warning: "warning CS0168: The variable 'ex' is declared but never used" To trigger this warning, it appears the C#...
1
by: Tim.D | last post by:
People, I've inherited a lot of SP embedded SQL code that makes substantial use of FOR cursors rather than DECLARED, and I am wondering whether there is a significant difference in the...
9
by: thomson | last post by:
Hi all, Would you please explain me where will be the heap stored if it is declared inside the Class, As class is a reference type, so it gets stored on the heap, but struct is a value...
2
by: Nathan Sokalski | last post by:
I would like to access variables and functions that I declare in the Global.asax.vb file. However, I am having trouble doing that. What does the declaration have to look like in the Global.asax.vb...
9
by: Don | last post by:
Say I have a class like so: Public Class MyClass Public Prop1 as Integer Public Prop2 As Integer Public Prop3 As Integer End Class Is it possible to retrieve a list of the variables or...
2
by: robin.bruce | last post by:
Hi guys, I just tried to give advice to a colleague who has a problem program in C, and I was interested to hear the thoughts of this forum on the subject. I've been an occasional programmer...
7
by: Nickolay Ponomarev | last post by:
Assigning to undeclared variables is considered a bad practice (I hope I don't need to explain the reasons here). The examples in the FAQ should declare the variables it uses: ...
3
by: Tyno Gendo | last post by:
I don't really need to do this, but I was wondering. Is there some way of obtaining a list of all the variables that have been declared in a PHP script ? Ie. for globals you have $_GLOBAL, is...
0
by: Gary Herron | last post by:
Jacob Davis wrote: Yuck, YUCK, YUCK! You are breaking *so* many good-programming-practices, I hardly know where to start. First off: A python global is not what you think. There are *no*...
17
by: Juha Nieminen | last post by:
As we know, the keyword "inline" is a bit misleading because its meaning has changed in practice. In most modern compilers it has completely lost its meaning of "a hint for the compiler to inline...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.