本儲存過程實現建立表和刪除表,並應用到日期函式sysdate,add_months,
pl/sql devoleper 8.0開發
create or replace procedure p_create_history_table
isv_sql string(31000) :='';
begin
for i in 1..2
loop
declare num number;
begin select count(1) into num from user_tables where table_name = 'onoffhist_'||to_char(add_months(sysdate,i),'yyyymm');
if num >0
then execute immediate 'drop table onoffhist_'||to_char(add_months(sysdate,i),'yyyymm');
end if;
end;
v_sql := v_sql||'
create table dtpgsis_onoff.onoffhist_'||to_char(add_months(sysdate,i),'yyyymm')
||'( id number(10,0) not null enable,
sn number(*,0),
datetime varchar2(20),
maxvalue float(126),
minvalue float(126),
value float(126),
constraint onoffhist_'||to_char(add_months(sysdate,i),'yyyymm')||' primary key(id)
using index pctfree 10 initrans 2 maxtrans 255
storage (initial 65536 next 1048576 minextents 1 maxextents 2147483645
pctincrease 0 freelists 1 freelist groups 1 buffer_pool default)
tablespace "dtpgsis_onoff" enable
)' ;
-- dbms_output.put_line(v_sql);
execute immediate v_sql;
end loop;
commit;
end;
遇到許可權問題參考此文解決http://www.itpub.net/viewthread.php?tid=413853&extra=&page=1
乙個簡單的儲存過程
set quoted identifier off goset ansi nulls on goalter procedure list gz p zgh int null as begin if p zgh is null begin print 請輸入乙個職工號 return end else ...
乙個簡單的儲存過程
建立物件 set oconn server.createobject adodb.connection set ors server.createobject adodb.recordset set ocmd server.createobject adodb.command 資料連線 strcon...
乙個簡單的儲存過程
建立乙個簡單的儲存過程 其中涉及到是基本的傳參,定義引數,引數賦值,條件語句,迴圈語句,用游標遍歷等基本語法 建立乙個儲存過程 create or replace procedure addgoods 傳入兩個變數,乙個輸入變數,乙個輸出變數,輸出變數用來作為返回值 gname1 user tabl...