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

SAP HANA: How to Assign a Scalar Query Result to a Variable in a Procedure

Dear All,

I would like to ask, how do we assign a scalar query result to a variable in a procedure on SAP HANA?

Thank you for your help.



Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • Posted on Aug 29, 2013 at 11:06 AM

    See example from help documentation. You can use SELECT INTO clause.

    CREATE PROCEDURE upsert_proc (IN v_isbn VARCHAR(20))



    DECLARE found INT := 1;

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

    IF :found = 0


    INSERT INTO books

    VALUES (:v_isbn, 'In-Memory Data Management', 1, 1,

    '2011', 42.75, 'EUR');


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

    END IF;


    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.