Dynamic SQL of stored procedures in ORACLE packages

Source: Internet
Author: User

Dynamic SQL of stored procedures in the ORACLE package --- create or replace package test_pkg is g_public_flag varchar2 (1); function test_function (p_param1 varchar2, p_param2 varchar2) return varchar2; function hello_function (p_param3 varchar2) return varchar2; procedure ff (p1 varchar2); end; -- create or replace package body test_pkg is g_private_flag varchar2 (1): = 'y '; function test_function (p_param1 varchar2, p_param2 varchar2) return varchar2 is val varchar2 (10): = 'HELO'; begin dbms_output.put_line ('HELO'); return val; end; function hello_function (p_param3 varchar2) -- The parameters must be consistent with the header. return varchar2 is val varchar2 (10): = 'hello'; begin dbms_output.put_line ('World'); return val; end; procedure ff (p1 varchar2) is flag number; pp1 VARCHAR2 (10): = 'P'; p2 VARCHAR2 (10): = 'P'; p3 VARCHAR2 (10 ): = 'P'; p4 VARCHAR2 (10): = 'P'; begin select count (*) into flag from all_all_tables where table_name = 'logtable1'; dbms_output.put_line (flag ); if (flag = 0) then execute immediate 'create TABLE logtable1 (userid VARCHAR2 (10), logdate VARCHAR2 (10), exception_id VARCHAR2 (10), exception_msg VARCHAR2 (10 ))'; end if; execute immediate 'insert into logtable1 values (: 1,: 2,: 3,: 4) 'using '1', '1', '2 ', '3'; -- can only insert end; ---- test declare begin functions (test_pkg.test_function ('1', '1'); dbms_output.put_line (test_pkg.hello_function ('1 ')); test_pkg.ff ('dd'); end; select * from logtable1; drop table logtable1

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.