PageSourceSearch

https://docs.seekdb.ai/seekdb/assets/js/6a627ade.9de7cfc8.js

js seekdb.ai collected 2026-10-04 15:21:48 UTC 4,496 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunkionic_docs=self.webpackChunkionic_docs||[]).push([["119598"],{815775(e,n,t){t.r(n),t.d(n,{metadata:()=>s,default:()=>h,frontMatter:()=>i,contentTitle:()=>r,toc:()=>d,assets:()=>l});var s=JSON.parse('{"id":"reference/pl/control-statement/if-pl","title":"IF","description":"The IF statement is used to construct basic conditional statements.","source":"@site/versioned_docs/version-V1.2.0/450.reference/300.pl/400.control-statement/200.if-pl.md","sourceDirName":"450.reference/300.pl/400.control-statement","slug":"/if-pl","permalink":"/seekdb/V1.2.0/if-pl","draft":false,"unlisted":false,"editUrl":"https://github.com/oceanbase/seekdb-doc/edit/V1.2.0/en-US/450.reference/300.pl/400.control-statement/200.if-pl.md","tags":[],"version":"V1.2.0","sidebarPosition":200,"frontMatter":{"slug":"/if-pl"},"sidebar":"reference","previous":{"title":"CASE","permalink":"/seekdb/V1.2.0/case-pl"},"next":{"title":"ITERATE","permalink":"/seekdb/V1.2.0/iterate"}}'),c=t(474848),o=t(28453);let i={slug:"/if-pl"},r="IF",l={},d=[];function a(e){let n={code:"code",h1:"h1",header:"header",p:"p",pre:"pre",...(0,o.R)(),...e.components};return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(n.header,{children:(0,c.jsx)(n.h1,{id:"if",children:"IF"})}),"\n",(0,c.jsxs)(n.p,{children:["The ",(0,c.jsx)(n.code,{children:"IF"})," statement is used to construct basic conditional statements."]}),"\n",(0,c.jsxs)(n.p,{children:["The syntax of the ",(0,c.jsx)(n.code,{children:"IF"})," statement is as follows:"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sql",children:"IF search_condition THEN statement_list\n    [ELSEIF search_condition THEN statement_list] ...\n    [ELSE statement_list]\nEND IF\n"})}),"\n",(0,c.jsxs)(n.p,{children:["The ",(0,c.jsx)(n.code,{children:"IF"})," statement can contain ",(0,c.jsx)(n.code,{children:"THEN"}),", ",(0,c.jsx)(n.code,{children:"ELSE"}),", and ",(0,c.jsx)(n.code,{children:"ELSEIF"})," clauses and is terminated by ",(0,c.jsx)(n.code,{children:"END IF"}),"."]}),"\n",(0,c.jsxs)(n.p,{children:["If the specified ",(0,c.jsx)(n.code,{children:"search_condition"})," evaluates to True, the corresponding ",(0,c.jsx)(n.code,{children:"THEN"})," or ",(0,c.jsx)(n.code,{children:"ELSEIF"})," clause statement list is executed. If no ",(0,c.jsx)(n.code,{children:"search_condition"})," matches, the ",(0,c.jsx)(n.code,{children:"statement_list"})," in the ",(0,c.jsx)(n.code,{children:"ELSE"})," clause is executed."]}),"\n",(0,c.jsxs)(n.p,{children:["Each ",(0,c.jsx)(n.code,{children:"statement_list"})," consists of one or more SQL statements; empty ",(0,c.jsx)(n.code,{children:"statement_list"})," is not allowed."]}),"\n",(0,c.jsxs)(n.p,{children:["In stored programs, the ",(0,c.jsx)(n.code,{children:"IF ... END IF"})," block must be terminated with a semicolon (;). Like other flow control constructs, the ",(0,c.jsx)(n.code,{children:"IF ... END IF"})," block can be nested within other control statements, including ",(0,c.jsx)(n.code,{children:"IF"})," statements. Each ",(0,c.jsx)(n.code,{children:"IF"})," must be terminated with its own ",(0,c.jsx)(n.code,{children:"END IF;"}),". You can indent nested flow control blocks to make them easier to read, as shown in the following example:"]}),"\n",(0,c.jsx)(n.pre,{children:(0,c.jsx)(n.code,{className:"language-sql",children:"DELIMITER //\n\nCREATE FUNCTION comp_fuc (n INT, m INT)\n   RETURNS VARCHAR(50)\n\n   BEGIN\n     DECLARE x VARCHAR(50);\n\n     IF n = m THEN SET x = 'equal';\n     ELSE\n       IF n > m THEN SET x = 'greater than';\n       ELSE SET x = 'less than';\n       END IF;\n\n     END IF;\n\n     SET x = CONCAT(n, ' ', x, ' ', m, '.');\n     RETURN x;\n   END //\nQuery OK, 0 rows affected\n"})}),"\n",(0,c.jsxs)(n.p,{children:["In the preceding example, the inner ",(0,c.jsx)(n.code,{children:"IF"})," statement is only evaluated when ",(0,c.jsx)(n.code,{children:"n"})," is not equal to ",(0,c.jsx)(n.code,{children:"m"}),"."]})]})}function h(e={}){let{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,c.jsx)(n,{...e,children:(0,c.jsx)(a,{...e})}):a(e)}},28453(e,n,t){t.d(n,{R:()=>i,x:()=>r});var s=t(296540);let c={},o=s.createContext(c);function i(e){let n=s.useContext(o);return s.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function r(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(c):e.components||c:i(e.components),s.createElement(o.Provider,{value:n},e.children)}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.