Oracle stored procedures, staging tables, dynamic SQL testing

Source: Internet
Author: User

--Create a result temp table at the transaction levelCreateGlobalTemporary TableTmp_yshy (C1varchar2( -), C2varchar2( -)) on Commit Deleterows;--Create a temporary table that stores SQL statements at the transaction levelCreateGlobalTemporary TableTmp_sql (C1varchar2(4000)) on Commit DeleteRows

Test table:

 --  create  table   T_user (NAME  varchar2  (20   number  )  
-- first build the package Create or Replace    as--  1: Check all users according to age  procedure  p_user_select (    av _age        number,        -- age    av_suc out    varchar2       -- Whether or not  the logo is successful   ); End Pack_user;
--Create a package bodyCreate or ReplacePackage Body Pack_user as --1: Check all users according to age procedureP_user_select (Av_age Number, Av_suc outvarchar2 )  asLv_sqlvarchar2(4000); beginAV_SUC:='T'; Lv_sql:='INSERT INTO Tmp_yshy (C1,C2)'||           'Select Name,age'||           'From T_user'||           'where age >'||Av_age; Insert  intoTmp_sql (C1)Values(Lv_sql||';'); Executeimmediate lv_sql; Exception whenOthers Then       rollback; AV_SUC:='F'||' '||To_char (Sqlcode)||' : '||SQLERRM; Dbms_output.put_line (AV_SUC); EndP_user_select;EndPack_user;

PL/SQL Developer Sqlwindow test:

DECLAREvarchar2 (begin pack_user.p_user_          Select (end;
Select *  from tmp_yshy; Select *  from Tmp_sql;

Oracle stored procedures, staging tables, dynamic SQL testing

Related Article

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.