Showing posts with label parameter. Show all posts
Showing posts with label parameter. Show all posts

Friday, March 30, 2012

Manage parameter dropdown list

I have an input parameter which has multi-value property checked. It has
dependence on the other input parameter and its value set is getting from
database. So, the number of row change when the other parameter changes. The
problem is the dropdown list sometime works fine, but the other time it
doesn't work as expected. For instance, there is case that there are only
two values in the list and the dropdown list gives me "Select All", first
item and a scroll bar. I need to drag the scroll bar to see the second item.
This is very annoying. The only good thing is that it did work consistently
in the sense of same value set always has same look in the dropdown list.
Is there a way to manage the displayable size of the dropdown list? How
about the input parameter text box length, is there anyway we can have any
control over this?Hi,
As you have mentioned that the "select ALL" comes as the first option and
you need to scroll down for the other two options. I think your query (in the
dataset) for this parameter is having spaces. Just have a look at the query
again and try to eliminate the null / space in your dataset.
Amarnath
"lu" wrote:
> I have an input parameter which has multi-value property checked. It has
> dependence on the other input parameter and its value set is getting from
> database. So, the number of row change when the other parameter changes. The
> problem is the dropdown list sometime works fine, but the other time it
> doesn't work as expected. For instance, there is case that there are only
> two values in the list and the dropdown list gives me "Select All", first
> item and a scroll bar. I need to drag the scroll bar to see the second item.
> This is very annoying. The only good thing is that it did work consistently
> in the sense of same value set always has same look in the dropdown list.
> Is there a way to manage the displayable size of the dropdown list? How
> about the input parameter text box length, is there anyway we can have any
> control over this?
>|||Sorry, if I didn't make it clear. No, what I said was the dropdown list
display first two items which are "Select All" and the first item in the
value set when I have only two items in the value set. Why I need to use
scroll bar to be able to see the second item. The dropdown list should just
have a window big enough to accomodate all three choice which are "Select
All", first item and second item.
"Amarnath" wrote:
> Hi,
> As you have mentioned that the "select ALL" comes as the first option and
> you need to scroll down for the other two options. I think your query (in the
> dataset) for this parameter is having spaces. Just have a look at the query
> again and try to eliminate the null / space in your dataset.
> Amarnath
> "lu" wrote:
> > I have an input parameter which has multi-value property checked. It has
> > dependence on the other input parameter and its value set is getting from
> > database. So, the number of row change when the other parameter changes. The
> > problem is the dropdown list sometime works fine, but the other time it
> > doesn't work as expected. For instance, there is case that there are only
> > two values in the list and the dropdown list gives me "Select All", first
> > item and a scroll bar. I need to drag the scroll bar to see the second item.
> > This is very annoying. The only good thing is that it did work consistently
> > in the sense of same value set always has same look in the dropdown list.
> > Is there a way to manage the displayable size of the dropdown list? How
> > about the input parameter text box length, is there anyway we can have any
> > control over this?
> >
> >sql

Wednesday, March 21, 2012

Make use of an passed XML parameter

I have tested the following code, and it works for me:

DECLARE @.XML XML
SET @.XML = '
<DocumentElement>
<data>
<item code="ABCDEFG" quantity="1" sort="0" />
<item code="XCFVGBF" quantity="1" sort="0" />
<item code="ABCDEFG" quantity="10" sort="0" />
</data>
</DocumentElement>'

SELECT SUM(x.qty * ISNULL(p.price_mn,0))
FROM (SELECT [Code] = A.A.value('@.code','varchar(20)'),
[Qty] = A.A.value('@.quantity','INT')
FROM @.xml.nodes('/DocumentElement/data/item') AS A(A)) X
LEFT JOIN productprice_t P ON p.code_id = x.code

The question is, how can I do this if the XML is in a different format & doesn't use any attributes?
So it looks like this (which I'm getting from an ADO.Net datatable using .WriteXML):
<DocumentElement>
<data>
<code>ABCDEFG</mercurycode>
<quantity>1</quantity>
<sort>0</sort>
</data>
<data>
<mercurycode>XCDFEG</mercurycode>
<quantity>2</quantity>
<sort>0</sort>
</data>
<data>
<code>ABCDEFG</mercurycode>
<quantity>10</quantity>
<sort>0</sort>
</data>
</DocumentElement>Ah, the old stupid question. You do tend to receive one of these every couple of months. On this occasion, I would be delighted to point out the glaring mistake in your question.

The question is, how can I do this if the XML is in a different format & doesn't use any attributes

You would write a new procedure to handle this new XML format. I should ask though, must you really, really use XML for this kind of situation? Would it not be possible to just use tables with rows and columns?|||Ah, the old stupid question. You do tend to receive one of these every couple of months. On this occasion, I would be delighted to point out the glaring mistake in your question.

You would write a new procedure to handle this new XML format. I should ask though, must you really, really use XML for this kind of situation? Would it not be possible to just use tables with rows and columns?

Wow. Your insight has been most helpful! Please elaborate on your suggestion to handle the following;

A user has a shopping cart made up of two columns - Code & Quantity. The code column cannot be unique because the user needs to be allowed to sort and their cart as they see fit. Because of this, we must summarize the data first. The cost cannot be added to the cart at the same time, because for any given product, there are 10 prices, depending on the user, and the sponsor wants to only show preferred pricing. Now I want to take my cart (which can have hundreds of items) and get the total for it. How do you propose I pass this to SQL to get the total of the cart? BTW, the cart is stored as an ADO.NET 2.0 data table.

I figure, why not make use of the .WriteXML function of the dataset? So in a few lines of code, I have it all working with 1 trip to the DB, and it only returns a single output parameter. And fortunately for me, I was able to get things to work before your stellar advice came through.

Seems pretty efficient to me - but PLEASE show me a more efficient away! I surely hope you don’t want me to pass a list of my codes and return a dataset filled with codes & costs, and then have the client app do the math.

Also, try typing in XML & .nodes or XML & .value into the search function here. YOU make use of the results – especially when you are new to XML handling in SQL.|||I answered your question clearly. Perhaps in future I will omit any suggestions for improvements, as you appear to have attacked the suggestion and ignored my answer to your question.

Your question asked, how to use SQL to process an XML document that represents information as the data of elements (of whichever other fancy XML term people use these days) rather than as data contained within an attribute of an element.

The answer I gave was to suggest that you either amend your existing procedure or write a new one to extract the values from the XML document by querying the elements rather than the attributes of the elements. In other words, I suggested that you amend your stored procedure to reflect the changes made to the format of your document. I don't understand the difficulty, unless of course you were asking for the syntax to query an XML node?

If this was the case, then I suggest you do a quick search on Google for information on how to query the data from an XML elements using SQL Server. Because, however, it is trivial to find such information, for example by using the SQL Server reference manual or Google, I came to the conclusion that your question was indeed a trick question, similar to somebody asking how to find information on Google. Perhaps it is now clear as to why I gave a largely flippant reply.

From what I can understand about your requirements, the decision to use XML as the transport mechanism for your shopping cart data appears to be based on the fact that the .NET framework provides an easy to use method for converting the contents of a dataset to an XML stream, which can then be just as easily used as input to a stored procedure. Although this is easy to code, as you already pointed out, have you considered the performance implications and the increase in manual labour that will be required to manage these kinds of procedures?

As the shopping cart data is stored in an in-memory structure, the dataset, and I assume that you do not periodically flush it to the DB, each user's shopping cart will be stored as an XML Document in the memory of the application server. For this to be practical, you will need to have an indexing mechanism that will allow you to quickly search and retrieve any item from any one of your users' shopping carts. As all of the information pertaining to a shopping cart is stored in XML, this means you will need to index hundreds of pieces of data, which themselves are stored as XML, for each shopping cart of each user. This will need to be developed, tested and the performance compared to that of a database index scan.

In addition to the issue of searching the shopping cart data, you will need to consider whether you want to use the memory of your application server(s) for the storage of this data. I've seen many a system crash with only a half dozen users because of the size of each user's session state, or the amount of memory allocated by a shared cache structure to store their individual information.

Next, consider the operation that will be required to calculate the total for a shopping cart. As you've already mentioned, you cannot insert the price directly into the shopping cart, as it depends on external variables which are stored in the database. Therefore, each and every time a user wants to view the total price of their shopping cart, you will need to search the index for that user's shopping cart, convert the XML into a format that can be used as an input parameter to the stored procedure, invoke the stored procedure, which will then have to parse the XML, store the results in a temporary memory structure, query the database to retrieve the price information, and then send the result back to the application. This to me is a compelling reason why not to store the shopping cart data in memory in the first place, but rather represent a shopping cart using a database table.

You also mention that the code element of the shopping cart cannot be unique, as the user needs to be able to sort on it. I do not understand this at all. Columns can be sorted irrespective of whether the contained values are unique or not. Sorry, but I don't understand how can claim that it not possible to sort a column because the data may not be unique.

My proposal to increase the efficiency of your process is, then, to therefore that you eliminate the use of XML and use tables with a few stored procedures to update and read the data. You will then have a process that is easy to develop, manage and monitor. If we compare the two approaches, in terms of components used, we can observe the reduced complexity of the database approach.

Approach using XML:

Required components and processes:
- XML Documents
- Custom indexing mechanism
- Memory structures to store the documents
- Stored procedures to process and extract information from the XML documents.
- Well documented processes to ensure the XML schema always remains constant to all processes that will access it. This will require at minimum, the application's processes, the dataset write method and the database stored procedure.
- Each time the user wishes to query their shopping cart, the system must send the HUGE XML document to the database, which will then parse it and return an answer. This step is rather involved.

Required approach using the database:
- One or two tables to represent the shopping cart
- A few stored procedures to update a shopping cart, and to return information including the total cost of shopping cart. The advantage here is that, as you need to calculate cost using variables from other tables, you can do this easily as your shopping cart data will already exist in tables. No need to parse anything.
- One or two methods in the application to communicate with the database.
- And, you will significantly reduce the amount of memory that is required when dealing with a shopping cart.

Databases were born to read and write data. I do not see a compelling reason to not use them for this purpose.

Differing opinions will of course exist, but me, I will always use a database for any operations that involve data. And if disk I/O becomes a performance problem, I'll just buy an in-memory database such as Oracle times ten ;)|||I must admit that your second post is actually useful and contains solid information. I appreciate well thought out and documented suggestions & comments when I see them.

However, please give me one more piece of advice. In regards to my original question, I wanted to know how to use the built in XML handing functionality of SQL to use nested elements as opposed to attributes. While I have figured out how to modify my XML to use attributes and resolve the issue, my original question is still unanswered. I would greatly appreciate sample code to clarify my understanding.

I did try Google (and of course this site) for solutions an examples, but all the documentation I found used attributes, and not nested elements. My trouble was compounded because I did not know the proper verbiage to use in my searches. I used combinations of XML, .value, .nodes, xquery, input paramenter, and xml datatype all to no avail.|||I still find it difficult to believe that you haven't been able to find information using Google about how to query an XML document using SQL Server. But anyway, that's neither here nor there.

Try
http://www.simple-talk.com/sql/sql-server-2005/beginning-sql-server-2005-xml-programming/

This link explains very clearly, under the heading of OPENXML, how to open an XML document and retrieve specific elements using SQL.

Monday, March 19, 2012

Make items bold in parameter selection list

Is it possible to make certain items in a parameter selection list appear bold?No, parameters are not configurable in terms of presentation.


HTH, Jens K. Suessmeyer.

http://www.sqlserver2005.de

|||I am getting available values from a calculated member in analysis services. The definition pane for a calculated member contains a section for 'font expressions'. I tried to use that, but didn't succeed. Does anyone know what you can do with font expressions?

Make Filter = False

I have a stored proc to return the main report data. I have another dataset1 to return the distinct values for my parameter. I filter the main data based on the parameter selected by user. I wanted to add 'ALL' option to the parameter drop down. I have added an UNION to the dataset1 to include this option. I now want to change my filter expresion from '=Fields!FRole.Value = Parameters!PRole.Value' to include ALL option and basically ignore the filter. Is it possibleMulti-valued parameters are not supported RS 2000. Here's a related post
with a solution that might work for you:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=ONnNRtsBEHA.3064%40tk2msftngp13.phx.gbl&rnum=2&prev=/groups%3Fq%3D%2522in%2Bclause%2522%2Bgroup:microsoft.public.sqlserver.reportingsvcs%26hl%3Den%26lr%3D%26ie%3DUTF-8%26selm%3DONnNRtsBEHA.3064%2540tk2msftngp13.phx.gbl%26rnum%3D2
Ravi Mumulla (Microsoft)
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"vrodkar" <vrodkar@.discussions.microsoft.com> wrote in message
news:A6CBA50D-2C8F-4A97-B925-CE5DE0378347@.microsoft.com...
> I have a stored proc to return the main report data. I have another
dataset1 to return the distinct values for my parameter. I filter the main
data based on the parameter selected by user. I wanted to add 'ALL' option
to the parameter drop down. I have added an UNION to the dataset1 to include
this option. I now want to change my filter expresion from
'=Fields!FRole.Value = Parameters!PRole.Value' to include ALL
option and basically ignore the filter. Is it possible|||I'm curious on this as well as I am also trying to
implement this on a report. Has anyone founnd a
workaround?
>--Original Message--
>I have a stored proc to return the main report data. I
have another dataset1 to return the distinct values for
my parameter. I filter the main data based on the
parameter selected by user. I wanted to add 'ALL' option
to the parameter drop down. I have added an UNION to the
dataset1 to include this option. I now want to change my
filter expresion from '=Fields!FRole.Value =Parameters!PRole.Value' to include ALL option and
basically ignore the filter. Is it possible
>.
>|||Yes I use an "(All)" option in most of my reports.
It's easier if you're using queries instead of stored procedures.
In your parameter list have an item labelled "(All)" give it a Value of "%".
In your main data query have criteria or where clause using the 'LIKE' operator against the parameter, so in SQL;
SELECT * FROM tblData WHERE Country LIKE @.Country
% is the SQL wildcard character, but must be used with the like operator.
Regards
Chris McGuigan
"BiggieSize" wrote:
> I'm curious on this as well as I am also trying to
> implement this on a report. Has anyone founnd a
> workaround?
> >--Original Message--
> >I have a stored proc to return the main report data. I
> have another dataset1 to return the distinct values for
> my parameter. I filter the main data based on the
> parameter selected by user. I wanted to add 'ALL' option
> to the parameter drop down. I have added an UNION to the
> dataset1 to include this option. I now want to change my
> filter expresion from '=Fields!FRole.Value => Parameters!PRole.Value' to include ALL option and
> basically ignore the filter. Is it possible
> >.
> >
>

Monday, March 12, 2012

Make (Select All) as default value in parameter

Dear Anyone,
Does anyone know how to Make (Select All) as default value in parameter selection on a multi-select parameter?

thanks,
Joseph

If the valid values list of the multi value parameter is dataset based, you could set the default value of the parameter to the same dataset field value.

-- Robert

|||

We have the hotfix for the (Select All) option applied (after applying SP1).

However, when the users change another parameter filter which cascades to change to the multivalued parameter filter, the (Select All) option is not reapplied. In other words, if new entries show up in the multivalued parameters list, they are not checked by default, so some records will be missed.

What is the best way to force a (Select All) again after the user filters on another dependent parameter filter?

Make (Select All) as default value in parameter

Dear Anyone,
Does anyone know how to Make (Select All) as default value in parameter selection on a multi-select parameter?

thanks,
Joseph

If the valid values list of the multi value parameter is dataset based, you could set the default value of the parameter to the same dataset field value.

-- Robert

|||

We have the hotfix for the (Select All) option applied (after applying SP1).

However, when the users change another parameter filter which cascades to change to the multivalued parameter filter, the (Select All) option is not reapplied. In other words, if new entries show up in the multivalued parameters list, they are not checked by default, so some records will be missed.

What is the best way to force a (Select All) again after the user filters on another dependent parameter filter?

Make (Select All) as default value in parameter

Dear Anyone,
Does anyone know how to Make (Select All) as default value in parameter selection on a multi-select parameter?

thanks,
Joseph

If the valid values list of the multi value parameter is dataset based, you could set the default value of the parameter to the same dataset field value.

-- Robert

|||

We have the hotfix for the (Select All) option applied (after applying SP1).

However, when the users change another parameter filter which cascades to change to the multivalued parameter filter, the (Select All) option is not reapplied. In other words, if new entries show up in the multivalued parameters list, they are not checked by default, so some records will be missed.

What is the best way to force a (Select All) again after the user filters on another dependent parameter filter?