![]() |
Having error message show when stored procedure not successfull - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Having error message show when stored procedure not successfull (/showthread.php?tid=51194) |
Having error message show when stored procedure not successfull - El Forum - 04-24-2012 [eluser]bleu[/eluser] I am using a stored procedure which inserts data in a table. Now if I am inserting data with a primary key value which already exists in the table, then it should provide an error but currently it is taking me to this page Code: A Database Error Occurred I would like to return a proper message(such as "Cannot be inserted right now try again" or "Primary key already exists") to the user along with the page on which he submitted the daa if there exists a similar primary key value or if there is an error when inserting data. How can I achieve that? I am using codeigniter 2.1.0 Having error message show when stored procedure not successfull - El Forum - 04-24-2012 [eluser]vrencianz[/eluser] Use (for example) Code: try { Having error message show when stored procedure not successfull - El Forum - 04-24-2012 [eluser]bleu[/eluser] [quote author="vrencianz" date="1335285687"]Use (for example) Code: try { where will I place this where I have called my stored procedure? like try { $this->db->query("call spInsertabc('primary_key_value_which_already_exists','edd')") } catch (Exception $e) { ... // set a message here ... } Having error message show when stored procedure not successfull - El Forum - 04-24-2012 [eluser]vrencianz[/eluser] Code: try where your_view will echo $message |