If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > View with parameters

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-13-09, 08:50
phil72 phil72 is offline
Registered User
 
Join Date: Nov 2008
Posts: 41
Thumbs up View with parameters

can we create a view with parameters

Example
Table1
code col1 col2 col3
A 1 10 2
B 1 21 3
C 0 4 7
D 0 3 9

View1 :

select case col1 = 1 then paradate + col2 days
else paradate - col3 days as res1 from table1

paradate is parameter i want to pass when quering view

Is this possible using views or i have to write function

Thanks
Reply With Quote
  #2 (permalink)  
Old 02-13-09, 09:12
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Table Function ?
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 02-13-09, 09:14
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
From CREATE VIEW in the manuals :

fullselect
Defines the view. At any time, the view consists of the rows that would result if the SELECT statement were executed. The fullselect must not reference host variables, parameter markers, or declared temporary tables. However, a parameterized view can be created as an SQL table function.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #4 (permalink)  
Old 02-13-09, 12:08
phil72 phil72 is offline
Registered User
 
Join Date: Nov 2008
Posts: 41
Thanks Sathyaram
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On