aduh...error mulu ya pakai PL/SQL..abis kebiasaan pakai T-SQl sih...
bikin function yang didalamnya ada proses DDL(Data Definition language) koq ga mau y?
aq pikir2..masak DB sekelas oracle koq gt aja ga support..
hmmm akhirnya ketemu juga jawabannya..
scriptnya harus di kasih tambahan script lg ternyata
ternyata ini 'pragma autonomous_transaction;' yang dicari2 dari td..
ihh gemez......bikin lama kerjaan aj:D
========================================================
CREATE OR REPLACE Function NextProcessInDestinationTable
( modeInput IN Integer, tableNm IN varchar2, tablespaceNm IN varchar2
, dd IN varchar2, mm IN varchar2, yy IN varchar2)
RETURN Integer
IS
-- penambahan ini untuk mengatasi error msg :
-- ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML
pragma autonomous_transaction; -- <===== ini dia :D
tailOfTable VARCHAR2(50);
sqlStatement VARCHAR2(2000);
i integer :=0;
BEGIN
IF ( tableNM = 'ACTIVITY' or tableNM = 'PENDING'
or tableNM = 'SETTLEMENT_LOP' or tableNm = 'RESOLVED') THEN
tailOfTable := substr(yy, 3, 2) || mm;
ELSIF ( tableNM = 'CUSTOMER' or tableNM = 'MERCHANT') then
tailOfTable := substr(yy, 3, 2) || mm ||dd;
END IF;
DBMS_OUTPUT.PUT_LINE('>>>>> ' || tailOfTable);
if (modeinput = 0) then
select count(1) into i
from all_tables
where table_name = (tableNm || tailOfTable) and tablespace_name = tablespaceNm;
if ( i > 0 ) then
-- processinsertdata please wait y:D
return 1;
else
--create table if not exists
sqlStatement := 'create table ' || tableNm || tailOfTable || ' as select * from ' || ' template_' || TableNm;
Execute immediate (sqlStatement);
end if;
end if;
return 0;
END;
========================================================
No comments:
Post a Comment