Oracle in pass string parameter query failed

Source: Internet
Author: User

The following code is in the write stored procedure:
For a in (               select a.svo_no,a.audit_no,a.order_id by  tt_pi_model_rel a     ) LOOP            SELECT COUNT (1) into v_ FLAG from  tt_pi_order WHERE pi_id in (a.order_id)  and regulariza_date are not NULL;//perform several operations end LOOP;
which
SELECT a.svo_no,a.audit_no,a.order_id  from Tt_pi_model_rel a    order_id has multiple values  1000007845,1000007669

Order_Id put pi_id in (a.order_id) to execute query error

Because of the parameter problem in in, it is not easy to understand that pi_id in (1000007845,1000007669) is a pi_id in (a variable), which results in a query error

Workaround: Advance the
SELECT COUNT (1) into V_flag from  Tt_pi_order WHERE pi_id in (a.order_id) and regulariza_date are not  NULL;
Stitching into the form of an SQL statement, rather than passing in the form of a.order_id,

The operation is as follows:

  Execute IMMEDIATE                   ' SELECT COUNT (1)  From Tt_pi_order WHERE pi_id in ('| | a.order_id| | ' ) and regulariza_date are not  NULL  'into                  C_flag;

Use

Execute IMMEDIATE solve the problem

The usage can refer to network: http://kevinlee0755.iteye.com/blog/1381617













Oracle in pass string parameter query failed

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.