我将它作为一项工作运行,所以我对您的脚本进行了一些更改:
create table test (descr varchar2(100),
data date,
data2 varchar2(500));
create procedure testt is
begin
execute immediate 'ALTER SESSION SET NLS_DATE_FORMAT = ''DD/MM/YYYY HH:MI:SS AM''';
DELETE FROM TEST;
INSERT INTO TEST SELECT 'SOME TEXT', SYSDATE, TO_CHAR(SYSDATE,'DD/MM/YYYY HH:MI:SS AM') FROM DUAL;
commit;
end;
/
declare
job number;
begin
DBMS_JOB.Submit(
job => JOB,
what => 'testt();',
next_date => SYSDATE
);
commit;
end;
/
SELECT * FROM TEST;
DROP TABLE TEST;
DROP PROCEDURE TESTT;
我得到了结果:
Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.1.0
Connected as
SQL>
SQL> create table test (descr varchar2(100),
data date,
data2 varchar2(500));
Table created
SQL> create procedure testt is
begin
execute immediate 'ALTER SESSION SET NLS_DATE_FORMAT = ''DD/MM/YYYY HH:MI:SS AM''';
DELETE FROM TEST;
INSERT INTO TEST SELECT 'SOME TEXT', SYSDATE, TO_CHAR(SYSDATE,'DD/MM/YYYY HH:MI:SS AM') FROM DUAL;
commit;
end;
16 /
Procedure created
SQL> declare
job number;
begin
DBMS_JOB.Submit(
job => JOB,
what => 'testt();',
next_date => SYSDATE
);
commit;
end;
/
PL/SQL procedure successfully completed
SQL> SELECT * FROM TEST;
DESCR DATA DATA2
-------------------------------------------------------------------------------- ----------- --------------------------------------------------------------------------------
SOME TEXT 19/03/2015 28/12/1393 01:47:57 TARDE