Returning a temporary table in Stored Procedure in Redshift

0

Hello everyone! The problem that I'm having is that I need for a stored procedure in redshift to return a temporary table. Not in the way described here https://docs.aws.amazon.com/redshift/latest/dg/stored-procedure-result-set.html

Where you can see that the temp table is called after the stored procedure with "select * from myresult;"

What I need is to have the table returned when executing the CALL get_result_set() for example.

In my case I'm working with stored procedure that uses two date variables to create several temp tables, insert them values and at the end it joins every temp table created. And what I need is to have the table returned right after i execute the call command.

The reason why I need this kind of solution is because we need to create a report in power bi and we want to do it in the direct query section (advanced options for database connections).

profile picture
已提問 4 個月前檢視次數 385 次
1 個回答
1
已接受的答案

The docs page provides two methods for using Stored Procedures. The first one returns the table data as a reference cursor. So the calling application needs to "fetch" from the cursor (which is like a table). The second method does not return the data, instead it just returns the name of a table. So the calling application needs to perform a "select" query to get the data.

The method #1 is actually returning the table's data for you to directly visualize upon.

I am not that familiar on PowerBI but hope this helps.

profile pictureAWS
已回答 4 個月前
profile pictureAWS
專家
已審閱 2 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南