473,626 Members | 3,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to pass a parameter to a view?

Hi Everyone,

Is there an easy way that I could pass a filter (variable) unto a view
via stored procedures? I would appreciate your suggestions.

Benito
Jul 20 '05 #1
3 78651

"Benito" <be*******@juno .com> wrote in message
news:5c******** *************** ***@posting.goo gle.com...
Hi Everyone,

Is there an easy way that I could pass a filter (variable) unto a view
via stored procedures? I would appreciate your suggestions.

Benito


Views cannot take parameters, but if you are using MSSQL 2000, then a
table-valued UDF is one solution:

create function dbo.MyFunc (@parm int)
returns table
as
return (
select col1, col2
from dbo.MyTable
where idcol > @parm
)

select col1, col2 from dbo.MyFunc(5)

There are examples in Books Online. If you have an earlier version of MSSQL,
then you'll have to use a stored procedure.

Simon
Jul 20 '05 #2
>> Is there an easy way that I could pass a filter (variable) unto a
view
via stored procedures? <<

VIEWs are virtual tables; they do not have parameters. Stored
procedures do take parameters and can return a resultset.
Jul 20 '05 #3
Simon,

Thanks for the suggestion. I am using MSSQL 2000. When creating a new
view at Enterprise Manager, I don't see the function I created at the
function tab of the Add Table Dialog Box. What I am trying to do is
store the filter in the function in the form of a variable then link
it to an existing view. Is this possible?

Benito

"Simon Hayes" <sq*@hayes.ch > wrote in message news:<3f******* *@news.bluewin. ch>...
"Benito" <be*******@juno .com> wrote in message
news:5c******** *************** ***@posting.goo gle.com...
Hi Everyone,

Is there an easy way that I could pass a filter (variable) unto a view
via stored procedures? I would appreciate your suggestions.

Benito


Views cannot take parameters, but if you are using MSSQL 2000, then a
table-valued UDF is one solution:

create function dbo.MyFunc (@parm int)
returns table
as
return (
select col1, col2
from dbo.MyTable
where idcol > @parm
)

select col1, col2 from dbo.MyFunc(5)

There are examples in Books Online. If you have an earlier version of MSSQL,
then you'll have to use a stored procedure.

Simon

Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
23968
by: Tony Johansson | last post by:
Hello! I use method forName and newInstance in class Class like this instance = (GameFactory)(Class.forName(name).newInstance() ); Now to my question: Assume that name is GameFactory then I want to pass a parameter to the GameFactory constructor like this instance = (GameFactory)(Class.forName(name).newInstance(field) ); Here I pass parameter field which is an int but when I do so I get compile
4
9792
by: dyw55a | last post by:
I have 2 webform in vb.NET application. On Webform1, I have one text box1 and one button. on Webform2, I have one text box . I need transfer the value of textbox 1 in webform1 to textbox2 in webform2. and popup webform2 when user click on the button on webform1. I have code in webform1: Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
1
2239
by: Ray | last post by:
Dear all, How to pass parameter from vb.net to Crystal Report? I'm now using ReportDocument and CrystalReportViewer. However, I don't know how to pass a parameter to the report and print the parameter in the report. Please help. Thanks a lot, Ray
1
1373
by: jindo | last post by:
Hi There! I must stresstest webservices. So I used parameter Like this 'http://aaa.bbb.ccc/services/BoardFD.asmx?op=showTable&IDno=96&tab=900'. but the parameters are not passed. how to pass parameter to webservices.... Plz Help ..
4
1429
by: Chakravarti Mukesh | last post by:
Hi I want to call an application and also need to pass some parameter for it. I use System.Diagnostics.Process.Start("application_path") and it runs perfectly. But when I pass paramenter like System.Diagnostics.Process.Start("application_path -parameter1 -parameter2") it says that the file doesn't exist. How should I pass parameter?
1
5088
by: Tarlanim | last post by:
Hi, i'm looking for a way to pass parameter from a HTML-File to a XML-File. In HTML-File i have a reference to XML-File and i want to use the parametre from the HTML-File in XML-File (Parameter from callig HTML instead of "1234567" and "mike" in XML-File) . ******* XML-File <?xml version="1.0" encoding="iso-8859-1" ?> <?xml-stylesheet href="styles_arzt.xsl" type="text/xsl" ?>
0
1596
by: Ed Dror | last post by:
Hi there, I'm using Visual studio 2005 pro and I want to pass parameter from datagrid selected cell to textbox I have Select button in my datagrid I wrote this Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound Try
15
3517
vinvik
by: vinvik | last post by:
hi am calling one exe from java script using window.open.. now i need to pass parameter to that exe.. and that exe accepts the parameter from command line using(variable=command$).. now how i can pass parameter to that exe through javascript.. plz solve.. thanx....
3
5276
by: wingsganesh | last post by:
Hi Buddy, see my small example, Public Sub myPaint(ByVal e As System.Windows.Forms.PaintEventArgs) e.Graphics.DrawString(" MichaelAyvazyan", Font, New SolidBrush(Color.Beige), 100, 100) End Sub
1
9647
by: 2desperate2usedesperate | last post by:
ERROR: You do not have SELECT privileges on sys.V_$PARAMETER view. This process cannot proceed. Hello, I am using ORACLE 10g Standard Edition and I am trying to configure the Oracle Designer for which a repository must be installed. The following is the procedure I am following: START > PROGRAMS > ORACLE DEVELOPER SUITE –DevSuite1 >
0
8269
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8203
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8711
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4206
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1515
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.