MySQL--Dynamic fetch result set (emphasis)

Source: Internet
Author: User

Note: The value of the statement must be a parameter with the @ symbol, not its own local variables, a @ called user variables, two @ is called a global variable. User variables: The current user's "global variables", the existence of the user state exists, the user exits when it disappears.

Initial version

if exists p1 () create procedure P1 () Begin      int ;      Set  One ;      set @p1 = i1;            from ' SELECT * from info where nid >? ' ;      using @p1;    -- performing pretreatment     deallocate prepare prod    ; -- Delete preprocessing end \delimiter;

Advanced version

delimiter \drop procedureifexists p1 () create procedure P1 (inchstrSQL varchar ( -),            ----Dynamic Get ParametersinchNidint----dynamic get parameters) beginSet@p1 =nid; Set@sql1 =strSQL; Prepare prod from@sql1; Execute PRODusing@p1; --perform pretreatment deallocate prepare prod; --Delete preprocessing end \delimiter; #调用call P1 ("SELECT * from info where nid >?",1)

Python calls Pymysql

row = Cursor.callproc ('p1', ("select * from info where nid >? ",6= Cursor.fetchall ()

MySQL--Dynamic fetch result set (emphasis)

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.