Cascading Parameter Not Working

Sep 20, 2007

Hi Friends,

I have 2 parameter One is Office (Listbox) another Account(list box) , where Account list box filling is dependent on the Office selection.

In published report when I select the office from list box the page got refreshed but it not updating the account list, the account list box looks diabled?

I have define the two parameter and for the second parameter here is the query

="SELECT ACCOUNT_ID, ACCOUNT_NUMBER FROM MLGDB2.A_ACCOUNT " &
"where OFFICE_ID =" & Parameters!paramOffice.Value &
"ORDER BY ACCOUNT_ID "

Can any one help me.

Thanks

Novin

View 4 Replies


ADVERTISEMENT

Default Parameter Value Is No Longer Part Of Cascading Parameter In SSRS 2005?

Jan 30, 2007

Hi,

I need "conditional" cascading parameters: In Report Manager when one changes parameter 1, parameter 2 get changed based on parameter 1. Optionally, one can also enter values to parameter 2 directly.

I was able to achieve this in SSRS 2000 (SP2) with the following setups. SSRS 2005 and SP1 no longer works - Parameter 2 always shows its default value regardless whether one select a value in Parameter 1 or not.

Parameter 1
available values: from query
default values: non query (specify a value "<None>")
Parameter 2
available values: Non query (no value specified)
default values: from query (based on Parameter 1)

It seems to me that the default value in SSRS 2000 is considered as cascading parameter. But it is no longer the case in SSRS 2005.

Is this a SSRS 2005 bug? is there any other work arounds or suggestions?

Thanks.

Kong

View 6 Replies View Related

Reporting Services :: Multi Value Cascading Parameters Not Working

Apr 23, 2015

I have created two report parameters and want them as Cascading. District Parameter depends on Region Parameter which should allow Multi selection. When I select single value in Region it works perfectly. But when I choose multiple values, District turns out to be a blank text box. I have used the In clause in my code :

SELECT
DISTINCT
SalesDistrict
FROMDistrict(NOLOCK)
WHERESalesRegion
IN(@SalesRegion)

View 2 Replies View Related

Cascading Parameter With ODBC

Sep 24, 2007

Hi Friends,

I have 2 parameter One is Office (Listbox) another Account(list box) , where Account list box filling is dependent on the Office selection.

In published report when I select the office from list box the page got refreshed but it not updating the account list, the account list box looks diabled?

I have define the two parameter and for the second parameter here is the query

="SELECT ACCOUNT_ID, ACCOUNT_NUMBER FROM MLGDB2.A_ACCOUNT " &
"where OFFICE_ID =" & Parameters!paramOffice.Value &
"ORDER BY ACCOUNT_ID "

To access parameter i need to use Parameters!paramOffice.Value with ODBC driver instead of @param.

Can any one help me.

Thanks

Novin

View 4 Replies View Related

Cascading Parameter Resets When Report Is Run

Feb 18, 2008



I am having a problem with Cascading Parameters in a RS2005 SP2 report.
In the report the user selects the part # (param 1) based on the part number selected the
serial # list (param 2) is populated. This all works fine.

The problem is that when the user clicks on the View report button the report is generated and the part # stays the same but the serial # parameter is "reset". On the development box it gets reset to the last serial # on the list. When we deploy out to our production environment it gets reset to the first serial # in the list.

Is there a way to stop the serial # (param 2) from being reset and to have it stay to what the user selected.


Thanks.

View 3 Replies View Related

How To Pass Multiple Values To A Parameter While Cascading

Oct 9, 2006

Hi,

I am using RS2005. i have a requirement in which i need to pass more than 1 value to a parameter. this parameter is used in a dataset for filtering.

Eg: if i have a parameter as @years, i want to assign values 2005, 2006 to it and use it in the dataset to filter like select.... where year in (@years).

How can i achieve this?

Thanks

Vivek S

View 13 Replies View Related

Reporting Services :: Cascading Multi-Value Parameter

Sep 30, 2015

So this is my first time posting on MSDN but I am running into an issue I don't know how to circumvent. This issue isn't causing my report not to run but it makes it very confusing for end users.  I am building a report for a user and he was cascading parameters. The parameters are Department (the Parent), Site (the Child) and Vehicle Class (the grandchild).

Here is my issue: If I select 2 Departments named Dept1 and Dept2, the Site parameter populates. If Dept1 and Dept2 have sites named the same, example fleet, Fleet shows up in the site parameter twice. 

Then the Vehicle Class parameter populates. Now if at those sites they have the same vehicle class, lets say 1/2 ton pickup, 1/2 ton pickup is in the vehicle class parameter twice. 

All three of these parameters are populated by a query and all of the queries are using SELECT DISTINCT. I know I could manually input values for the parameters but there are to many departments and sites and they all vary to much depending on the department. 

Is there a way to to only have distinct values populate the parameter even if the parents have the same child?

View 3 Replies View Related

Cascading Parameter Alwaycome Back To Default Value

Feb 9, 2007

Hi all,

I encounter a cascading parameter problem that confuses me badly.



I have a Web App, say App1, and view the server report, say Report1, through Report viewer. I pass a parameter (P1)value from App1 to Report1. at the report side, I create a dataset, say DS1, against the P1's value. Then I create second parameter P2 whose value comes from dataset DS1, and I set its default value as DV1 (it could be Null, or querying from DS1 or a constant). The report1 comes agains the value of @P2.


The problem is here, when the report is run, @P2 can show correct value list in its dropdown (comes from dataset DS1), but after I select the values and click 'view report', the of value of @P2come back to the default one, DV1, and the report comes out against the DV1 (not what I selected).


Any idea?

Thanks

View 1 Replies View Related

Reporting Services :: Default Value Refreshing In Cascading Parameter (SSRS)

Jul 19, 2011

I have two parameters, lets say P1 and P2. P2 is cascaded with P1. P1 -> P2.

For the parameter P2, the following proterty set are

 1. Multi Select
 2. The default value is all the available value selected (Same dataset is assigned to both "Available Values" and "Default Values")

The data relation be,
P1    P2
A     a
A     b
A     c
A     d
B     a

Now the issue is,

Step 1 : When i choose A in P1 first time, a,b,c and d in P2 are selected
Step 2 : When i change B in P1, a is selected
Step 3 : When i change back to A in P1, only a is selected in P2 (a,b,c and d should be selected)

View 3 Replies View Related

Cascading Deletes - Which Is Better - A Trigger Or Foreign Key Cascading Delete?

Aug 17, 2005

I need to implement my cascading deletes on a SQL database.  Is it better (performance/reliablility-wise) to use the Foreign Key Cascading Deletes or to just write my own triggers to do the deletes?I was hoping someone had experimented and found which works best.

View 2 Replies View Related

Parameter Not Working

Jan 19, 2007



I am pretty new to reporting services and hope some of you experts can help.

I created a report from AS cube that has a column "Description" with 30 distinct values. The report has a multi-value parameter "Description" with the following details:

Data Type : String
Value Field: Description
Label Field : Description

The filter that i have on the table is =(Fields!Description.Value) = Cstr(Parameters!Description.Value(0))

When i preview the report i only see the top 1 item from the values that i select from the parameter list.

What am i doing wrong?

Any help is appreciated.



Thanks

View 8 Replies View Related

Output Parameter In SP Not Working?

Feb 28, 2008

Hi everyone,
   This is the sp i have written which works fine in the sql server management studio when i run it but when i call it from the vb.net web application the output parameters are generated as nothing but the sp return the data from the select statement, so here is the sp followed by vb.net code to access the sp. 
This is the Store ProcedureCREATE PROCEDURE [dbo].StaffAuthenticate
@Staff_ID nvarchar(50),
@Password nvarchar(15),
@IsAuthenticated int OUTPUT,
@P_message_code int OUTPUT
AS
BEGIN
SET NOCOUNT ON;
Select * From Staff;
SET @IsAuthenticated = 0;
SET @P_message_code = 100;
RETURN END
GOThis is the VB.NET code.  Dim ConStr As String = GenericDataAccess.GetConnection(IConnectionStrNames.OAAStaffAuthStr)
Dim Conn As SqlConnection = New SqlConnection(ConStr)
Dim Command As SqlCommand = Nothing
Conn.Open()
Command = New SqlCommand()
Command.Connection = Conn
Command.CommandText = "StaffAuthenticate"
Command.CommandType = CommandType.StoredProcedure

Command.Parameters.Add("@Staff_ID", SqlDbType.NVarChar, 50).Value = UserId
Command.Parameters.Add("@Password", SqlDbType.NVarChar, 15).Value = Password
Command.Parameters.Add("@IsAuthenticated", SqlDbType.Int).Direction = ParameterDirection.Output
Command.Parameters.Add("@P_message_code", SqlDbType.Int).Direction = ParameterDirection.Output

Dim myDataReader As SqlDataReader = Command.ExecuteReader()
Dim Res As New StringBuilder

While (myDataReader.Read())
For i As Integer = 0 To myDataReader.FieldCount - 1
Res.Append(myDataReader(i).ToString())
Res.Append(" ; ")
Next
Res.AppendLine()
End While

MsgBox(Command.Parameters("@IsAuthenticated").Value)
MsgBox(Command.Parameters("@P_message_code").Value)
MsgBox(Res.ToString, MsgBoxStyle.Information, "DAL : StaffSqlAuthenticate")  Thanks for all the help, Really could use one. Kabir 
 

View 5 Replies View Related

Working With DataTableAdapter And Parameter

Apr 18, 2006

I have created a dataset table adapter with existing stored procedure.Stored Procedure has 3 parameters.I am trying to create a page where use can search on different field and generate report on gried view control. They can either search by one parameter , two or may be multiple.
But When I try to run this it gives me error if I dont put all three parameters, how can I make this work so that even if I put one, two or multiple parameter it works error free.
CREATE PROCEDURE [dbo].[ConvertParentSupplier_SP] @supplierID varchar(10),@active varchar(10)ASselect distinct Supplier.SupplierID, SupplierName, ParentSupplierID, isnull(Active,'')as Activefrom supplier where supplier.ParentSupplierID =@supplierIDand Supplier.SupplierID=Supplier.ParentSupplierID and supplier.active=@activeorder by supplier.supplieridGO

View 1 Replies View Related

Why Is My Output Parameter Not Working?

Jul 23, 2005

Hi,I am currently creating an ASP page that returns a recordset of searchresult based on multiple keywords. The where string is dynamicallybuilt on the server page and that part work quite well. However I wantto also return the number of records in the recordset and I can notmanage to get any output parameter working. Even if I assign SELECT@mycount=100 (or SET @mycount=100) in the SP the only value set inmycount is always NULL. I tested various theories (e.g. early exit,order & naming of parameters etc. but I can not make the SP set theoutput parameters - has it anything to do with the execute?). @mycountalso returns NULL if I test it in SQL QA.What's wrong with this SP (as regards mycount):CREATE PROCEDURE dbo.spFindProducts@mycount integer OUTPUT,@whereString varchar (1000)AS--SET NOCOUNT ON--Set a Default value for the Wherestring which will return all recordsif the Wherestring is blankIF @whereString is NullSELECT @whereString = 'AND TblProduct.ProductID is not null'--Declare a variable to hold the concatenated SQL stringDECLARE @SQL varchar(2500)-- AND (((UPPER([TblProduct].[ProductName] + [ProductGroupCode] +[AttributeValue1] +-- [SearchWords] + [tblSupplier].[SupplierCode] + [SupplierDesc]))Like '%screw%'))SELECT @SQL = 'SELECT TblProduct.ProductID, TblProduct.ProductName,TblProduct.ChapterCode, tblProduct.ProductGroupCode' +' FROM (TblProduct LEFT JOIN TblStockItem ON TblProduct.ProductID =TblStockItem.ProductID) ' +' LEFT JOIN tblSupplier ON TblProduct.SupplierCode =tblSupplier.SupplierCode' +' WHERE 1=1 ' + @whereString +' GROUP BY TblProduct.ProductID, TblProduct.ProductName,TblProduct.ChapterCode, TblProduct.ProductGroupCode'SELECT @mycount = 200; -- testexecute (@SQL);-- next line seems to be ignored ?SELECT @mycount = @@rowcount;GOtiaAxel

View 11 Replies View Related

Parameter Store Procedure Not Working

Aug 9, 2006

I have this select statement:
SELECT * FROM [enews] WHERE ([name_nws] LIKE '%" + strSearch + "%' OR
[title_nws] LIKE '%" + strSearch + "%'OR [sub_nws] LIKE '%" + strSearch
+ "%' OR [sum_nws] LIKE '%" + strSearch + "%' OR [content_nws] LIKE '%"
+ strSearch + "%')

This statement works fine but when I turned it into a store procedure,
it returns nothing. I created the store procedure as follows:
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:        <Author,,Name>
-- Create date: <Create Date,,>
-- Description:    <Description,,>
-- =============================================
CREATE PROCEDURE sqlSearch
    -- Add the parameters for the stored procedure here
    @strSearch varchar(250)
AS
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    -- Insert statements for procedure here
    WHERE ([name_nws] LIKE '%" + @strSearch + "%' OR
[title_nws] LIKE '%" + @strSearch + "%'OR [sub_nws] LIKE '%" +
@strSearch + "%' OR [sum_nws] LIKE '%" + @strSearch + "%' OR
[content_nws] LIKE '%" + @strSearch + "%')
END
GO

Help is appreciated.

View 1 Replies View Related

Dynamic SQL && Parameter Inside A SP Not Working

Nov 5, 2006

When I run the query below on my DB, it gives the following error:
Server: Msg 8114, Level 16, State 5, Procedure partstlist ...Error converting data type varchar to float.
Only after I replace the      " + @d + " section with a float numnber such as 39020.5 does it work fineIt's reported that my temporary table named #tbl doesn't exist within the scope of the environment that the EXEC(UTE) command operates.Someone said that I couldn't combine dynamic SQL and temporary tables or table variables...and that I would have to use a global temp table "##tbl" or a permanent table.
So here I have appearantly a "DYNAMiC SQL & TEMPORARY TABLE" problem. That's sure.
But I don't have much knowledge and experience with SQL tables and have difficulty forming a global temp table "##tbl" or a permanent table.and I have to employ the datetime variable dynamically @d inside the Dynamic SQL string.
So what kind of a code should I use here to properly combine Dynamic SQL string with my dynamic datetime variable? I'd be grateful if you could post your code suggestions so that I can try them on my DB ..
alter PROCEDURE partslist@no INT,@dt DATETiMEASDECLARE @s VARCHAR(5000)DECLARE @d floatSET @d = CONVERT (float, @dt2)create TABLE #tbl(pageindex int IDENTITY(1,1) PRIMARY KEY , prt_name varchar(50), prt_country varchar(50) , prt_date smalldatetime, partID int , prt_cat varchar(50),prt_product_type nvarchar(10), producer_company nvarchar(50), producer_city nvarchar(50), prt_released DATETIME, dvalue float, datevalue varchar(26) )BEGiNSET ANSI_WARNINGS OFFSET ROWCOUNT @noSELECT @s = 'INSERT INTO #tbl SELECT prt_name, Countries.Val AS ''prt_country'' , prt_date, partID , partsCategories.Val AS ''prt_cat'' , partsProductTypes.Val AS ''prt_product_type'' , producers.producer_company AS ''producer_company'' , producers.producer_city AS ''producer_city'' ,  prt_released , CONVERT (float, prt_released) , CONVERT (varchar(26) , prt_released, 109) FROM producer_parts  JOIN partsProductTypes ON (producer_parts.prt_product_type = partsProductTypes.ID) JOIN partsCategories ON (producer_parts.prt_cat = partsCategories.ID)JOIN Countries ON (producer_parts.prt_country = Countries.ID) JOIN producers ON (producer_parts.producerID = producers.producerID) WHERE prt_visible = 1  AND CONVERT (float, prt_released) > ' + @d + ' AND CONVERT (float, prt_released) < 39025.5ORDER BY prt_released DESC SELECT * FROM  #tbl'EXEC (@s)SET ROWCOUNT 0ENDGO partslist 10 , '10.10.2006 10:10:10' -- This is just to test the SP.
This code may not be syntatically correct, it's a re-edited version of my code which works fine in my DB.

View 2 Replies View Related

Report Parameter Not Working Properly After Deploy

Feb 21, 2008

Hi All

I have a parameter @User givning a dropdown list from a dataset:

SELECT FullName FROM tvf_GetListOfUsers ('LDAP://OU=Business
Users,OU=Users,OU=Production,DC=MRP,DC=NET,DC=NZ','Subtree')
ORDER BY FullName


The parameter is passed to a second dataset when the User is chosen:

SELECT GroupName FROM tvf_GetUserMembership('LDAP://cn=' + @User +
',ou=business users,ou=users,ou=production,DC=MRP,DC=NET,DC=NZ')
ORDER BY GroupName

This works fine in VS but when I deploy it only works the first time.

That is, I enter the username and run the report - it brings back the
desired results. But when I enter a different username it just redisplays the
old data from the first username I entered.

Any ideas?

Thanks
Pete

PS The funcions above called in the datasets are for querying Active
Directory but I think this is not the cause of the problem.

View 1 Replies View Related

Multi-value Parameter Default Values Not Working

Jul 12, 2007



I have a parameter that gets it's available values from a dataset.



I use this exact same data to populate the default values.



When I run the report, the available values get populated; however the default values are not being selected.



This works on other parameters on the same report. However, on this parameter, it is not working.



I have tried ltrim/rtrim (Been burned with that before when the field type is a char)

I change the data field in the query, without changing the parameter setup, and it works...



Here is my query:




Code Snippet

Select distinct
CityName

from dimHotel dH (NOLOCK)
Inner join factHotel fH (NOLOCK)
on dh.HotelKey = fH.HotelKey

Where dH.CityName <> ''
and dH.CityName is not null
and fH.ClientKey in (@ClientID)

Order by CityName





The parameter is setup correctly, and matches the setup of another parameter on the same report that is working fine.



I have tried deleting the parameter and re-adding it. This did not work.

I also deleted and re-added the query. No luck.



Any ideas??

Thanks!!



Thanks

View 3 Replies View Related

Reporting Services :: Hidden Parameter Stops Working

Nov 22, 2015

I have a working set of parameters, when they are all visible. However, when I change the second parameter to hidden it stops working. 

First Parameter - Contains static values 'MTD' & Daily
Second Parameter - has available values and a default. Set up to be invalidated when the First parameter changes... like i say it works beautifully when not hidden.
Third Parameter - has an expression takes the value of the 2nd parameter value, removes the first character off and then converts the remainder to a date and uses it as its default value.

It based on this webpage: URL....However, when i set the second parameter to hidden it no longer works.

View 2 Replies View Related

SSRS 2005 Multivalue Parameter Not Working On The Asp Page.

Oct 30, 2007

Hi,
i am working on SSRS 2005. i have one problem while accessing report throgh ASP.net pages.

i have used multivalue parameters in the report. on the report server it works fine but on the .asp page when that report is accessed, drop down is not working,

can anybody guide me regarding this , what to do?

thanks and Regards,
Vishruti.

View 1 Replies View Related

Multivalue Parameter Dropdown Not Working In Aspx Page

Feb 21, 2008



Hi All
i have created one report using SSRS 2005, in this report one parameter is multivalue parameter, this report preview working fine and user able to select multivalues. but the problem is i deployed this report in server and opened in client system (reports shown to user using report viewer in aspx pages), i am able to access the report but multivalue parameter dropdown is not working.
when i clicked on multivalue parameter dropdown report refreshing and remaining parameters default vaues coming up..
i am unable to find the solution
please anyone help me

thanks

View 3 Replies View Related

Reportviewer Date Parameter And Calendar.. Not Working And Javascript Errors??

Oct 22, 2007


Hi, I've got this ssrs 2005 report that works great passing a few
security related parameters from asp.net codebehind. However, there
are two date related parameters that won't be coming from my web form,
but rather from the report form itself. When I test the report's date
parameters from visual studio it work fine, but when I attempt the
same report from a reportviewer no matter what input I place on the
report's date fields or even if I select the date picker, the report
simply resets to default and reloads. And actually the date picker
from the reportviewer does not not even pop up.



Here's my aspx code:


<%@ Page Language="VB" AutoEventWireup="false"
Inherits="_ReportViewer" MasterPageFile="~/Main/MasterPage.master"
CodeFile="~/Reports/CashSales.aspx.vb" Title="Cash Sales" %>


<%@ Register Assembly="Microsoft.ReportViewer.WebForms,
Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>


<asp:Content ID="Content1" ContentPlaceHolderID="Content1"
runat="Server">
<rsweb:ReportViewer BackColor="Transparent" ZoomMode="PageWidth"
Width="100%" ProcessingMode="Remote" ID="ReportViewer1"
runat="server">
<ServerReport ReportPath="/Retailer/CashSales"
ReportServerUrl="http://myserver/reportserver" />
</rsweb:ReportViewer>
</asp:Content>


Note: I'm only passing the parameters that are not coming from the
reportviewer form.




the code behind:




Imports system.web.security.membership
Imports system.web.security.Roles
Imports Microsoft.Reporting.Webforms


Partial Class _ReportViewer
Inherits System.Web.UI.Page
Private Users As New Retailer.Core()


Protected Overrides Sub OnLoad(ByVal e As EventArgs)


Dim Roles() As String =
GetRolesForUser(Page.User.Identity.Name.ToString)


Dim cred As New Retailer.ReportServerCredentials("myuser",
"mypassword", "mydomain")
ReportViewer1.ServerReport.ReportServerCredentials = cred


Dim param As New ReportParameter("r_user",
Page.User.Identity.Name.ToString)
Dim param2 As New ReportParameter("r_role", Roles(0))
Dim p() As ReportParameter = {param, param2}


ReportViewer1.ServerReport.SetParameters(p)
ReportViewer1.ServerReport.Refresh()


End Sub
End Class



on my reportviewer form, at the top I have parameters for startdate
and end date, they are not set to internal or hidden.

If I select the calendar icon, i get a javascript error


Line: 606
Object Required


When I attempt to debug I get a Just-In-time failed : Unspecified
error. Check the documentation index for 'Just-in-time debugging,
errors' for more information. So pretty much I can't see the error or javascript in question.


If i enter anything in the date fields, it disregards them setting them to the defaults.

Again, if i run the report from my vs.net client (not using reportviewer), i can select the calendar and enter dates and it respects them.

Any chance I need to patch sql server or reporting services? maybe ie. I'm on IE 7.0.5730.11
Could my problem be that selecting items on the report itself fails to send my credential information from my codebehind?


Thanks for any help or information!

View 26 Replies View Related

Reporting Services :: Passing Multivalue Parameter In URL In SSRS 2008 Not Working

Jun 17, 2015

I am trying to test the concept of passing multi value parameters from one report using the Action Property of a textbox to open another report is a new Window with the Multi Value parameter values already passed. The test involves the following:

Report 1:

1. Multi Value Parameter @ReportParameter1 has three Values: Value1, Value2, Value3

2. Has a text box with the Action Property set to Go to URL with the following Expression:
="javascript:void(window.open('http://reportserver/Reports/Pages/Report.aspx?ItemPath=%2fReports%2fReport2&rs:Command=Render&ReportParameter1="
+ JOIN(Parameters!ReportParameter1.Value,"&ReportParameter1=") + "'))"

Report 2:

1. Has Two Parameters @ReportParameter1 and @ReportParameter2

2. @ReportParameter1 has Available Values as follows: Value1, Value2, Value3

Does not have any default Values.

When I click on the textbox on Report1, it does navigate to Report2 but none of the Values are being set.

View 3 Replies View Related

Cascading Delete?

Nov 8, 2006

I use SQL Server 2005I have tables tblUserData, tblUsersAndGuestbook, tblGuestbooktblUserdata contains:UserCode   intUsername   nvarchar(50)tblUsersAndGuestbook contains:Usercode    int   (FK to tblUserData)GBEntryCode    inttblGuestbookGBEntryCode    int   (FK to tblUsersAndGuestbook)GBText      textNow...if I delete a user in tblUserData I want to also delete the entries in tblUsersAndGuestbook AND in tblGuestbook.I've heard something about cascading delete, but how can i configure that in my database?Or do I manually need to delete all entries from code?

View 2 Replies View Related

Cascading Parameters

Dec 15, 2005

Hi
I have three params p1 , p2 and p3.
All 3 are non queried with values Yes and NO .
if p1 is yes only i have to enable the remaining twp params otherwise disable them.
Can some one suggest as to how this can be achieved.
Thanks

View 1 Replies View Related

Help-Cascading Delete

Jun 4, 2001

Hi,
I read all the existing material in SWYNK but still am not clear on the following question.
What is the best way to perform Cascading actions (Delete & Update) with foreign Key Constraints declared? We are using SQL Server 7.0
thanks
Rozina

View 1 Replies View Related

Cascading Trigger

Nov 3, 2000

Can someone pls help me with a syntax example of a cascading delete trigger.

thanks

View 2 Replies View Related

Cascading Delete ...

Sep 14, 2004

Procedure spDeleteRows
/*
Recursive row delete procedure.

It deletes all rows in the table specified that conform to the criteria selected,
while also deleting any child/grandchild records and so on. This is designed to do the
same sort of thing as Access's cascade delete function. It first reads the sysforeignkeys
table to find any child tables, then deletes the soon-to-be orphan records from them using
recursive calls to this procedure. Once all child records are gone, the rows are deleted
from the selected table. It is designed at this time to be run at the command line. It could
also be used in code, but the printed output will not be available.
*/
(
@cTableName varchar(50), /* name of the table where rows are to be deleted */
@cCriteria nvarchar(1000), /* criteria used to delete the rows required */
@iRowsAffected int OUTPUT /* number of records affected by the delete */
)
As
set nocount on
declare @cTab varchar(255), /* name of the child table */
@cCol varchar(255), /* name of the linking field on the child table */
@cRefTab varchar(255), /* name of the parent table */
@cRefCol varchar(255), /* name of the linking field in the parent table */
@cFKName varchar(255), /* name of the foreign key */
@cSQL nvarchar(1000), /* query string passed to the sp_ExecuteSQL procedure */
@cChildCriteria nvarchar(1000), /* criteria to be used to delete
records from the child table */
@iChildRows int /* number of rows deleted from the child table */

/* declare the cursor containing the foreign key constraint information */
DECLARE cFKey CURSOR LOCAL FOR
SELECT SO1.name AS Tab,
SC1.name AS Col,
SO2.name AS RefTab,
SC2.name AS RefCol,
FO.name AS FKName
FROM dbo.sysforeignkeys FK
INNER JOIN dbo.syscolumns SC1 ON FK.fkeyid = SC1.id
AND FK.fkey = SC1.colid
INNER JOIN dbo.syscolumns SC2 ON FK.rkeyid = SC2.id
AND FK.rkey = SC2.colid
INNER JOIN dbo.sysobjects SO1 ON FK.fkeyid = SO1.id
INNER JOIN dbo.sysobjects SO2 ON FK.rkeyid = SO2.id
INNER JOIN dbo.sysobjects FO ON FK.constid = FO.id
WHERE SO2.Name = @cTableName

OPEN cFKey
FETCH NEXT FROM cFKey INTO @cTab, @cCol, @cRefTab, @cRefCol, @cFKName
WHILE @@FETCH_STATUS = 0
BEGIN
/* build the criteria to delete rows from the child table. As it uses the
criteria passed to this procedure, it gets progressively larger with
recursive calls */
SET @cChildCriteria = @cCol + ' in (SELECT [' + @cRefCol + '] FROM [' +
@cRefTab +'] WHERE ' + @cCriteria + ')'
print 'Deleting records from table ' + @cTab
/* call this procedure to delete the child rows */
EXEC spDeleteRows @cTab, @cChildCriteria, @iChildRows OUTPUT
FETCH NEXT FROM cFKey INTO @cTab, @cCol, @cRefTab, @cRefCol, @cFKName
END
Close cFKey
DeAllocate cFKey
/* finally delete the rows from this table and display the rows affected */
SET @cSQL = 'DELETE FROM [' + @cTableName + '] WHERE ' + @cCriteria
print @cSQL
EXEC sp_ExecuteSQL @cSQL
print 'Deleted ' + CONVERT(varchar, @@ROWCOUNT) + ' records from table ' + @cTableName
--------
The above code is good .. but has limitation...throws an error:
Server: Msg 217, Level 16, State 1, Procedure spDeleteRows, Line 58
Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32).

Can anyone out there suggest a better way of implementing on a database without a limitation of levels.. we are talking about a HUGE DB with lots of table and FK referentials..

Please advice.. or solve the problem..
Thank you

View 2 Replies View Related

Cascading Prompts

Jun 30, 2005

This question is for Bill directly. Hi Bill, I have lots of experience with RS, implementing the beta in a production environment, I was so impressed. Currently my company uses Cognos for financial reporting, and I am hoping to replace this with RS and MSAS. I have little knowledge of MDX, so I have been using your various series of articles to get up to speed. However, I don't get the article Mastering OLAP Reporting: Cascading Prompts. I fully understand how to build the prompts, but there seems to be a step missing in the article. You never replace the hardcoded where clause in the base dataset, and I can't seem to work out how to pass the parameter from the cascading prompts to the report. Maybe I'm being stupid, but the article doesn't seem to tell us how to do that.

Many Thanks

Sam

View 3 Replies View Related

Cascading Parameters

Mar 28, 2006

Hi All

I am using RS 2000. I used 2 input parameters for one of the report. The 2nd parameter is based on the 1st parameter. i.e. First Parameter is Country and 2nd Parameter is State. Based on the Country selection the list of states for the selected country will get displayed. This is working fine in Reporting services as well as report server. When deploying into the application it doesn't work.

If you have solution for this I would like to share.

Regards

Venkataraman M
ramanmahalingam@hotmail.com

View 6 Replies View Related

Cascading Deletes

Dec 21, 1998

I need some suggestions concerning the issue cascading deletes in a self-referencing table, i.e. a table with a foreign key pointing at the primary key in itself. Although SQL Server still does not support cascading deletes the declarative way there are some other ways to handle this situation. One common way is to use trigger coding with the simple structure
CREATE TRIGGER DelCascadeTrig
ON self_ref_tab
FOR DELETE
AS
DECLARE @C_FK xxxxxx
SELECT @C_FK = C_FK FROM DELETED
BEGIN
DELETE self_ref_tab
FROM self_ref_tab, deleted
WHERE self-_ref_tabC_FK = deleted.C_PK
END

where C_PK is the primary key column and C_FK the foreign key column. The problem is that this simple pattern does not work with self-referencing tables, because the removal of dependent rows deeper layer (n-2, n-3 etc. if the originating delete request is level n and the first level of dependant deletes handled by the trigger code is n-1) would require the delete trigger to fire more than once for the same delete operation. As far as I know, in ver. 6.x triggers are executed only once per SQL statement and in this case the n-2, n-3 etc. level rows would have been left as "orphans".

In ver. 7.0 I suppose this should work fine because of the new recursive trigger execution possibility (trigger will fire up to 32 recursive times per SQL statement), but in the meanwhile (i.e. my case util we have upgraded all our servers) the delete logic for a cascading, self-referencing relationship must be handled completely within one execution of the trigger.

My question is now: does anyone know anything about any common algorithm or trigger code example solving this problem.

Thanks in advance

Bjorn Ehnberg

View 1 Replies View Related

Triggers Not Cascading

Aug 5, 2004

Here's my table setup:

tblSteps:
StepID int IDENTITY
ParentStepID int ALLOWSNULLS
OtherID int
Amount money

tblOther:
OtherID int IDENTITY
Amount money

Now, I have a trigger defined on tblSteps:

Code:


CREATE TRIGGER tgrUpdateAmount
ON dbo.tblSteps
AFTER INSERT, UPDATE, DELETE
AS
BEGIN
DECLARE @Amount money
SET @Amount = ISNULL((SELECT SUM([Amount]) FROM inserted), 0) - ISNULL((SELECT SUM([Amount]) FROM deleted), 0)

IF (SELECT [ParentStepID] FROM inserted) IS NULL
BEGIN
UPDATE tblOther SET [Amount] = [Amount] + @Amount WHERE [OtherID] = (SELECT [OtherID] FROM inserted)
END
ELSE
BEGIN
UPDATE tblSteps SET [Amount] = [Amount] + @Amount WHERE [StepID] = (SELECT [ParentStepID] FROM inserted)
END

END



What this code basically does is this: if you update the amount of a Step that has a ParentStepID, it will take what was addded (or deleted etc...) and update it's parent with the added amount. If the Step does not have a ParentStepID, it will take the amount add add it to the Other row it corresponds to.

Here's an example of some test data:
tblOther:
OtherID: 1
Amount: 0

tblSteps:
StepID: 1
ParentStepID: NULL
Amount: 0
------
StepID: 2
ParentSTepID: 1
Amount: 0

If I update the Amount to 100 for StepID=2, it also updates the amount for StepID=1. If I update the amount for StepID=1, it also updates the amount for OtherID=1. However, when I update the amount for StepID=2, it does not cascade up to the tblOther level (e.g. Updating StepID=2 should update StepID=1 which should update OtherID=1, right?)

Basically, the trigger isn't cascading. Can anyone point out what I need to do?

Thanks

View 1 Replies View Related

Cascading Deletes

May 24, 2004

When I setup a relationship in Access I can specify that Primary Key deletes cascade down to the Forgien Key. So when I delete an Order Header it cleans up all the items in the Order Details table for me automatically.

Can I get this same functionality in SQL Server 7 without having to write triggers or are triggers the only way?

thanks
dog

View 13 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved