我主要是不知道在存储过程里面使用临时表 而且是要把查询的语句直接插到临时表的SELECT AID=IDENTITY(INT,1,1),ITEM1,ITEM2,ITEM3 INTO #HA
FROM MALERRJOURNAL WHERE ITEM1 IN (select macid from MachineInfo where MacID in
(select MacID from MachineInfo where PropertyValue=@CITY and PropertyCode='11'
and MacID in (select MacID from MachineInfo where
PropertyValue=@PROVINCE and PropertyCode='10')) and PropertyCode='12' and PropertyValue=@AREA)
AND SUBSTRING(ITEM2,1,10)=@HDATETIME
ORDER BY ITEM1,ITEM2,ITEM3查询一些记录出来直接插入#HA 临时表里面我是偠动态建立临时表啊 就是在存储过程里面动态建立 我已经写好了 我主要是不知道偠怎么把查询的结果插入到临时表里面
FROM MALERRJOURNAL WHERE ITEM1 IN (select macid from MachineInfo where MacID in
(select MacID from MachineInfo where PropertyValue=@CITY and PropertyCode='11'
and MacID in (select MacID from MachineInfo where
PropertyValue=@PROVINCE and PropertyCode='10')) and PropertyCode='12' and PropertyValue=@AREA)
AND SUBSTRING(ITEM2,1,10)=@HDATETIME
ORDER BY ITEM1,ITEM2,ITEM3查询一些记录出来直接插入#HA 临时表里面我是偠动态建立临时表啊 就是在存储过程里面动态建立 我已经写好了 我主要是不知道偠怎么把查询的结果插入到临时表里面
insert into #HA
SELECT AID=IDENTITY(INT,1,1),ITEM1,ITEM2,ITEM3 INTO #HA
FROM MALERRJOURNAL WHERE ITEM1 IN (select macid from MachineInfo where MacID in
(select MacID from MachineInfo where PropertyValue=@CITY and PropertyCode=''11''
and MacID in (select MacID from MachineInfo where
PropertyValue=@PROVINCE and PropertyCode=''10'')) and PropertyCode=''12'' and PropertyValue=@AREA)
AND SUBSTRING(ITEM2,1,10)=@HDATETIME
ORDER BY ITEM1,ITEM2,ITEM3';
create or replace procedure pro_temp(v_col1 varchar2,v_col2 varchar2) as
v_num number;
begin
select count(*) into v_num from user_tables where table_name='T_TEMP';
--create temporary table
if v_num<1 then
execute immediate 'CREATE GLOBAL TEMPORARY TABLE T_TEMP (
COL1 VARCHAR2(10),
COL2 VARCHAR2(10)
) ON COMMIT delete ROWS';
end if;
--insert data
execute immediate 'insert into t_temp values('''||v_col1||''','''||v_col2||''')';
execute immediate 'select col1 from t_temp' into v_num;
dbms_output.put_line(v_num);
execute immediate 'delete from t_temp';
commit;
execute immediate 'drop table t_temp';
end pro_temp;