日期:2014-05-17 浏览次数:20844 次
CREATE OR REPLACE PROCEDURE createtable(WellName IN VARCHAR2,
Table_Name IN VARCHAR2,
boiler IN VARCHAR2,
managerarea IN VARCHAR2) AUTHID current_user AS
sqlstr VARCHAR2(500);
BEGIN
sqlstr:='CREATE TABLE '||Table_Name||'(
cjsj DATE,
jkgd NUMBER(10,2),
zryl NUMBER(10,2),
zqwd NUMBER(10,2),
zqsd NUMBER(10,2)
)';
--Dbms_Output.put_line(sqlstr);
EXECUTE IMMEDIATE sqlstr;
sqlstr:='CREATE TABLE '||Table_Name||'_H(
cjsj DATE,
jkgd NUMBER(10,2),
zryl NUMBER(10,2),
zqwd NUMBER(10,2),
zqsd NUMBER(10,2)
)';
--Dbms_Output.put_line(sqlstr);
EXECUTE IMMEDIATE sqlstr;
sqlstr:='CREATE TABLE '||Table_Name||'_D(
cjsj DATE,
jkgd NUMBER(10,2),
zryl NUMBER(10,2),
zqwd NUMBER(10,2),
zqsd NUMBER(10,2),
runhours NUMBER(10)
)';
--Dbms_Output.put_line(sqlstr);
EXECUTE IMMEDIATE sqlstr;
sqlstr:= 'CREATE OR REPLACE TRIGGER '||Table_Name||'_Tri
BEFORE INSERT ON '||Table_Name||
' FOR EACH ROW
BEGIN
HistoryData('''||Table_Name||''',SYSDATE,:new.zryl,:new.jkgd,:new.zqwd,:new.zqsd);
END';
--Dbms_Output.put_line(sqlstr);
EXECUTE IMMEDIATE sqlstr;
sqlstr:='INSERT INTO wells(wname,rtable,boiler,managerarea,issteam,tempstop,stoptimes) VALUES ('''||
WellName||''','''||Table_Name||''','''||boiler||''','''||managerarea||''',''Y'',''N'',0)';
--Dbms_Output.put_line(sqlstr);
EXECUTE IMMEDIATE sqlstr;
END;