CREATEOR REPLACE PROCEDURE mes.p_create_table_task( f_date TIMESTAMP(0) WITHOUTTIME ZONE ) PACKAGE AS DECLARE l_sql VARCHAR(5000); l_date TIMESTAMP(0) WITHOUTTIME ZONE; f_error2 NUMERIC; f_error NUMERIC; BEGIN l_date := f_date; while l_date <= f_date +7 loop call mes.p_mes_cre_tbs01(l_date,f_error2); RAISE notice 'AFTER A BEFORB p_create_table_task value is: %',l_date; --call mes.p_mes_cre_tbs02(l_date,f_error2); l_date := l_date+1; RAISE notice 'last l_date is: %',l_date; end loop; f_error :=1; exception when others then f_error :=0; RAISE notice 'p_create_table_task of SQLERRM is: %',SQLERRM; end; /;
f_tab_if_cre
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
CREATEOR REPLACE FUNCTION mes.f_tab_if_cre(p_tablename charactervarying) RETURNSnumeric LANGUAGE plpgsql NOT FENCED NOT SHIPPABLE PACKAGE AS $function$ DECLARE resultNUMERIC; BEGIN SELECTCOUNT(*) intoresultFROM information_schema.tables WHERE TABLE_NAME=lower(p_tablename); returnresult; exception when others then return-1; end; $function$;
MogDB=# \c mesdb mes Password foruser mes: Non-SSL connection (SSL connection is recommended when requiring high-security) You are now connected to database "mesdb" asuser "mes". mesdb=>call mes.p_create_table_task(sysdate); NOTICE: the l_sql of mes_cretbs01 is: createtable mestbs01_20240523 ( ID NUMBER(11) ) NOTICE: p_create_table_task of SQLERRM is: query has no destination forresult data p_create_table_task --------------------- (1row)
mesdb=> \d mestbs01_20240523 Did not find any relation named "mestbs01_20240523". mesdb=>call mes.p_mes_cre_tbs01(sysdate,','); NOTICE: the l_sql of mes_cretbs01 is: createtable mestbs01_20240523 ( ID NUMBER(11) ) f_error --------- 1 (1row) mesdb=> \d mestbs01_20240523 Table "mes.mestbs01_20240523" Column| Type | Modifiers --------+---------------+----------- id |numeric(11,0) | mesdb=>
通过 Mogeaver 来 debug 也是执行完 第一个存储过程p_mes_cre_tbs01之后,就转到主存储过程抛异常了:NOTICE: p_create_table_task of SQLERRM is: query has no destination for result data 他的报错就是 query has no destination for result data ,也就是没有返回结果,p_mes_cre_tbs01存储过程是判断表是否存在,如果不存在就创建,就是创建成功之后他也没有返回结果呢,所以没有结果是正常的呢。这里百思不得其解,无奈把上面的数据 复制给大模型。