For execution of dynamic SQL in oralce

Source: Internet
Author: User

For execution of dynamic SQL in oralce

-- Execute dynamic SQL CREATE OR REPLACE FUNCTION fun_checkguaranteetype (TranId varchar2) return varchar2 is V_result varchar2 (1000); Begin declare zhiyavar NUMBER; diyavar NUMBER; dabaoren NUMBER; v_ SQL varchar2 (1000); -- defines type TYPE accountno_type IS TABLE OF actaccount. accountno % type index by BINARY_INTEGER; TYPE id_type is table of bizpawn. id % type index by BINARY_INTEGER; -- set column accountno accountno_type; id id_type; begin v_ SQL: = 'select p1.accountno accountno, pawn. id, pawn. nocredencemode from bizpawn pawn, ('; v_ SQL: = v_ SQL | 'select act. relationaccountid, act. accountno from actaccount act where act. id in '; v_ SQL: = v_ SQL |' (select trans. accountid from acttransaction trans where trans. id in ('| TranId |') p1 '; v_ SQL: = v_ SQL | 'where pawn. actaccountid = p1.relationaccountid '; -- EXECUTE the dynamic SQL execute immediate v_ SQL BULK COLLECT into accountno, id; -- for V1 IN 1 .. accountno. count loop -- get the value dbms_output ('accountno: '| accountno (v1) |' --- id: '| id (v1); end loop; return (V_result ); end; end fun_checkguaranteetype;

 


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.