Showing posts with label values. Show all posts
Showing posts with label values. Show all posts

Thursday, March 22, 2012

error in updating field thru stor_proc

I'm trying to update 'password' field in a table thru a stored procedure which is called from my program.

I'm passing the values for password and the key fields.

While debugging I can see the values in each parameter, but I get an error that the 'value for password was not passed'.

Here's the program snippet for calling the stored proc.

All three parameters are 'varchar' type

dbConn.Open();

dbConn.CreateParameters(3);

dbConn.AddParameters(0, Pwd, newPwd);

dbConn.AddParameters(1, Login, pwd_Login);

dbConn.AddParameters(2, IdNum, pwd_IdNum);

result = dbMgr.ExecuteNonQuery(CommandType.StoredProcedure, SP_UPDPWD);

--

EXEC @.return_value = [dbo].[usp_UsrMstUpdPwdParaPwdEmailCaseNum]

@.Pwd = N'3Sg7vqowIBRdfgdfgrgdjykFTjTFt5hfHfhFtFghzIG1haWRliBuYW1lPw==',

@.Login = N'xyz@.abc.com',

@.IdNumber = N'00009'

--

What am I missing?

Is Pwd a variable or constant set to "@.Pwd", login to "@.Login", IdNum to "@.IdNum", and "SP_UPDPWD" to the appropriate string for your stored procedure?

Also, is this using an IDBManager pattern?

Thanks,

John

|||

Never mind. found the problem

The parameter for Password was not spelt right!

Wednesday, March 21, 2012

Error in SSRS Expressions

I am having an expression which is supposed to give me the values selected in a multivalued input parameter. I have tried following options however everytime it gives me error. Could someone let me know what might be the issue here.

1. Expression: =Parameters!i_Category.Label

Output: The Value expression used in textbox ‘textbox47’ returned a data type that is not valid.

2. Expression: =Parameters!i_Category.Label.ToString()

Output: System.Object[]

3. Expression: =CStr(Parameters!i_Category.Label)

Output: Error: Conversion from type 'String()' to type 'String' is not valid.

Take a look at this link for more information about parameters and working with multi-valued parameters.

http://msdn2.microsoft.com/en-us/library/aa337292.aspx|||Thanks Ian. It helped me a lot.

Error in sql stored procedure

I've a stored procedure which returns values based on 7 criterias. It was working fine and returned the values properly. I added one more criteria for returning values from 2 database columns based on minimum and maximum values. It's not working properly and gives syntax error. Could someone tell me what mistake I'm doing? Thanks.

ALTERprocedure [dbo].[USP_Account_Search_Mod]

@.ClientCode VARCHAR(7)=''

,@.DebtorName VARCHAR(25)=''

,@.DebtorNumberINT= 0

,@.AccountNumber VARCHAR(30)=''

,@.ReferenceNumber VARCHAR(30)=''

,@.TierINT= 0

,@.Status VARCHAR(5)=''

,@.UserIDINT

,@.MonthDateTime=NULL

,@.FromDateDateTime=NULL

,@.ToDateDateTime=NULL

,@.OriginalMindecimal= 0

,@.OriginalMaxdecimal= 0

,@.CurrentMindecimal= 0

,@.CurrentMaxdecimal=0

,@.lstAmountSelect VARCHAR(3)

,@.IsActivebit= 1

AS

DECLARE

@.SQLTier1Select VARCHAR(2000)

,@.SQLTier2Select VARCHAR(2000)

,@.Criteria VARCHAR(2000)

,@.SQL VARCHAR(8000)

,@.CRI1 VARCHAR(100)

,@.CRI2 VARCHAR(100)

,@.CRI3 VARCHAR(100)

,@.CRI4 VARCHAR(100)

,@.CRI5 VARCHAR(100)

,@.CRI6 VARCHAR(200)

,@.CRI7 VARCHAR(500)

,@.CRI8 VARCHAR(500)

,@.CRI9 VARCHAR(500)

SELECT @.CRI1=''

,@.CRI2=''

,@.CRI3=''

,@.CRI4=''

,@.CRI5=''

,@.CRI6=''

,@.CRI7=''

,@.CRI8=''

,@.CRI9=''

,@.Criteria=''

SELECT @.DebtorName=REPLACE(@.DebtorName,'''','''''');

Print @.DebtorName

if(SELECT UserTypeIDFROM dbo.tbl_Security_UsersWhere UserID= @.UserID)= 3AND @.ClientCode=''

return(-1)

IFLEN(@.DebtorName)> 0

SET @.CRI1=' AND Name like '+'''%'+ @.DebtorName+'%'''

IF @.DebtorNumber> 0

SET @.CRI2=' AND Number = '+CAST(@.DebtorNumberAS VARCHAR(7))

IFLEN(@.AccountNumber)> 1

SET @.CRI3=' AND AccountNumber like '+'''%'+ @.AccountNumber+'%'''

IFLEN(@.ReferenceNumber)> 0

SET @.CRI4=' AND Account like '+'''%'+ @.ReferenceNumber+'%'''

IFLEN(@.ClientCode)> 1

SET @.CRI5=' AND Customer = '+''''+ @.ClientCode+''''

SET @.Status=RTRIM(@.Status)

IF((@.StatusNotIN('ALL','ALA','ALI'))AND(LEN(@.Status)>1))

BEGIN

IF(@.Status='PAID')

SET @.CRI6=''

IF(@.Status='CANC')

SET @.CRI6=' AND Code IN (SELECT DISTINCT StatusID FROM tbl_APR_Statuses WHERE SearchCategoryCancelledT1 = 1 OR SearchCategoryCancelledT2 = 1)'

END

--PRINt @.CRI6

IFLEN(CONVERT(CHAR(8), @.Month, 112))> 0

BEGIN

IF(LEN(CONVERT(CHAR(8), @.FromDate, 112))> 0ANDLEN(CONVERT(CHAR(8), @.ToDate, 112))> 0)

BEGIN

SET @.CRI7=' AND Received BETWEEN '+''''+CONVERT(CHAR(8), @.FromDate, 112)+''''+' AND '+''''+CONVERT(CHAR(8), @.ToDate, 112)+''''

END

ELSE

BEGINSET @.CRI7=' AND DATEPART(mm, Received) = DATEPART(mm, '+''''+CONVERT(CHAR(8), @.Month, 112)+''''+') AND DATEPART(yy, Received) = DATEPART(yy, '+''''+CONVERT(CHAR(8), @.Month, 112)+''''

END

END

IF @.lstAmountSelect='ALL'

SET @.CRI8=''

elseIF @.lstAmountSelect='DR'

BEGIN

SET @.CRI8=' AND OriginalBalance >= '+convert(Varchar,@.OriginalMin)+'AND OriginalBalance<='+convert(Varchar,@.OriginalMax)+' AND CurrentBalance >= '+convert(Varchar,@.CurrentMin)+'AND CurrentBalance<='+convert(Varchar,@.CurrentMax)

END

ELSEIF @.lstAmountSelect='OLC'

BEGIN

SET @.CRI8=' AND OriginalBalance < CurrentBalance '

END

ELSEIF @.lstAmountSelect='OGC'

BEGIN

SET @.CRI8=' AND OriginalBalance > CurrentBalance '

END

ELSEIF @.lstAmountSelect='OEC'

BEGIN

SET @.CRI8=' AND OriginalBalance = CurrentBalance '

END

SELECT @.Criteria= @.CRI1+ @.CRI2+ @.CRI3+ @.CRI4+ @.CRI5+ @.CRI6+ @.CRI7+ @.CRI8

--PRINT @.Criteria

--PRINT @.CRI7

if @.Status='ALL'OR @.Status='ALA'OR @.Status='ALI'--All Period

BEGIN

if(@.Status='ALL')--All Active

BEGIN

SELECT @.SQLTier1Select='SELECT * FROM dbo.UDV_Tier1Accounts WHERE CUSTOMER IN (SELECT CUSTOMERNUMBER FROM dbo.UDF_GetUsersCustomers('+CAST(@.UserIDAS VARCHAR(4))+'))'+ @.Criteria+' AND code IN (SELECT DISTINCT StatusID FROM tbl_APR_Statuses WHERE SearchCategoryAllT1 = 1)'

SELECT @.SQLTier2Select='SELECT * FROM dbo.UDV_Tier2Accounts WHERE CUSTOMER IN (SELECT CUSTOMERNUMBER FROM dbo.UDF_GetUsersCustomers('+CAST(@.UserIDAS VARCHAR(4))+'))'+ @.Criteria+' AND code IN (SELECT DISTINCT StatusID FROM tbl_APR_Statuses WHERE SearchCategoryAllT2 = 1)'

END

if(@.Status='ALA')--All Active

BEGIN

SELECT @.SQLTier1Select='SELECT * FROM dbo.UDV_Tier1Accounts WHERE CUSTOMER IN (SELECT CUSTOMERNUMBER FROM dbo.UDF_GetUsersCustomers('+CAST(@.UserIDAS VARCHAR(4))+'))'+ @.Criteria+' AND code IN (SELECT DISTINCT StatusID FROM tbl_APR_Statuses WHERE SearchCategoryActiveT1 = 1)'

SELECT @.SQLTier2Select='SELECT * FROM dbo.UDV_Tier2Accounts WHERE CUSTOMER IN (SELECT CUSTOMERNUMBER FROM dbo.UDF_GetUsersCustomers('+CAST(@.UserIDAS VARCHAR(4))+'))'+ @.Criteria+' AND code IN (SELECT DISTINCT StatusID FROM tbl_APR_Statuses WHERE SearchCategoryActiveT2 = 1)'

END

if(@.Status='ALI')--All Inactive

BEGIN

SELECT @.SQLTier1Select='SELECT * FROM dbo.UDV_Tier1Accounts WHERE CUSTOMER IN (SELECT CUSTOMERNUMBER FROM dbo.UDF_GetUsersCustomers('+CAST(@.UserIDAS VARCHAR(4))+'))'+ @.Criteria+' AND code IN (SELECT DISTINCT StatusID FROM tbl_APR_Statuses WHERE SearchCategoryInactiveT1 = 1)'

SELECT @.SQLTier2Select='SELECT TOP 1000 * FROM dbo.UDV_Tier2Accounts WHERE CUSTOMER IN (SELECT CUSTOMERNUMBER FROM dbo.UDF_GetUsersCustomers('+CAST(@.UserIDAS VARCHAR(4))+'))'+ @.Criteria+' AND code IN (SELECT DISTINCT StatusID FROM tbl_APR_Statuses WHERE SearchCategoryInactiveT2 = 1)'

END

END

ELSEIF @.Status='PAID'

BEGIN

SELECT @.SQLTier1Select='SELECT * FROM dbo.UDV_Tier1Accounts WHERE CUSTOMER IN (SELECT CUSTOMERNUMBER FROM dbo.UDF_GetUsersCustomers('+CAST(@.UserIDAS VARCHAR(4))+'))'+ @.Criteria+' AND (number IN (SELECT DISTINCT ph1.number FROM Collect2000.dbo.payhistory ph1 LEFT JOIN Collect2000.dbo.payhistory ph2 ON ph1.UID = ph2.ReverseOfUID WHERE (((ph1.batchtype = ''PU'') OR (ph1.batchtype = ''PC'')) AND ph2.ReverseOfUID IS NULL)) OR code IN (SELECT DISTINCT StatusID FROM tbl_APR_Statuses WHERE SearchCategoryPaidPaymentsT1 = 1))'

SELECT @.SQLTier2Select='SELECT * FROM dbo.UDV_Tier2Accounts WHERE CUSTOMER IN (SELECT CUSTOMERNUMBER FROM dbo.UDF_GetUsersCustomers('+CAST(@.UserIDAS VARCHAR(4))+'))'+ @.Criteria+' AND (number IN (SELECT DISTINCT ph1.number FROM Collect2000Tier2.dbo.payhistory ph1 LEFT JOIN Collect2000Tier2.dbo.payhistory ph2 ON ph1.UID = ph2.ReverseOfUID WHERE (((ph1.batchtype = ''PU'') OR (ph1.batchtype = ''PC'')) AND ph2.ReverseOfUID IS NULL)) OR code IN (SELECT DISTINCT StatusID FROM tbl_APR_Statuses WHERE SearchCategoryPaidPaymentsT2 = 1))'

END

ELSE

BEGIN

SELECT @.SQLTier1Select='SELECT * FROM dbo.UDV_Tier1Accounts WHERE CUSTOMER IN (SELECT CUSTOMERNUMBER FROM dbo.UDF_GetUsersCustomers('+CAST(@.UserIDAS VARCHAR(4))+'))'+ @.Criteria

SELECT @.SQLTier2Select='SELECT * FROM dbo.UDV_Tier2Accounts WHERE CUSTOMER IN (SELECT CUSTOMERNUMBER FROM dbo.UDF_GetUsersCustomers('+CAST(@.UserIDAS VARCHAR(4))+'))'+ @.Criteria

END

SELECT @.SQL=CASE @.Tier

WHEN 0THEN @.SQLTier1Select+' UNION '+ @.SQLTier2Select+'ORDER BY NAME ASC'

WHEN 1THEN @.SQLTier1Select+'ORDER BY NAME ASC'

WHEN 2THEN @.SQLTier2Select+'ORDER BY NAME ASC '

END

PRINT @.SQL

--SELECT @.SQL

EXEC(@.SQL)

Could you help us help you better by opening your stored procedure up in a query analyzer (like SQL 2005 QA or SQL Express Managment Studio) and parsing the query to determine what line number and what the syntax error is?

That is a lot of code and would be difficult for us to go over line by line to determine what the issue is.

|||

I do not have SQL Query Analyzer. Here is the error I get when I saw in event viewer

Transaction (Process ID 64) was deadlocked on lock | communication buffer resources with another process and has been chosen as the deadlock victim. Rerun the transaction., Error Source:.Net SqlClient Data Provider.

|||

there's a lock on one of the tables your trying to do an insert on or update on. Talk with your DBA about that error and let him/her know what the Process ID is to help track it down.

Out of curiosity, what environment are you writing your stored procedures in?

|||

I'm writing my stored procedure in SQL Server Management Studio Express

|||

In SQL Server Management Studio Express you can parse your query (stored procedure syntax) and it will either tell you the syntax error along with the line number or tell you that the command was successful, which means you can run (execute) it and thus create your stored procedure.

Monday, March 19, 2012

Error in returning values when using >=

if i have the following data:
Name
--
SILFL-CFL-ELI24-220-GR
SILFL-CFL-ELI24-220-WH
SILFL-CFL-TOP-GLASS
SILFL-CFL-TOP-LOUVER
SILFL-CFL-TOP218-WH
SILFL-CFL-TOP226-WH
SILFL-FLU-EST18-220-WH
SILFL-FLU-EST36-220-WH
SILFL-FLU-FLA08-220-WH
SILFL-FLU-FLA13-220-WH
SILFL-FLU-MAR/P-218-220
SILFL-FLU-MAR/P-236-220-EB
SILFL-FLU-MAR/P-236-220-EES
SILFL-FLU-MAR/P-236-220
SILFL-FLU-STY108-220-WH
SILFL-FLU-STY113-220-WH
SILFL-FLU-STY15-220-BK
SILFL-FLU-STY15-220-WH
SILFL-FLU-STY18-220-BK
SILFL-FLU-STY18-220-WH
SILFL-FLU-STY30-220-BK
SILFL-FLU-STY30-220-WH
SILFL-FLU-STY36-220-BK
SILFL-FLU-STY36-220-WH
SILFL-GLS-GLOB-220-BK
SILFL-GLS-GLOB-220-WH
SILFL-GLS-ROLL-220-WH
SILFL-GLS-ROLL-220V-BK
SILFL-HPD-INT-ARCLT-150-WH
- When i run the following query no data is returned:
Select *
from TableName
where Name >= 'SILFL'
- If I add a dash the correct data is returned.
Select *
from TableName
where Name >= 'SILFL-'
Why is SQL Server seeing the string 'SILFL' as smaller than 'SILFL-'I believe that this is to do with the collation you have on your server.
Out of interest I did the same thing and got back the correct results.
You can probably get back the correct results by doing the following...
SELECT *
FROM YourTable
WHERE cast(Info as nvarchar(100)) >= N'S'
"Happiness is having a large, loving, caring, close-knit family in another
city."
George Burns
Anyway have a look at your collation and read about it on BOL.
Peter
"Nadim Wakim" wrote:

> if i have the following data:
> Name
> --
> SILFL-CFL-ELI24-220-GR
> SILFL-CFL-ELI24-220-WH
> SILFL-CFL-TOP-GLASS
> SILFL-CFL-TOP-LOUVER
> SILFL-CFL-TOP218-WH
> SILFL-CFL-TOP226-WH
> SILFL-FLU-EST18-220-WH
> SILFL-FLU-EST36-220-WH
> SILFL-FLU-FLA08-220-WH
> SILFL-FLU-FLA13-220-WH
> SILFL-FLU-MAR/P-218-220
> SILFL-FLU-MAR/P-236-220-EB
> SILFL-FLU-MAR/P-236-220-EES
> SILFL-FLU-MAR/P-236-220
> SILFL-FLU-STY108-220-WH
> SILFL-FLU-STY113-220-WH
> SILFL-FLU-STY15-220-BK
> SILFL-FLU-STY15-220-WH
> SILFL-FLU-STY18-220-BK
> SILFL-FLU-STY18-220-WH
> SILFL-FLU-STY30-220-BK
> SILFL-FLU-STY30-220-WH
> SILFL-FLU-STY36-220-BK
> SILFL-FLU-STY36-220-WH
> SILFL-GLS-GLOB-220-BK
> SILFL-GLS-GLOB-220-WH
> SILFL-GLS-ROLL-220-WH
> SILFL-GLS-ROLL-220V-BK
> SILFL-HPD-INT-ARCLT-150-WH
> - When i run the following query no data is returned:
> Select *
> from TableName
> where Name >= 'SILFL'
>
> - If I add a dash the correct data is returned.
> Select *
> from TableName
> where Name >= 'SILFL-'
> Why is SQL Server seeing the string 'SILFL' as smaller than 'SILFL-'
>
>|||Becuase it is. Anything with 4 characters is "smaller" than the same thing
with any character added at the end.
abcd' < 'abcd' + 'a'
What I Don't understand is why the query is not returning anything. All
those values are > 'SILFL', because 'SILFL' is < than all of them.
When I run the following, ALL The records are returned...
Create Table Test (Col VarCHar(50))
Insert Test (Col) VAlues ('SILFL-CFL-ELI24-220-GR')
Insert Test (Col) VAlues ('SILFL-CFL-ELI24-220-WH')
Insert Test (Col) VAlues ('SILFL-CFL-TOP-GLASS')
Insert Test (Col) VAlues ('SILFL-CFL-TOP-LOUVER')
Insert Test (Col) VAlues ('SILFL-CFL-TOP218-WH')
Insert Test (Col) VAlues ('SILFL-CFL-TOP226-WH')
Insert Test (Col) VAlues ('SILFL-FLU-EST18-220-WH')
Insert Test (Col) VAlues ('SILFL-FLU-EST36-220-WH')
Insert Test (Col) VAlues ('SILFL-FLU-FLA08-220-WH')
Insert Test (Col) VAlues ('SILFL-FLU-FLA13-220-WH')
Insert Test (Col) VAlues ('SILFL-FLU-MAR/P-218-220')
Insert Test (Col) VAlues ('SILFL-FLU-MAR/P-236-220-EB')
Insert Test (Col) VAlues ('SILFL-FLU-MAR/P-236-220-EES')
Insert Test (Col) VAlues ('SILFL-FLU-MAR/P-236-220')
Insert Test (Col) VAlues ('SILFL-FLU-STY108-220-WH')
Insert Test (Col) VAlues ('SILFL-FLU-STY113-220-WH')
Insert Test (Col) VAlues ('SILFL-FLU-STY15-220-BK')
Insert Test (Col) VAlues ('SILFL-FLU-STY15-220-WH')
Insert Test (Col) VAlues ('SILFL-FLU-STY18-220-BK')
Insert Test (Col) VAlues ('SILFL-FLU-STY18-220-WH')
Insert Test (Col) VAlues ('SILFL-FLU-STY30-220-BK')
Insert Test (Col) VAlues ('SILFL-FLU-STY30-220-WH')
Insert Test (Col) VAlues ('SILFL-FLU-STY36-220-BK')
Insert Test (Col) VAlues ('SILFL-FLU-STY36-220-WH')
Insert Test (Col) VAlues ('SILFL-GLS-GLOB-220-BK')
Insert Test (Col) VAlues ('SILFL-GLS-GLOB-220-WH')
Insert Test (Col) VAlues ('SILFL-GLS-ROLL-220-WH')
Insert Test (Col) VAlues ('SILFL-GLS-ROLL-220V-BK')
Insert Test (Col) VAlues ('SILFL-HPD-INT-ARCLT-150-WH')
Select * from Test
where Col >= 'SILFL-'
"Nadim Wakim" wrote:

> if i have the following data:
> Name
> --
> SILFL-CFL-ELI24-220-GR
> SILFL-CFL-ELI24-220-WH
> SILFL-CFL-TOP-GLASS
> SILFL-CFL-TOP-LOUVER
> SILFL-CFL-TOP218-WH
> SILFL-CFL-TOP226-WH
> SILFL-FLU-EST18-220-WH
> SILFL-FLU-EST36-220-WH
> SILFL-FLU-FLA08-220-WH
> SILFL-FLU-FLA13-220-WH
> SILFL-FLU-MAR/P-218-220
> SILFL-FLU-MAR/P-236-220-EB
> SILFL-FLU-MAR/P-236-220-EES
> SILFL-FLU-MAR/P-236-220
> SILFL-FLU-STY108-220-WH
> SILFL-FLU-STY113-220-WH
> SILFL-FLU-STY15-220-BK
> SILFL-FLU-STY15-220-WH
> SILFL-FLU-STY18-220-BK
> SILFL-FLU-STY18-220-WH
> SILFL-FLU-STY30-220-BK
> SILFL-FLU-STY30-220-WH
> SILFL-FLU-STY36-220-BK
> SILFL-FLU-STY36-220-WH
> SILFL-GLS-GLOB-220-BK
> SILFL-GLS-GLOB-220-WH
> SILFL-GLS-ROLL-220-WH
> SILFL-GLS-ROLL-220V-BK
> SILFL-HPD-INT-ARCLT-150-WH
> - When i run the following query no data is returned:
> Select *
> from TableName
> where Name >= 'SILFL'
>
> - If I add a dash the correct data is returned.
> Select *
> from TableName
> where Name >= 'SILFL-'
> Why is SQL Server seeing the string 'SILFL' as smaller than 'SILFL-'
>
>

Sunday, February 26, 2012

Error in DMX query

Hi

I have the following query used to predict the values in 2006 based on cluster model built using 2004 and 2005 data. I'm using a prediction join on a cube containing the data. I can join a single dimension from the cube to a column in a the data mining model. However when I try to join to a column in a nested table I get this error:

Executing the query ...

Obtained object of type: Microsoft.AnalysisServices.AdomdClient.AdomdDataReader

Internal error: An unexpected exception occured.

Execution complete

The query I'm running is this

select t.*

, Predict([Time].[Deal Count])as predicted_deal_count

, Predict([Time].[Deal Revenue])as predicted_deal_revenue

, Cluster()

From

[Time]

prediction join

(

select {[Measures].[Deal Count], [Measures].[Deal Revenue]} on 0,

non empty {{[Time].[Month Number Of Year].[Month Number Of Year].members} *

{[Country].[KeyCountry].[KeyCountry].members} * {[Country].[Region].[Region].members}} on 1

from [DM]

where ([Time].[Year].&[2006-01-01T00:00:00])) as t

on

[Time].[Month Number Of Year] = t.[[Time]].[Month Number Of Year]].[Month Number Of Year]].[MEMBER_CAPTION]]]

and [Time].[Country].[KeyCountry] = t.[[Country]].[KeyCountry]].[KeyCountry]].[MEMBER_CAPTION]]]

and [Time].[Country].[Region] = t.[[Country]].[Region]].[Region]].[MEMBER_CAPTION]]]

I'm running SQL Server 2005 with SP2 CTP2.

Thanks

Sanjay

Given the limited error message - we need to try additional queries to see if we can narrow the problem down. Alternatively, you could send us a backup of your database - let me know if this is an option.

Can you see if this query works? Does it return what you expect?

select t.*

From

[Time]

NATURAL prediction join

(

select {[Measures].[Deal Count], [Measures].[Deal Revenue]} on 0,

non empty {{[Time].[Month Number Of Year].[Month Number Of Year].members} *

{[Country].[KeyCountry].[KeyCountry].members} * {[Country].[Region].[Region].members}} on 1

from [DM]

where ([Time].[Year].&[2006-01-01T00:00:00])) as t

|||

Hi,

Your query works as expected, all the selected data from the cube is return. It would be possible to send you the cube offline, do you need the just the cube or the relational db as well?

Thanks

Sanjay

|||

A backup of AS database with the cube and model is enough. Please remove any additional objects (e.g. cubes or mining structures) to reduce the database size. You can also do a process clear structure only on the Mining Structure to reduce the size even further. Try compressing it as well (although it should be compressed already).

You can send the data to jamie "at" sqlserverdatamining.com and we'll look into the issue

Thanks!

|||We are still looking into this issue - thanks for your patience.

Wednesday, February 15, 2012

Error handling problem

I am running SQL 2000.
I have several procedures where I do general validation on entered values.
User procedures typically call these "checkprocedures" to verify all entered
values.
I thought I grasped the idea of error handling but must have done something
wrong.
When a wrong value is found I throw an exception in the checking procedure
and return an arbitrary return code other than 0, typically 1.
In the calling procedure I check the @.@.ERROR value and then take action
based on that. The problem is that excution does not stop after the exceptio
n
is thrown even if I explicitly end with a Return in the calling procedure.
What is wrong?
Why does not the execution in the main procedure stop?
Maybe it is overkill to use both exceptions and return values:
Should I skip the exception throwing and rely on the Return values?
Should I skip the Return values and rely on the exception throwing?
My idea was to avoid defining the validation and exception messages on many
places.
Code example enclosed below:
CREATE PROCEDURE dbo.CheckLanguage
@.LanguageKey char(5),
@.LanguageID int OUT
AS
SET @.LanguageID = NULL
-- Check if given language exists
SELECT @.LanguageID = LanguageID
FROM Language
WHERE LanguageKey = @.LanguageKey
IF @.LanguageID IS NULL
BEGIN
RAISERROR ('This LanguageKey is not recognized as a valid language: %s',
16, 1, @.LanguageKey)
RETURN 1
END
GO
Calling procedure contains this code:
....
-- Make sure the given language key is valid
EXEC CheckLanguage @.LanguageKey, @.LanguageID OUT
SET @.ErrorNumber = @.@.ERROR
IF @.ErrorNumber <> 0
BEGIN
SET @.Response = 'Error_LanguageKey'
RETURN 0
END
...It seems it is the RETURN statement after the RAISERROR that resets the
@.@.ERROR to 0 again, making the calling procedure ....
What would you recommend?
Should I use RAISERROR or RETURN in the check procedure to inform the
calling procedure about the error?
I tend to the RAISERROR ....|||Since the procedure executes OK even if @.LanguageID is NULL, @.@.ERROR in your
calling statement will always be 0. @.@.ERROR traps the error number for the
most recently executed statement.
You need something like this
CREATE PROCEDURE dbo.CheckLanguage
@.LanguageKey char(5),
@.LanguageID int OUT
AS
SET @.LanguageID = NULL
-- Check if given language exists
SELECT @.LanguageID = LanguageID
FROM Language
WHERE LanguageKey = @.LanguageKey
IF @.LanguageID IS NULL
BEGIN
RAISERROR ('This LanguageKey is not recognized as a valid language: %s',
16, 1, @.LanguageKey)
RETURN 1
END
Calling procedure contains this code:
....
-- Make sure the given language key is valid
DECLARE @.return_status int
EXEC @.return_status = CheckLanguage @.LanguageKey, @.LanguageID OUT
IF @.return_status = 1
BEGIN
SET @.Response = 'Error_LanguageKey'
RETURN 0
END
...
"Jakob Lithner" wrote:

> I am running SQL 2000.
> I have several procedures where I do general validation on entered values.
> User procedures typically call these "checkprocedures" to verify all enter
ed
> values.
> I thought I grasped the idea of error handling but must have done somethin
g
> wrong.
> When a wrong value is found I throw an exception in the checking procedure
> and return an arbitrary return code other than 0, typically 1.
> In the calling procedure I check the @.@.ERROR value and then take action
> based on that. The problem is that excution does not stop after the except
ion
> is thrown even if I explicitly end with a Return in the calling procedure.
> What is wrong?
> Why does not the execution in the main procedure stop?
> Maybe it is overkill to use both exceptions and return values:
> Should I skip the exception throwing and rely on the Return values?
> Should I skip the Return values and rely on the exception throwing?
> My idea was to avoid defining the validation and exception messages on man
y
> places.
>
> Code example enclosed below:
> CREATE PROCEDURE dbo.CheckLanguage
> @.LanguageKey char(5),
> @.LanguageID int OUT
> AS
> SET @.LanguageID = NULL
> -- Check if given language exists
> SELECT @.LanguageID = LanguageID
> FROM Language
> WHERE LanguageKey = @.LanguageKey
>
> IF @.LanguageID IS NULL
> BEGIN
> RAISERROR ('This LanguageKey is not recognized as a valid language: %s',
> 16, 1, @.LanguageKey)
> RETURN 1
> END
> GO
>
> Calling procedure contains this code:
> ....
> -- Make sure the given language key is valid
> EXEC CheckLanguage @.LanguageKey, @.LanguageID OUT
> SET @.ErrorNumber = @.@.ERROR
> IF @.ErrorNumber <> 0
> BEGIN
> SET @.Response = 'Error_LanguageKey'
> RETURN 0
> END
> ...|||Thanks, I guess that is the best solution!