Skip to content Skip to sidebar Skip to footer

Hana Sql Select Count (*) From Multiple Tables Found In A Table

DECLARE VI_CNT INTEGER DEFAULT 0; DECLARE VI_IDX INTEGER; DECLARE VI_LIMIT INTEGER; DECLARE VS_OUTPUTSTRG1 NVARCHAR(500); DECLARE VS_OUTPUTSTRG2 NVARCHAR(500); /* ANAGRAFICA TABE

Solution 1:

It looks like the OP wants to store the raw record count of a list of tables into yet another table.

This requirement can be met without the use of SQLScript.

SAP HANA keeps the number of committed records in tables available in catalog tables like [M_TABLES][1].

With this information available, the INSERT-statement can be rewritten like so:

INSERTINTO 
     "TEAMBW"."IFRS17.INTEGRATION.DATA_QUALITY::ZTB_DQ_DAFNE_TEST" 
       (TABLE_NAME, RECORD_COUNT)
(SELECT 
        TABLE_NAME, RECORD_COUNT
 FROM M_TABLES
 WHERE 
   SCHEMA_NAME ='xyz'AND TABLE_NAME IN (SELECTDISTINCT TABLE_NAME 
                      FROM ZDAFNE_INFO)
 );

This solution works as long as no filtering of to-be-counted records in the source tables is required.

Post a Comment for "Hana Sql Select Count (*) From Multiple Tables Found In A Table"