Menu

Calling MySQL stored functions

Help
2007-02-27
2012-09-19
  • Jeff Norton

    Jeff Norton - 2007-02-27

    Is it possible to call MySQL stored functions (i.e. functions rather than procedures)?

    Thanks,

     
    • Jeff Norton

      Jeff Norton - 2007-02-27

      Aha -- that's it. Use cursor.execute("select myFunction()").
      If you use cursor.callproc("myFunction") you get:

      (1305, 'PROCEDURE testdb1.myFunction does not exist')

       
      • Andy Dustman

        Andy Dustman - 2007-02-27

        Yep, callproc() is only for stored procedures.

         
    • Andy Dustman

      Andy Dustman - 2007-02-27

      A stored function works like a regular function, so yes, and you don't need to do anything special.

      Side note: You don't have to use cursor.callproc() to call stored procedures. You can use cursor.execute() if you prefer.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.