on 2021 Sep 08 5:44 AM
Have a use case where flyway will execute the migration for script which creates a view in the Hana.
generally in SQL, we use DROP IF EXIST my_user_view; which prevents the script from erroring out for duplicate names. But in Hana database exists function can only be used in blocks and block doesn't allow DDL DROP statement in it.
tried following approach but didn't work..
DO
BEGIN
IF EXISTS(SELECT 1 FROM views v WHERE v.view_name = 'my_user_view')
THEN
DROP VIEW "my_user_view";-- CREATE/DROP statement within anonymous block feature not supported error
END IF;
END;
Request clarification before answering.
What HANA version you are using? Would it be an option for you to use the CREATE OR REPLACE option for a view which is available since HANA 2.0 SPS04 (CREATE VIEW Statement (Data Definition) - SAP Help Portal)?
With the "OR REPLACE" addition your existing view would be replaced with the new definition. No drop is necessary in that case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
11 | |
8 | |
8 | |
6 | |
6 | |
5 | |
5 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.