Skip to Content
0

DDL in Stored procedures

Oct 20, 2016 at 11:27 AM

136

avatar image
Former Member

Hi All,

I would like to create a stored procedure to drop and create a synonym where the synonym will be passed an input to the stored procedure. Please let me know how this can be done.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

James Zhang
Oct 21, 2016 at 02:18 AM
0

Hi,

The main point is to use exec to execute ddl command, use || to append command.

The structure would like below, (I only list create synonym):

-----------------------------------------------------------------------

create procedure synonym_create (in synonym_name NVARCHAR(20), in table_name NVARCHAR(20))
as
begin
exec 'create synonym ' || :synonym_name || ' FOR ' || :table_name;
end;

---------------------------------------------------------------------------
Regarding the create, drop synonym option, please do refer to links:

https://help.sap.com/saphelp_hanaplatform/helpdata/en/20/d7e172751910148bccb49de92d9859/content.htm

https://help.sap.com/saphelp_hanaplatform/helpdata/en/20/d5412b75191014bc7ec7e133ce5bf5/content.htm


Best regards,
James

Share
10 |10000 characters needed characters left characters exceeded
Rich Heilman
Oct 21, 2016 at 03:42 PM
0

As for the product roadmap, we are looking to allow the use of DDL statements natively within procedures in an upcoming release.

Cheers,

Rich Heilman

Share
10 |10000 characters needed characters left characters exceeded