MySQL Stored Function gives Access violation:1305 in Laravel but works in phpmyadmin

Khurram Ilyas

I have following stored function defined in my local database:

CREATE DEFINER=`root`@`localhost` FUNCTION `GenerateSectionFee`(`in_month` INT, `in_year` INT, `in_section_detail_id` INT, `in_issue_date` DATE, `in_due_date` DATE) RETURNS int(11)
    MODIFIES SQL DATA
BEGIN    
    /** Variables declartion **/
    declare v_new_mfm_id int;


    /** insert heads of given grade & section **/
    insert into month_fees_masters(section_details_id, fee_month, fee_year, issue_date, due_date,  h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, 
        th1, th2, th3, th4, th5, th6, th7, th8, th9, th10)
    select  
        class_detail_id, in_month, in_year, in_issue_date, in_due_date, h1, h2, h3, h4, h5, h6, h7, h8, h9, h10, 
        th1, th2, th3, th4, th5, th6, th7, th8, th9, th10 
    from fee_masters 
    where class_detail_id=in_section_detail_id and fee_type='R';

    /** Get id of inserted record **/
    SELECT LAST_INSERT_ID() into v_new_mfm_id;

    /** insert monthly fee of all students of given grade & section **/
    insert into month_fees(month_fees_masters_id, student_id, arears, fine_amount, fee_con, deposit_amount, status)
    select 
        v_new_mfm_id, s.id, (f.arears+f.fine_amount-f.fee_con-f.deposit_amount), 0 fine_amount, s.fee_con, 0 deposit_amount, 'L' status 
    from
        students s inner join month_fees f on s.id=f.student_id and f.status='L'
    where 
        s.cur_class_detail_id = in_section_detail_id and s.status='ACTIVE'
    ;

return (0); /** Zero means No Error. Records created successfully **/
END

When I call it from phpmyadmin it works fine. but when I call it from Laravel it gives following error:

[2014-11-03 05:53:54] production.ERROR: exception 'Illuminate\Database\QueryException' with message 'SQLSTATE[42000]: Syntax error or access violation: 1305 PROCEDURE iiui_db.GenerateSectionFee does not exist (SQL: call GenerateSectionFee(10, 2014, 27, 2014-10-01, 2014-10-08))' in C:\wamp\www\SchoolWeb\vendor\laravel\framework\src\Illuminate\Database\Connection.php:555

I am calling this function from Laravel as follows:

$flag_ = DB::statement('call GenerateSectionFee(?, ?, ?, ?, ?)', $data);

While $data is an array.

Jarek Tkaczyk

CALL is used with stored procedures - doc, while for a function you do:

select function(args)

so in your case:

$flag_ = DB::statement('select GenerateSectionFee(?, ?, ?, ?, ?)', $data);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

MySQL Stored Function gives Access violation:1305 in Laravel but works in phpmyadmin

From Dev

SQLSTATE[42000]: Syntax error or access violation: 1055 Laravel 5.8 MySQL

From Dev

function works but gives errors

From Dev

MySQL query works in PHPMyAdmin but not PHP

From Dev

MySQL Workbench works and phpmyadmin does not

From Dev

MySQL Workbench works and phpmyadmin does not

From Dev

MySQL UPDATE works in phpMyAdmin but not in PHP

From Dev

Mysql query works in Phpmyadmin but not works in PHP

From Dev

MySQL in PHP gives error, MySQL in phpmyadmin does not

From Dev

MySQL in PHP gives error, MySQL in phpmyadmin does not

From Dev

Access violation on recursive function with interfaces

From Dev

Access Violation in CvEM::getCovs function

From Dev

Access violation on recursive function with interfaces

From Dev

Mysql error #1305 FUNCTION db.sys_exec does not exists

From Dev

DB query from PHP gives no result but same query on phpMyAdmin works?

From Dev

Am trying to create a stored procedure in mysql phpmyadmin

From Dev

Query gives #1305 - FUNCTION database-name.LEN does not exist; WHY?

From Dev

MySQL SELECT query works in PHPmyadmin, not in PHP

From Dev

mysql query works in phpmyadmin but not in node.js

From Dev

MySQL INSERT query works in Phpmyadmin but not in PHP

From Dev

MySQL Query Not Working Live But Works In PHPMyAdmin

From Dev

mysql query works in phpmyadmin but errors in php

From Dev

PHP and MySQL french accent works in PHPMyAdmin but not in page

From Dev

#1305 - FUNCTION xxxx not exist

From Dev

Reading from a binary file gives me access violation

From Dev

Pass thread arguments by reference gives me access violation

From Dev

Calling virtual method in c++ gives access violation

From Dev

Vector::push_back() gives read access violation

From Java

Laravel : Syntax error or access violation: 1055 Error

Related Related

  1. 1

    MySQL Stored Function gives Access violation:1305 in Laravel but works in phpmyadmin

  2. 2

    SQLSTATE[42000]: Syntax error or access violation: 1055 Laravel 5.8 MySQL

  3. 3

    function works but gives errors

  4. 4

    MySQL query works in PHPMyAdmin but not PHP

  5. 5

    MySQL Workbench works and phpmyadmin does not

  6. 6

    MySQL Workbench works and phpmyadmin does not

  7. 7

    MySQL UPDATE works in phpMyAdmin but not in PHP

  8. 8

    Mysql query works in Phpmyadmin but not works in PHP

  9. 9

    MySQL in PHP gives error, MySQL in phpmyadmin does not

  10. 10

    MySQL in PHP gives error, MySQL in phpmyadmin does not

  11. 11

    Access violation on recursive function with interfaces

  12. 12

    Access Violation in CvEM::getCovs function

  13. 13

    Access violation on recursive function with interfaces

  14. 14

    Mysql error #1305 FUNCTION db.sys_exec does not exists

  15. 15

    DB query from PHP gives no result but same query on phpMyAdmin works?

  16. 16

    Am trying to create a stored procedure in mysql phpmyadmin

  17. 17

    Query gives #1305 - FUNCTION database-name.LEN does not exist; WHY?

  18. 18

    MySQL SELECT query works in PHPmyadmin, not in PHP

  19. 19

    mysql query works in phpmyadmin but not in node.js

  20. 20

    MySQL INSERT query works in Phpmyadmin but not in PHP

  21. 21

    MySQL Query Not Working Live But Works In PHPMyAdmin

  22. 22

    mysql query works in phpmyadmin but errors in php

  23. 23

    PHP and MySQL french accent works in PHPMyAdmin but not in page

  24. 24

    #1305 - FUNCTION xxxx not exist

  25. 25

    Reading from a binary file gives me access violation

  26. 26

    Pass thread arguments by reference gives me access violation

  27. 27

    Calling virtual method in c++ gives access violation

  28. 28

    Vector::push_back() gives read access violation

  29. 29

    Laravel : Syntax error or access violation: 1055 Error

HotTag

Archive