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

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 Sep 23 '14 at 13:13
  • I have not tried it as now I got solution using php file. But will try that in future – shabbir Sep 23 '14 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 Sep 23 '14 at 13:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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