注册

sql动态执行

石头 2024/12/02 301 1

请问,如下代码,怎么能动态一下行执行,创建临时表,然后插入数据,并返回数据,然后删除临时表。最主要能返回数据

CREATE GLOBAL TEMPORARY TABLE test.TEMP_WORK_VERIFICATION (
uid int,
userid int,
date varchar(100),
xm varchar(100),
type int
) ON COMMIT DELETE ROWS;

insert into test.TEMP_WORK_VERIFICATION(uid, userid, date,xm, type) values (null, 432, '2024-12-03', '', 3);

select A.* from test.TEMP_WORK_VERIFICATION A where A.type + (select sum(isnull(B.type, 0)) from test.tb_oa_work_detail B left join test.tb_oa_work C on B.zbid = C.uid where B.date = A.date
and A.userid = B.userid and C.state >= 0) > 3 ;

drop table test.TEMP_WORK_VERIFICATION

回答 0
暂无回答
扫一扫
联系客服