用存儲過程創建數據表:
創建時注意必須添加authid current_user
這個語句相當於賦權限
例
創建語句如下
復制代碼 代碼如下:
create or replace
procedure sp_create_mnl(i_id varchar
/*********************************
名稱
功能描述
修訂記錄
版本號 編輯時間 編輯人 修改描述
入參出參描述
i_id 測點編號
**********************************/
v_tablename varchar
v_flag number(
v_sqlfalg varchar(
begin
v_flag:=
v_tablename:=CONCAT(
v_sqlfalg:=
dbms_output
execute immediate v_sqlfalg into v_flag;
if v_flag=
begin
execute immediate
( DATETIME DATE
MIN
AGV
MAX
MIN
AVG
MAX
MIN
AGV
MAX
MIN
AGV
MAX
MIN
AGV
MAX
MIN
AGV
MAX
MIN
AGV
MAX
MIN
AGV
MAX
MIN
AGV
MAX
MIN
AGV
MAX
MIN
AGV
MAX
MIN
AGV
MAX
MINV FLOAT
MAXV FLOAT
AVGV FLOAT
MAXTIME DATE
MINTIME DATE
)
tablespace WYG
pctfree
initrans
maxtrans
storage
(
initial
next
minextents
maxextents unlimited
pctincrease
)
end;
end if;
end;
調用此存儲過程
復制代碼 代碼如下:
begin
createmnl(
end;
例
復制代碼 代碼如下:
CREATE OR REPLACE PROCEDURE BIP_MMS_PARTITION_PROC AS
v_Mms_Task_Tab VARCHAR
v_Mms_Content_Tab VARCHAR
v_Mms_User_Tab VARCHAR
v_TableSpace VARCHAR
v_PartPreFlag VARCHAR
v_SqlCursor NUMBER;
v_SqlExec VARCHAR
v_PartPreDate VARCHAR
v_RangeValue NUMBER;
v_RangeDate NUMBER;
v_Rows NUMBER(
v_Num NUMBER(
vErrInfo VARCHAR
p_DateFrom NUMBER;
p_PartNum NUMBER;
p_Range NUMBER;
BEGIN
v_Mms_Task_Tab :=
v_Mms_Content_Tab :=
v_Mms_User_Tab :=
BEGIN
SELECT TO_NUMBER(VALUE)
INTO p_DateFrom
FROM BIP_OTHERS_PROPERTIES_TAB
WHERE NAME =
SELECT TO_NUMBER(VALUE)
INTO p_PartNum
FROM BIP_OTHERS_PROPERTIES_TAB
WHERE NAME =
SELECT TO_NUMBER(VALUE)
INTO p_Range
FROM BIP_OTHERS_PROPERTIES_TAB
WHERE NAME =
EXCEPTION
WHEN OTHERS THEN
BEGIN
p_DateFrom :=
p_PartNum :=
p_Range :=
END;
END;
INSERT INTO BIP_LOG_STAT_EXEC_TAB
VALUES
(TO_CHAR(SYSDATE
COMMIT;
FOR i IN
v_PartPreDate := TO_CHAR(SYSDATE + p_DateFrom + i
dbms_output
v_Num :=
v_TableSpace :=
v_PartPreFlag :=
SELECT COUNT(*)
INTO v_Num
FROM user_tab_partitions
WHERE table_name = v_Mms_Content_Tab
AND SUBSTR(partition_name
IF v_Num <
v_RangeDate := TO_CHAR(SYSDATE + p_DateFrom + i
v_RangeValue := v_RangeDate ||
dbms_output
v_SqlExec :=
v_PartPreFlag ||
dbms_output
v_SqlCursor := DBMS_SQL
DBMS_SQL
v_Rows := DBMS_SQL
DBMS_SQL
END IF;
v_PartPreDate := TO_CHAR(SYSDATE + p_DateFrom + i
v_Num :=
v_TableSpace :=
v_PartPreFlag :=
SELECT COUNT(*)
INTO v_Num
FROM user_tab_partitions
WHERE table_name = v_Mms_Task_Tab
AND SUBSTR(partition_name
IF v_Num <
v_RangeDate := TO_CHAR(SYSDATE + p_DateFrom + i
v_RangeValue := v_RangeDate ||
v_SqlExec :=
v_PartPreFlag ||
dbms_output
v_SqlCursor := DBMS_SQL
DBMS_SQL
v_Rows := DBMS_SQL
DBMS_SQL
END IF;
v_PartPreDate := TO_CHAR(SYSDATE + p_DateFrom + i
v_Num :=
v_TableSpace :=
v_PartPreFlag :=
SELECT COUNT(*)
INTO v_Num
FROM user_tab_partitions
WHERE table_name = v_Mms_User_Tab
AND SUBSTR(partition_name
IF v_Num <
v_RangeDate := TO_CHAR(SYSDATE + p_DateFrom + i
v_RangeValue := v_RangeDate ||
v_SqlExec :=
v_PartPreFlag ||
dbms_output
v_SqlCursor := DBMS_SQL
DBMS_SQL
v_Rows := DBMS_SQL
DBMS_SQL
END IF;
END LOOP;
COMMIT;
INSERT INTO BIP_LOG_STAT_EXEC_TAB
VALUES
(TO_CHAR(SYSDATE
COMMIT;
INSERT INTO BIP_LOG_STAT_EXEC_TAB
VALUES
(TO_CHAR(SYSDATE
COMMIT;
BEGIN
v_PartPreFlag :=
TO_CHAR(SYSDATE
dbms_output
v_SqlExec :=
dbms_output
v_SqlCursor := DBMS_SQL
DBMS_SQL
v_Rows := DBMS_SQL
DBMS_SQL
dbms_output
v_SqlExec :=
v_PartPreFlag;
dbms_output
v_SqlCursor := DBMS_SQL
DBMS_SQL
v_Rows := DBMS_SQL
DBMS_SQL
dbms_output
END;
BEGIN
v_PartPreFlag :=
TO_CHAR(SYSDATE
dbms_output
v_SqlExec :=
v_PartPreFlag;
dbms_output
v_SqlCursor := DBMS_SQL
DBMS_SQL
v_Rows := DBMS_SQL
DBMS_SQL
dbms_output
v_SqlExec :=
v_PartPreFlag;
v_SqlCursor := DBMS_SQL
DBMS_SQL
v_Rows := DBMS_SQL
DBMS_SQL
dbms_output
END;
BEGIN
v_PartPreFlag :=
TO_CHAR(SYSDATE
dbms_output
v_SqlExec :=
v_PartPreFlag;
dbms_output
v_SqlCursor := DBMS_SQL
DBMS_SQL
v_Rows := DBMS_SQL
DBMS_SQL
dbms_output
v_SqlExec :=
v_PartPreFlag;
v_SqlCursor := DBMS_SQL
DBMS_SQL
v_Rows := DBMS_SQL
DBMS_SQL
dbms_output
END;
COMMIT;
INSERT INTO BIP_LOG_STAT_EXEC_TAB
VALUES
(TO_CHAR(SYSDATE
COMMIT;
EXCEPTION
WHEN OTHERS THEN
BEGIN
ROLLBACK;
dbms_output
vErrInfo := SUBSTR(SQLERRM
dbms_output
INSERT INTO BIP_LOG_STAT_EXEC_TAB
VALUES
(TO_CHAR(SYSDATE
vErrInfo);
COMMIT;
END;
end bip_mms_partition_proc;
From:http://tw.wingwit.com/Article/program/Oracle/201405/30854.html