Skip to Content
author's profile photo Former Member
Former Member

Query error

query on UDF

IF $[OIGE.Series.Number]= 65

begin

Select OIGN.U_BP_Name From OIGN where DocNum =$[OIGE.U_JW_NO]

End

If $[OIGE.Series]= 64

Begin

select CardName from OCRD

END

If $[OIGE.Series]= 17

Begin

select CardName from OCRD

END

when i m executing this query it generate this error :

Error. [Microsoft][SQL Native Client][SQL Server]Incorrect syntax near

the keyword 'FOR'. 2). [Microsoft][SQL Native Client][SQL

Server]Statement '' (NFN1) (s) could not be prepared.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 20, 2010 at 02:35 PM

    Try this:

    SELECT CASE 
          WHEN $[OIGE.Series] = 65 THEN (Select OIGN.U_BP_Name From OIGN where DocNum =$[OIGE.U_JW_NO])
          WHEN $[OIGE.Series] IN (64, 17) THEN (Select T0.CardName from OCRD T0 WHERE T0.CardCode=$[OIGE.CardCode]
    END
    

    Thanks,

    Gordon

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 20, 2010 at 01:19 PM

    Try this one:

    SELECT  CASE 
             WHEN $[OIGE.Series] = 65 THEN (Select OIGN.U_BP_Name From OIGN where DocNum =$[OIGE.U_JW_NO])
             WHEN $[OIGE.Series] = 64 THEN (Select T0.CardName from OCRD T0)
             WHEN $[OIGE.Series] = 17 THEN (Select T0.CardName from OCRD T0)
          END
    

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.