Dynamically execute the SQL statement and return a value.

Source: Internet
Author: User
Dynamically execute the SQL statement and return a value of listen (p_sqlinvarchar2); resultvarchar2 (4000); l_tempnumber; beginc: comment; dbms_ SQL .parse (c, p_ SQL, dbms_ SQL .native); ifupper (p_ SQL) li

Dynamic execution of SQL, returns a value PL/SQL dynamic SQL function dyn_ SQL (p_ SQL in varchar2) return varchar2 is c integer; result varchar2 (4000); l_temp number; begin c: = dbms_ SQL .open_cursor; dbms_ SQL .parse (c, p_ SQL, dbms_ SQL .native); if upper (p_ SQL) li

Dynamic execution of SQL, returns a PL/SQL dynamic SQL
  function dyn_sql(p_sql in varchar2) return varchar2 is    c      integer;    result varchar2(4000);    l_temp number;  begin    c := dbms_sql.open_cursor;    dbms_sql.parse(c, p_sql, dbms_sql.native);    if upper(p_sql) like 'SELECT%' then      dbms_sql.define_column(c, 1, result, 4000);      l_temp := dbms_sql.execute_and_fetch(c);      if l_temp > 0 then        dbms_sql.column_value(c, 1, result);      else        result := null;      end if;    else      l_temp := dbms_sql.execute(c);      result := null;    end if;    dbms_sql.close_cursor(c);    return result;  end dyn_sql;

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.