1

I have created a stored procedure which do some updates in database. Now when I am trying to add that stored procedure using magento install script from sql folder, It is not being updated..

I cannot see stored procedure created in database.. I am using below syntax there

$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$write->query(STORED_PROCEDURE_SYNTAX);

1 Answer 1

1

Thank you all. I got solution from another stackoverflow comment

Now I have used syntax as below.

$sql = <<< __SQLPRC
STORED_PROCEDURE
__SQLPRC;

and run it using

$write = Mage::getSingleton('core/resource')->getConnection('core_write');
$write->exec($sql);

and it is working fine now

3
  • Does the .sql file not work in your scenario? (Which imo sounds like the better way of running SQL code)
    – Ash
    Commented Sep 23, 2014 at 13:13
  • I have not tried it as now I got solution using php file. But will try that in future
    – shabbir
    Commented Sep 23, 2014 at 13:14
  • I would recommend looking over This article by Alan Storm to understand how set-up resources work and i'm then sure you can create a install-X.X.X.sql to run the SQL syntax directly as your solution is a long winded way of the same thing.
    – Ash
    Commented Sep 23, 2014 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.