Skip to Content
0

Data Type Mismatch

Aug 11, 2017 at 09:23 PM

50

avatar image

I'm trying to create a formatted search, which includes the following snippet of code:

IF $[ORDR.CardCode] in (select cardcode from ocrd where groupcode = 256 and slpcode = 22) SELECT 'Text String'

When I trigger the FMS, I get the following error

Conversion Failed when converting the nvarchar value 'C12345' to data type int.

In this instance, CardCode translates to 'C12345'. I don't see why it is trying to convert the cardcode to data type int. I don't get an error when I run the code in SSMS (after replacing the field reference with the actual CardCode, of course).

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Randy Davis Aug 11, 2017 at 10:29 PM
0

The above snippet is just part of a larger FMS. Here is the entire code:

--Split Commission Rep
BEGIN
IF (SELECT MAX(T0.DiscPrcnt) 
		from RDR1 T0 
			inner join ORDR T1 on T1.DocEntry = T0.DocEntry
		where T1.DocNum = $[ORDR.DocNum])>=70
	SELECT 'Text 1'
ELSE
	IF $[ORDR.CardCode] in (select cardcode from ocrd where groupcode = 256 and slpcode = 22)
		SELECT 'Text 2'
ELSE SELECT '' END

The expected result is 'Text 1', 'Text 2' or blank. There error comes from the original code snippet.

Share
10 |10000 characters needed characters left characters exceeded
Nagarajan K Aug 11, 2017 at 10:14 PM
0

Hi,

What is your expected result from above FMS?

Regards,

Nagarajan

Share
10 |10000 characters needed characters left characters exceeded