note 1363 modified in OCIExecute by ronabop

From: Date: Sun, 27 Aug 2000 11:44:15 +0000
Subject: note 1363 modified in OCIExecute by ronabop
Groups: php.notes 
Request: Send a blank email to php-notes+get-3473@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: $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://www.php.net/manual/function.ociexecute.php

« previous php.notes (#3473) next »