Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3280

drop temp tables if exist in SAP HANA query

$
0
0

Hi experts,

 

i have a very simple query but it has a drop table if it exist then the select statement continues, but i do not know how to do it right in SAP HANA queries.

Below is my HANA query for assistance.

 

 

CREATE PROCEDURE STAFF_RPORT (IN Prjcode1 date, IN prjcode2 date)

AS

BEGIN

DROP TABLE "test_table";

CREATE COLUMN TABLE "test_table" AS (SELECT T2."TransId", T0."PrjCode", T0."PrjName", T1."Account", T3."AcctName", T1."RefDate", T2."Memo", T1."Debit", T1."Credit", T1."BatchNum", T2."CreateDate", T2.TaxDate, T0."U_PR_TYPE", T1."Ref2", T1."FCDebit", T1."FCCredit", T1."DueDate", IFNULL((SELECT SUM(t5."debit") FROM OPRJ T4 INNER JOIN JDT1 T5 ON T4."PrjCode" = T5."Project" INNER JOIN OJDT T6 ON T5."TransId" = T6."TransId" INNER JOIN OACT T7 ON T5."Account" = T7."AcctCode" WHERE T5."RefDate" < :Prjcode1 AND T0."PrjCode" = T4."PrjCode" AND t5."account" = t1."account"), 0) AS "Debit_BF", IFNULL((SELECT SUM(t5."credit") FROM OPRJ T4 INNER JOIN JDT1 T5 ON T4."PrjCode" = T5."Project" INNER JOIN OJDT T6 ON T5."TransId" = T6."TransId" INNER JOIN OACT T7 ON T5."Account" = T7."AcctCode" WHERE T5."RefDate" < :Prjcode1 AND T0."PrjCode" = T4."PrjCode" AND t5."account" = t1."account"), 0) AS "Credit_BF" FROM OPRJ T0 INNER JOIN JDT1 T1 ON T0."PrjCode" = T1."Project" INNER JOIN OJDT T2 ON T1."TransId" = T2."TransId" INNER JOIN OACT T3 ON T1."Account" = T3."AcctCode" WHERE T1.RefDate >= :Prjcode1 AND T1.RefDate <= :prjcode2 AND T0.U_PR_TYPE = 'Employee' ORDER BY t0.prjcode, T2."TransId");

SELECT * FROM test_table ORDER BY PrjCode;

END;

 

 

i want to know if the syntax above is right?

 

Urgent reply will be appreciated

 

Regards

Justice


Viewing all articles
Browse latest Browse all 3280

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>