If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > PHP > Returning mysql procedure error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-22-11, 11:07
bharanidharanit bharanidharanit is offline
Registered User
 
Join Date: Nov 2008
Posts: 115
Returning mysql procedure error

hi,
I hav a created a field with unique constraint, so if it got duplicated error must be returned from procedure. Wats wrong here?

PHP Code:
$dbconn = new DbConn;
        
$dbc $dbconn->Fn_CreateDbConn();
        
$Qry $dbc->prepare("CALL CMS_School_Insert(:SchoolID,:SchoolName)");    
        
$Qry -> bindParam(":SchoolID",$SchoolID);
        
$Qry -> bindParam(":SchoolName",$SchoolName);
                try
                {
            
$Qry -> execute();
                 }catch(
PDOException $e)
                  {
                      return 
"Error: ".$e->getMessage();
                  } 

Here s my procedure
Code:
DELIMITER //

CREATE DEFINER=`root`@`localhost` PROCEDURE `CMS_School_Insert`(_SchoolID INT, _SchoolName VARCHAR(100))
BEGIN
    IF (SELECT COUNT(*) FROM CMT_School WHERE School_ID=_SchoolID) = 0 THEN
        INSERT INTO CMT_School (School_Name) VALUES (_SchoolName);
    ELSE
        UPDATE CMT_School SET School_Name=_SchoolName WHERE School_ID=_SchoolID;
    END IF;
END//
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On