Quantcast
Channel: SCN: Message List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 9165

Re: IF statement syntax in SQL script view

$
0
0

Hi Lakshmi,

below is the syntax for IF statement.

 

IF <bool_expr1> THEN

<then_stmts1>

[

{

ELSEIF <bool_expr2>

THEN <then_stmts2>

}...]

[ELSE <else_stmts3>]

END IF

 

 

 

eg :

 

 

BEGIN

DECLARE found INT := 1;

SELECT count(*) INTO found FROM books WHERE isbn = :v_isbn;

IF :found = 0 THEN

INSERT INTO books VALUES (:v_isbn, 'In-Memory Data Management', 1, 1, '2011', 42.75, 'EUR');

ELSE

UPDATE books SET price = 42.75 WHERE isbn =:v_isbn;

END IF;

END;

 

Sreehari


Viewing all articles
Browse latest Browse all 9165

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>