In multiple data using dynamic SQL to pass in a string

Source: Internet
Author: User

<title>In multiple data using dynamic SQL to pass in a string</title> 1. Dynamic SQL Incoming stringCREATE OR REPLACE PROCEDURE p_test (V_str VARCHAR2) as  TYPE Cur_type is REF CURSOR ;c_fzt Cur_type;V_sql VARCHAR2( -);V_JRH VARCHAR2( -);BEGINV_sql:=' SELECT jrh from Fzt_dd WHERE rownum<10 and Prod_name in ('||V_str ||')' ;      OPEN C_fzt for V_sql;      LOOP        FETCH C_fzt into V_JRH;            EXIT when C_fzt %NOTFOUND ;Dbms_output.put_line (V_JRH );      END LOOP;END; 
BEGINp_test( ' ordinary phone ', ' broadband ' );END;
2. Dynamic SQL Incoming numbersCREATE OR REPLACE PROCEDURE p_test (V_str VARCHAR2) as  TYPE Cur_type is REF CURSOR ;c_fzt Cur_type;V_sql VARCHAR2( -);V_JRH VARCHAR2( -);BEGINV_sql:=' SELECT jrh from Fzt_dd WHERE rownum<10 and prod_spec_id in ('||V_str ||')' ;      OPEN C_fzt for V_sql;      LOOP        FETCH C_fzt into V_JRH;            EXIT when C_fzt %NOTFOUND ;Dbms_output.put_line (V_JRH );      END LOOP;END; 
BEGINp_test( ' 9,2 ');END;
3. Dynamic SQL incoming SQL tableCREATE OR REPLACE PROCEDURE p_test (V_str VARCHAR2) as  TYPE Cur_type is REF CURSOR ;c_fzt Cur_type;V_sql VARCHAR2( -);V_JRH VARCHAR2( -);BEGINV_sql:=' SELECT jrh from Fzt_dd WHERE rownum<10 and prod_spec_id in ('||V_str ||')' ;      OPEN C_fzt for V_sql;      LOOP        FETCH C_fzt into V_JRH;            EXIT when C_fzt %NOTFOUND ;Dbms_output.put_line (V_JRH );      END LOOP;END; 
BEGINp_test( ' Select prod_spec_id from fzt_dd where prod_name= ' ordinary phone ' );END;

From for notes (Wiz)

In multiple data using dynamic SQL to pass in a string

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.