How to run and debug Oracle stored procedures

Source: Internet
Author: User

1. The steps for compiling an Oracle stored procedure are as follows:

  1. Create or replace procedure P_AUTO_CREATE_PARTITION
  2. (Result Out int,
  3. LogErrDesc Out varchar2
  4. )
  5. Is
  6. Type TypeTable is table of varchar2 (20 );
  7. CreatePartitionErr exception;
  8. Days TypeTable;
  9. BEGIN
  10. Result:=0;
  11. Select datetime bulk collect into days FROM
  12. (
  13. SELECT TO_CHAR (TRUNC (SYSDATE-2, 'dd'), 'yyyymmdd') AS DATETIME FROM DUAL
  14. UNION
  15. SELECT TO_CHAR (TRUNC (SYSDATE-1, 'dd'), 'yyyymmdd') AS DATETIME FROM DUAL
  16. UNION
  17. SELECT TO_CHAR (TRUNC (SYSDATE, 'dd'), 'yyyymmdd') AS DATETIME FROM DUAL
  18. UNION
  19. SELECT TO_CHAR (TRUNC (SYSDATE + 1, 'dd'), 'yyyymmdd') AS DATETIME FROM DUAL
  20. UNION
  21. SELECT TO_CHAR (TRUNC (SYSDATE + 2, 'dd'), 'yyyymmdd') AS DATETIME FROM DUAL
  22. );
  23. For I in 1 .. days. count loop
  24. If bruce_partiton.CreatePartitions ('t_ CDT_1X_BASIC_Partion ', days (I ))<0Then raise CreatePartitionErr; end if;
  25. End loop;
  26. -- The name of bruce_partiton is incorrect. It should be bruce_partition.
  27. Commit;
  28. -- Exception Handling
  29. EXCEPTION
  30. WHEN CreatePartitionErr THEN rollback; Result:=-1; LogErrDesc:=SQLERRM; Commit; RETURN;
  31. WHEN OTHERS THEN
  32. Rollback;
  33. Result:=-2;
  34. LogErrDesc:='CDM _ CTCALLTRACEINFO_PRC_NEW Fail! '| Substr (dbms_utility.format_error_stack, 1,200 );
  35. Commit;
  36. RETURN;
  37. END P_AUTO_CREATE_PARTITION;
  38. /

2. debugging

Select a stored procedure in PL/SQL, right-click TEST, ADD DEBUGINFO,



3. Run the Program in the Program Window.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.