Calling stored procedure from MysQL 5.0

Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default Calling stored procedure from MysQL 5.0

    I am trying to call stored procedures using <cfquery> in Coldfusion MX 7.0, but
    I am getting this error:

    Error Executing Database Query.
    General error: PROCEDURE start.getforums can't return a result set in the
    given context

    Has anybody successfully called a stored procedure in CF from MySQL 5.0? When
    I run the stored procedure from the MySQL Command Line, it works without a
    problem. Here is the code I am using:



    <cfquery name='query1' datasource='datasource1'>
    call getforums();
    </cfquery>

    ShytKicker Guest

  2. Similar Questions and Discussions

    1. #39136 [NEW]: Calling a stored procedure that creates temp table
      From: aspen dot olmsted at alliance dot biz Operating system: Windows XP SP2 PHP version: 5CVS-2006-10-12 (snap) PHP Bug Type: ...
    2. oracle stored procedure calling
      I have two procedures test1 and test2. Resultset is returned by test2. My coldfusion code calls test1. PROCEDURE test1 (in_eid IN NUMBER,...
    3. Does MySQL have a Stored Procedure equivalent?
      I've only used ASP and MS SQL Server before but I want to learn PHP and MySQL. Does MySQL have an equivalent of Microsoft's Stored Procedures (i.e....
    4. ASP page calling a stored procedure
      Im trying to call a stored procedure in SQL Server 2000 in ASP.. Heres my code.. ...
    5. Calling stored procedure on connection
      Hello all, I'm having a dickens of a time calling a stored procedure on a connection. Every time I do, it generates an error "Arguments are of the...
  3. #2

    Default Re: Calling stored procedure from MysQL 5.0

    I have run a stored procedure with MX7 / mySQL 5.0.12. Are you sure you're
    calling a stored procedure and not a function? From the mySQL docs: "
    Statements that return a result set cannot be used within a stored function."

    [url]http://dev.mysql.com/doc/mysql/en/create-procedure.html[/url]

    mxstu Guest

  4. #3

    Default Re: Calling stored procedure from MysQL 5.0

    Yes, I am sure that I am calling a stored procedure, not a stored function. It
    works from the MySQL Command Line "call getforums();", but doesn't work from
    Coldfusion.

    mxstu, what connector were you using with Coldfusion 7 and MySQL 5? I also
    found this, don't know how helpful it will be to me:
    [url]http://macromedia.com/cfusion/webforums/forum/messageview.cfm?catid=6&threadid=9[/url]
    08525&highlight_key=y&keyword1=mysql%20stored%20pr ocedure

    ShytKicker Guest

  5. #4

    Default Re: Calling stored procedure from MysQL 5.0

    I'm using the jdbc connector mysql-connector-java-3.1.7-bin.jar
    mxstu Guest

  6. #5

    Default Re: Calling stored procedure from MysQL 5.0

    It also works with the version 3.1.10 connector. There are general
    instructions on installing the connector here:
    [url]http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=6ef0253[/url] .

    A few important details about the instructions:
    1) Download version 3.1.10 from
    [url]http://dev.mysql.com/downloads/connector/j/3.1.html[/url]
    2) Extract mysql-connector-java-3.1.10-bin.jar. This is the file referred to
    in steps 2 and 3 of the instructions above
    3) Make sure there is only (1) version of the connector jar in the
    cf_root/WEB-INF/lib directory. If there is more than one version you may
    receive a "No suitable driver" error.
    5) You must restart the CF server after placing the driver in the
    cf_root/WEB-INF/lib directory


    After you create and verify the new datasource try running the stored
    procedure again:

    <cfquery name='query1' datasource='datasource1'>
    { call getforums(); }
    </cfquery>


    mxstu Guest

  7. #6

    Default Re: Calling stored procedure from MysQL 5.0

    Worked well, thanks, but now I am having a problem now with my old queries,
    they are returning this error:

    Error Executing Database Query.
    Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and
    (utf8_general_ci,COERCIBLE) for operation '='

    I have to convert each table and each column to utf8_general_ci inorder for
    the queries to work. Why would it show this error over a JDBC connector?

    ShytKicker Guest

  8. #7

    Default Re: Calling stored procedure from MysQL 5.0

    mxstu, apparently <cfstoredproc> tag works a little different in MySQL 5.0, for
    example, this would throw an error:

    <cfstoredproc procedure='getOrders' datasource='name' />

    Although, instead, you would have to use this to successfully call the MySQL
    stored procedure:

    <cfstoredproc procedure='getOrders()' datasource='name' />

    The returncode attribute also throws an error. Any luck getting those to work
    100% perfectly?

    ShytKicker Guest

  9. #8

    Default Re: Calling stored procedure from MysQL 5.0

    >Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and
    (utf8_general_ci,COERCIBLE) for operation '='

    See [url]http://dev.mysql.com/doc/mysql/en/charset-collation-charset.html[/url]
    >The returncode attribute also throws an error. Any luck getting those to work
    100% perfectly?
    No, but I haven't used them extensively in this version and I don't really use
    return codes. Since mySQL 5.0.12 is still a beta and the CF MX7 docs only list
    support for mySQL 3.x and 4.0, I wasn't really expecting perfection ;-) I'll
    run a few more tests and let you know what I find.

    mxstu Guest

  10. #9

    Default Re: Calling stored procedure from MysQL 5.0

    Yes, I am happy Coldfusion MX 7 and MySQL 5.0.12 Beta even work to begin with!
    mxstu, I am getting JDBC errors that I never had with ODBC. Here is the error I
    am getting, any thoughts:

    [url]http://forums.mysql.com/read.php?39,43138,43138#msg-43138[/url]



    ShytKicker Guest

  11. #10

    Default Re: Calling stored procedure from MysQL 5.0

    mxstu, I don't know if this is JDBC 3.1 problem or MySQL 5.0.12 beta problem,
    but when using <cfqueryparam> in the where clause of a SELECT statement, the
    selected numeric columns return extrelemy strange values. For instance, this
    for me returns 1 for userid:

    SELECT userid
    FROM table
    WHERE userid = 1;

    But, this, returns 4294967297 for userid:

    SELECT userid
    FROM table
    WHERE userid = <cfqueryparam value='1'>;

    Any ideas?

    ShytKicker Guest

  12. #11

    Default Re: Calling stored procedure from MysQL 5.0

    First, you need to specify the cfsqltype (integer, varchar, etc).
    mxstu Guest

  13. #12

    Default Re: Calling stored procedure from MysQL 5.0

    I did, still nothing. Does it work for you?
    ShytKicker Guest

  14. #13

    Default Re: Calling stored procedure from MysQL 5.0

    Yes, this is my table and statement

    create table myTable (
    userId int auto_increment primary key,
    username varchar(50)
    );

    <cfquery name="test" datasource="myDSN">
    SELECT userid
    FROM mytable
    WHERE userid = <cfqueryparam value="1" cfsqltype="cf_sql_integer">;
    </cfquery>
    <cfdump var="#test#">

    mxstu Guest

  15. #14

    Default Re: Calling stored procedure from MysQL 5.0

    Hmmm that worked right. Maybe I should recreate my tables since I created them on MySQL 4.1 via ODBC.
    ShytKicker Guest

  16. #15

    Default Re: Calling stored procedure from MysQL 5.0

    Could be. I haven't used their ODBC connector for anything. Is the basic table structure the same?
    mxstu Guest

  17. #16

    Default Re: Calling stored procedure from MysQL 5.0

    Originally posted by: ShytKicker
    Yes, I am happy Coldfusion MX 7 and MySQL 5.0.12 Beta even work to begin with!
    mxstu, I am getting JDBC errors that I never had with ODBC. Here is the error I
    am getting, any thoughts:

    [url]http://forums.mysql.com/read.php?39,43138,43138#msg-43138[/url]



    Can you post the query and value(s) that generated this error? I haven't
    experienced it yet with this version.



    mxstu Guest

  18. #17

    Default Re: Calling stored procedure from MysQL 5.0

    Basically, if you have a date/time value of "0000-00-00 00:00:00" or a date
    value of "0000-00-00" then it will return an error since Java considers those
    "not valid date" values.

    So I had to change the datetime column default value to "0001-01-01 00:00:00".
    JDBC annoys me.

    The basic table structure is the same, only alot more info, but same WHERE
    clause, same primary key, auto_increment, etc. And the funny thing is, when it
    returns data, it returns all the integer fields with the MAXIMUM value for that
    datatype. For userid I had mediumint unsigned, and it returned 4294967297

    ShytKicker Guest

  19. #18

    Default Re: Calling stored procedure from MysQL 5.0

    mxstu, the problem still persists! I figured out why, it is because of UNSIGNED
    columns. I changed userid to UNSIGNED and now it is returning "4294967300"
    instead of "1". Let me know what you get after you change userid to UNSIGNED.

    ShytKicker Guest

  20. #19

    Default Re: Calling stored procedure from MysQL 5.0

    I get the same thing ("4294967300") when using cfqueryparam. I know I have not
    seen any mention of support for "unsigned" in the cfqueryparam docs so far.
    The query does work correctly without the cfqueryparam though.

    --- works correctly
    SELECT userid
    FROM mytable
    WHERE userid = 1;

    mxstu Guest

  21. #20

    Default Re: Calling stored procedure from MysQL 5.0

    UNSIGNED worked with cfqueryparam on MySQL 4.1.x for me when using the myODBC
    driver. I don't understand why it wouldn't, all that UNSIGNED means is that
    integer column cannot store negatives and can store double the positive total
    value.

    This is strange.

    ShytKicker Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139