I'm using this statement in my sp to check a paramter value:
IF @.MESSAGE_CODE <> 2
The paramter is defined like @.MESSAGE_CODE NUMERIC ,I print the value and
it;s for example 1 but it never gets into the preceding block. 1<> 2 ,right?
but it dosen't work.
Any suggestions,
ThanksHow can we reproduce the problem?
If @.MESSAGE_CODE is null, then it is not considered as diff.
Example:
if null != 2 print 'hello!'
else print 'hi!'
AMB
"Ray5531" wrote:
> I'm using this statement in my sp to check a paramter value:
> IF @.MESSAGE_CODE <> 2
> The paramter is defined like @.MESSAGE_CODE NUMERIC ,I print the value and
> it;s for example 1 but it never gets into the preceding block. 1<> 2 ,righ
t?
> but it dosen't work.
> Any suggestions,
> Thanks
>
>|||Ray said: ,I print the value and it;s for example 1
It's not null:-) I'm printing the paramtere.
Thanks
"Alejandro Mesa" <AlejandroMesa@.discussions.microsoft.com> wrote in message
news:C872E8D0-B347-4FC1-A1CE-D0C43134CF93@.microsoft.com...
> How can we reproduce the problem?
> If @.MESSAGE_CODE is null, then it is not considered as diff.
> Example:
> if null != 2 print 'hello!'
> else print 'hi!'
>
> AMB
> "Ray5531" wrote:
>|||Well, your post is incomplete, It's probably some syntax error, but without
looking at SP Code, it's impossible to guess...
Post the complete code...
"Ray5531" wrote:
> I'm using this statement in my sp to check a paramter value:
> IF @.MESSAGE_CODE <> 2
> The paramter is defined like @.MESSAGE_CODE NUMERIC ,I print the value and
> it;s for example 1 but it never gets into the preceding block. 1<> 2 ,righ
t?
> but it dosen't work.
> Any suggestions,
> Thanks
>
>|||Ray5531 wrote:
> I'm using this statement in my sp to check a paramter value:
> IF @.MESSAGE_CODE <> 2
> The paramter is defined like @.MESSAGE_CODE NUMERIC ,I print the value
> and it;s for example 1 but it never gets into the preceding block.
> 1<> 2 ,right? but it dosen't work.
> Any suggestions,
> Thanks
Must be a syntax issue as others have stated:
declare @.n numeric
set @.n = 1
print @.n
if @.n <> 2
print 'not equal'
Make sure you have a Begin / End after the IF block if you are using
more than one statement after the IF (good idea to use them in any
case).
David Gugick
Imceda Software
www.imceda.com|||here is the complete sp code:
CREATE PROCEDURE [dbo].[IF_InsertLog]
@.INTERNAL_FILEID NUMERIC,
@.AFFILIATE_ID NUMERIC=NULL,
@.CLIENT_ID VARCHAR(10)=NULL,
@.LINE_NUMBER NUMERIC,
@.COLUMN_ORDER NUMERIC,
@.MESSAGE_CODE NUMERIC,
@.MESSAGE VARCHAR(500),
@.CREATED_BY_USER VARCHAR(30),
@.C1STATUS_CODE VARCHAR(6)=NULL
AS
SET NOCOUNT ON
DECLARE @.NEW_LOGENTRY VARCHAR(1)
DECLARE @.C4ENROLLMENT_ID NUMERIC(9)
DECLARE @.C4ENROLMENT_WITHERROR_COUNT NUMERIC(9)
SET @.C4ENROLLMENT_ID= (SELECT CAST(ENROLLMENT_ID AS NUMERIC(9)) FROM
dbo.IF_C4TRANSFORM WHERE FILEID=1355 AND
LINE_NUMBER=5)
IF @.MESSAGE_CODE <> 2
IF @.CREATED_BY_USER='C1_DTS'
IF EXISTS (SELECT LOG_ID FROM IF_LOG WHERE
AFFILIATE_ID=@.AFFILIATE_ID AND CLIENT_ID= @.CLIENT_ID AND
COLUMN_ORDER=@.COLUMN_ORDER AND CREATED_BY_USER=@.CREATED_BY_USER )
SET @.NEW_LOGENTRY='N'
ELSE
SET @.NEW_LOGENTRY='Y'
ELSE IF (@.CREATED_BY_USER='C4_DTS')
BEGIN
SELECT @.C4ENROLLMENT_ID=CAST(ENROLLMENT_ID AS NUMERIC(9)) FROM
dbo.IF_C4TRANSFORM WHERE FILEID=@.INTERNAL_FILEID AND
LINE_NUMBER=@.LINE_NUMBER
SELECT @.C4ENROLMENT_WITHERROR_COUNT = COUNT(*) FROM dbo.IF_C4TRANSFORM
T1 INNER JOIN dbo.IF_C4TRANSFORM T2 ON
T1.ENROLLMENT_ID = T2.ENROLLMENT_ID AND
T1.ERROR_STATUS = T2.ERROR_STATUS
IF @.C4ENROLMENT_WITHERROR_COUNT > 0
SET @.NEW_LOGENTRY='N'
ELSE
SET @.NEW_LOGENTRY='Y'
END
ELSE IF (@.CREATED_BY_USER='C4_DTS_HISTORY')
IF EXISTS (SELECT LOG_ID FROM IF_LOG WHERE
AFFILIATE_ID=@.AFFILIATE_ID AND CLIENT_ID= @.CLIENT_ID AND
COLUMN_ORDER=@.COLUMN_ORDER AND CREATED_BY_USER=@.CREATED_BY_USER )
SET @.NEW_LOGENTRY='N'
ELSE
SET @.NEW_LOGENTRY='Y'
ELSE
SET @.NEW_LOGENTRY='U'
ELSE
PRINT 'A Warning has been reported and there is no need for New/OLD
detection'
SET @.NEW_LOGENTRY=@.MESSAGE_CODE
INSERT INTO DBO.IF_LOG (INTERNAL_FILEID,
AFFILIATE_ID,
CLIENT_ID,
LINE_NUMBER,
COLUMN_ORDER,
MESSAGE_CODE,
MESSAGE,
CREATED_BY_USER,
NEW_LOGENTRY,
C1STATUS_CODE,
C4ENROLLMENT_ID)
VALUES(@.INTERNAL_FILEID,
@.AFFILIATE_ID,
@.CLIENT_ID,
@.LINE_NUMBER,
@.COLUMN_ORDER,
@.MESSAGE_CODE,
@.MESSAGE,
@.CREATED_BY_USER,
@.NEW_LOGENTRY,
@.C1STATUS_CODE,
@.C4ENROLLMENT_ID)
GO|||Use BEGIN and END statements in all blocks and see if the problem still
occurs. Also, why have you chosen to use the NUMERIC data type? Why not
using something like an INT instead?
David Gugick
Imceda Software
www.imceda.com|||What's wrong with numeric?
Thanks
"David Gugick" <davidg-nospam@.imceda.com> wrote in message
news:%23$jgDwnUFHA.2128@.TK2MSFTNGP15.phx.gbl...
> Use BEGIN and END statements in all blocks and see if the problem still
> occurs. Also, why have you chosen to use the NUMERIC data type? Why not
> using something like an INT instead?
> --
> David Gugick
> Imceda Software
> www.imceda.com|||They store more information and so take up more space. If you do not need
to keep decimal places (very rare with IDs), you're better off with INT, and
I typically use SMALLINT or TINYINT in finite data sets.
Even the smallest NUMERIC declaration takes up one more byte than a full
INT. And the default (18,0) takes more than double (9 bytes).
http://www.aspfaq.com/2503
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.
"Ray5531" <RayAll@.microsft.com> wrote in message
news:OfF6x0nUFHA.580@.TK2MSFTNGP15.phx.gbl...
> What's wrong with numeric?|||Apparently there was some problem using INT and thet's what DBA forces us to
do.I don;t know why and I don't care.I've told not to use INT:-) I know
that's funny but you know....
"AB - MVP" <ten.xoc@.dnartreb.noraa> wrote in message
news:O2fC$QoUFHA.3572@.TK2MSFTNGP12.phx.gbl...
> They store more information and so take up more space. If you do not need
> to keep decimal places (very rare with IDs), you're better off with INT,
> and I typically use SMALLINT or TINYINT in finite data sets.
> Even the smallest NUMERIC declaration takes up one more byte than a full
> INT. And the default (18,0) takes more than double (9 bytes).
> http://www.aspfaq.com/2503
> --
> This is my signature. It is a general reminder.
> Please post DDL, sample data and desired results.
> See http://www.aspfaq.com/5006 for info.
>
>
> "Ray5531" <RayAll@.microsft.com> wrote in message
> news:OfF6x0nUFHA.580@.TK2MSFTNGP15.phx.gbl...
>sql
No comments:
Post a Comment