note 1363 modified in function.ociexecute by sixd

From: Date: Mon, 05 Oct 2009 02:02:42 +0000
Subject: note 1363 modified in function.ociexecute by sixd
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161319@lists.php.net to get a copy of this message
To catch what an error was about, I use a piece of PL/SQl instead of just a SELECT. For instance: <?php $query="BEGIN SELECT user_id INTO :v_user_id FROM rw_users WHERE gebruikersnaam = LOWER(:p_alias); :ERROR := 0; EXCEPTION when others then :ERROR := 1; :SQLCODE := SQLCODE; :SQLERRM := SUBSTR(SQLERRM,0,300); END; "; $stmt = OCIParse($conn, $query); /* Output parameters */ OCIBindByName($stmt,":ERROR",&$insert_error,32); OCIBindByName($stmt,":SQLCODE",&$SQLCODE,32); OCIBindByName($stmt,":SQLERRM",&$SQLERRM,300); OCIBindByName($stmt,":v_user_id",&$v_user_id,32); /* Input parameters */ OCIBindByName($stmt,":p_alias", &$p_alias, strlen($p_alias)+2); $exec_result = OCIExecute($stmt,OCI_DEFAULT); ?> Now if the select causes an exception, it is caught and the error message is stored. --was-- To catch what an error was about, I use a piece of PL/SQl instead of just a SELECT. For instance: <?php $query="BEGIN SELECT user_id INTO :v_user_id FROM rw_users WHERE gebruikersnaam = LOWER(:p_alias); :ERROR := 0; EXCEPTION when others then :ERROR := 1; :SQLCODE := SQLCODE; :SQLERRM := SUBSTR(SQLERRM,0,300); END; "; $stmt = OCIParse($conn, $query); /* Output parameters */ OCIBindByName($stmt,":ERROR",&$insert_error,32); OCIBindByName($stmt,":SQLCODE",&$SQLCODE,32); OCIBindByName($stmt,":SQLERRM",&$SQLERRM,300); OCIBindByName($stmt,":v_user_id",&$v_user_id,32); /* Input parameters */ OCIBindByName($stmt,":p_alias", &$p_alias, strlen($p_alias)+2); $exec_result = OCIExecute($stmt,OCI_DEFAULT); ?> Now if the select causes an exception, it is caught and the error message is stored. http://php.net/manual/en/function.ociexecute.php

« previous php.notes (#161319) next »