Hi Experts,
In my case, I have to use Dynamic SQL to build the query string because the table name is variable.
Anyone know how to retrieve values from a dynamic SQL running on HANA without use any table or temporaly table.
I testing with the CE function, but unfortunately CE functions not supports string with tablename value.
In Microsoft SQL-SERVER use the following syntax:
SET @SQLString = 'SELECT TOP 1 @DocTypeOUT = DocType FROM ' + @tbl + ' WHERE DocEntry = ' + @list_of_cols_val_tab_del SET @ParmDefinition = N'@DocTypeOUT nvarchar(1) OUTPUT'; execute sp_executesql @SQLString, @ParmDefinition,@DocTypeOUT = @DocType OUTPUT;
In HANA use the following syntax:
CREATE LOCAL TEMPORARY TABLE #TABLE_VALUES( DocType nvarchar(5) ); SQLString := 'INSERT INTO #TABLE_VALUES (DocType) SELECT TOP 1 "DocType" as "DOCTYPE" FROM ' || tbl || ' WHERE "DocEntry" = ' || list_of_cols_val_tab_del; EXEC SQLString; SELECT DocType into DocType FROM #TABLE_VALUES; DROP TABLE #TABLE_VALUES;
Thank you in advance for your help.