We are creating a view in SQL to format data to DTS to another database. Here is the section of the view which does not work -- eliminating this section from the query allows the view to be created:
CASE APTran.LineNbr
WHEN < '0' THEN 'O'
--Offsetting Document (or transaction line as we have (AP Liab. AP Cash Entry).
WHEN > '0' THEN 'D'
--Regular Document (or transaction line as we have (This is either a Debit or a Credit line not AP Liab. AP Cash Entry).
ELSE 'E'
END AS JED_DIST_OR_OFF,
I am attaching the whole query stmt here.
Thanks very much for all assistance.Is LineNbr numeric?
--EDIT:
Can you tell us the error?
Might help|||The error received in Query analyzer is:
Server: Msg 170, Level 15, State 1, Procedure xvr_03901EXPORTER, Line 107
Line 107: Incorrect syntax near '<'.
Server: Msg 170, Level 15, State 1, Procedure xvr_03901EXPORTER, Line 133
Line 133: Incorrect syntax near 'APTran'.
Server: Msg 170, Level 15, State 1, Procedure xvr_03901EXPORTER, Line 186
Line 186: Incorrect syntax near 'APDoc'.
The field aptran.linenbr is datatype smallint.
Thanks, Dave Spangler|||CASE
WHEN cast(APTran.LineNbr as int) < 0 THEN 'O'
--Offsetting Document (or transaction line as we have (AP Liab. AP Cash Entry).
WHEN cast(APTran.LineNbr as int) > 0 THEN 'D'
--Regular Document (or transaction line as we have (This is either a Debit or a Credit line not AP Liab. AP Cash Entry).
ELSE 'E'
END AS JED_DIST_OR_OFF,|||Hey, based on the code you submitted before I clicked on Post, I thought (here's that magic word again ;)) that it was a varchar field!
CASE
WHEN APTran.LineNbr < 0 THEN 'O'
--Offsetting Document (or transaction line as we have (AP Liab. AP Cash Entry).
WHEN APTran.LineNbr > 0 THEN 'D'
--Regular Document (or transaction line as we have (This is either a Debit or a Credit line not AP Liab. AP Cash Entry).
ELSE 'E'
END AS JED_DIST_OR_OFF,
And you probably need to test for NULL unless this is taken care of by the 'IsNullable' property of the field.|||Originally posted by rdjabarov
Hey, based on the code you submitted before I clicked on Post, I thought (here's that magic word again ;)) that it was a varchar field!
CASE
WHEN APTran.LineNbr < 0 THEN 'O'
--Offsetting Document (or transaction line as we have (AP Liab. AP Cash Entry).
WHEN APTran.LineNbr > 0 THEN 'D'
--Regular Document (or transaction line as we have (This is either a Debit or a Credit line not AP Liab. AP Cash Entry).
ELSE 'E'
END AS JED_DIST_OR_OFF,
And you probably need to test for NULL unless this is taken care of by the 'IsNullable' property of the field.
Hey, get your own ideas...:D
And why would they have to check for Nulls Null would give them an "E"|||Yup, forgot about ELSE
No comments:
Post a Comment