admin管理员组

文章数量:1122846

IF inOverseasFlag = 'YES' THEN
    ELSE 
     SELECT MPMD06X, -- Account Name
                  MPMD04X, -- Sort Code
                  MPMD05X, -- Account Number              
                  MPMD09X  -- BS Rollno
      INTO vBankAccountName, vBankSortCode, vBankAccountNumber, vBsRollNo
      FROM MP_Mandate
      WHERE BGroup = inBGroup
      AND Mandate = inMandate;
    END IF;
IF inOverseasFlag = 'YES' THEN
    ELSE 
     SELECT MPMD06X, -- Account Name
                  MPMD04X, -- Sort Code
                  MPMD05X, -- Account Number              
                  MPMD09X  -- BS Rollno
      INTO vBankAccountName, vBankSortCode, vBankAccountNumber, vBsRollNo
      FROM MP_Mandate
      WHERE BGroup = inBGroup
      AND Mandate = inMandate;
    END IF;
Share Improve this question edited Nov 21, 2024 at 18:34 msanford 12.2k13 gold badges71 silver badges98 bronze badges asked Nov 21, 2024 at 18:31 AlexAlex 1 3
  • 1 I think you want IF inOverseasFlag != 'YES' THEN SELECT MPMD06X, etc. != means does not equal. Documentation: Comparison Conditions. "If A Then X Else Y" is logically the same as "If !A Then Y Else X" where A is a binary condition. – Andrew Morton Commented Nov 21, 2024 at 18:41
  • @AndrewMorton unless inOverseasFlag can be null. – William Robertson Commented Nov 24, 2024 at 18:39
  • @WilliamRobertson That's why I wrote "where A is a binary condition." – Andrew Morton Commented Nov 25, 2024 at 8:13
Add a comment  | 

1 Answer 1

Reset to default 1

"Do nothing" in pl/sql can be achieved with the NULL statement. The NULL statement is a ''no-op" (no operation)—it only passes control to the next statement. Sometimes it can be useful to write an branch in an IF ELSEIF statement that doesn't do anything but makes code more understandable. It also comes in handy when writing new code as a temporary placeholder.

Example:

DECLARE
  l_var VARCHAR2(100);
BEGIN
  IF (l_var = 'FOO') THEN
    -- no action needed for FOO, but showing it here anyway.
    NULL;
  ELSIF (l_var = 'BAR') THEN 
    dbms_output.put_line('BAR');
  END IF;
END;

For reference, here is the documentation

本文标签: plsqlIn the if statement I would like the first parameter to do nothingStack Overflow