Hi ,
I’m getting the follow error when I execute this SP:
call del_truncate_all_project_data() ;
setting_value contains the table name.
singlestore> call del_truncate_all_project_data() ;
±-------------------------------------+
| Status |
±-------------------------------------+
| truncate table: ff_processing_result |
±-------------------------------------+
1 row in set (0.04 sec)±-------------------------------------+
| v_truncate_table_sql |
±-------------------------------------+
| truncate table ff_processing_result; |
±-------------------------------------+
1 row in set (0.04 sec)ERROR 1064 (42000): Unhandled exception
Type: ER_PARSE_ERROR (1064)
Message: Leaf Error (127.0.0.1:3307): Multiple statements detected in a single query. truncate table ff_processing_result; TWO_PHASE 17895398464852729182:26
Callstack:
#0 Line 45 inseismos
.del_truncate_all_project_data
SP:
CREATE OR REPLACE PROCEDURE
del_truncate_all_project_data
() RETURNS void AS– call del_truncate_all_project_data() ;
– SP is called to reset a Project on the Trailer.
– SP should not be present on Production Cloud not should the feature Be present on ProductionDECLARE v_cnt_row bigint ;
v_truncate_table_sql text;
v_truncate_table_cmd text=“”;DECLARE qry QUERY(table_name varchar(100) ) =
select setting_value FROM project_setting
WHERE is_active=1
AND setting_attribute=‘Truncate’ ;arr ARRAY(RECORD( table_name varchar(100) ));
v_table_name varchar(100) ;BEGIN
– Total Project
SELECT count(*) into v_cnt_row FROM project p ;– If there is only 1 project
If v_cnt_row =1 thenarr = COLLECT(qry); FOR x in arr LOOP v_table_name = x.table_name ; -- drop temp table -- ECHO Select concat ('truncate table: ',v_table_name ) as 'Status' ; v_truncate_table_sql = CONCAT("truncate table ", v_table_name,';'); -- v_truncate_table_cmd = CONCAT(v_truncate_table_cmd, v_truncate_table_sql ); ECHO select v_truncate_table_sql ; EXECUTE IMMEDIATE v_truncate_table_sql; END LOOP;
else
echo Select ‘There is more than 1 project in your database. We cannot truncate all projects related tables.’ as ‘Status’;
end if ;
END//