Skip to Content

Stored Procedure Script

Hi experts,

Just want to ask a big favor, iam new to stored procedure, please check my script if its correct: all i want is all if ocrcode code is null or ocrcode5 is null and also invtype = 13 then message 'Please Choose Branch and Department' will show.

please check my script below - thank you very much in advance...

if (@object_type = '24 ') and (@transaction_type= 'A' or @transaction_type= 'U')

BEGIN

If Exists (Select T0.DocNum from ORCT T0 Inner Join RCT2 T1 On T0.DocNum=T1.DocNum

Where T1.OcrCode Is Null And T0.DocNum = @list_of_cols_val_tab_del And T1.InvType = '13' or T1.OcrCode5 Is Null And T0.TransId = @list_of_cols_val_tab_del And T1.InvType = '13' )

BEGIN

Select @error = -1,

@error_message = 'Please Choose Branch and Department'

End

End

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 20, 2015 at 06:53 AM

    Hi,

    As per your requirement you should use OR operator between OcrCode and OcrCode5.Kindly use the below one

    IF (@OBJECT_TYPE ='24' AND (@TRANSACTION_TYPE IN('A','U')))

    BEGIN

    IF EXISTS(

    Select T0.DocNum from ORCT T0 Inner Join RCT2 T1 On T0.DocNum=T1.DocNum

    Where (isnull(T1.OcrCode,'')='' or isnull(T1.OcrCode5,'')='') And T0.DocEntry = @list_of_cols_val_tab_del

    And T1.InvType = '13'

    )

    BEGIN

    SELECT @error=100001, @error_message='Please Choose Branch and Department'

    END

    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.