开发者

get primary key or unique error with sql

I am working on a ORACLE SQL table which have a primary key on two fields. I would like to retreive primary key error during an开发者_JAVA技巧 insertion with PHP.

I placed code in a try/catch and I don't get any errors.

I don't have a lot of skills with databases, but I know here we use triggers. Maybe I could catch here the error ?

Thank you!


Check this link on php.net

The function that returns the error is oci_error()

to quote from php.net

<?php
$stid = oci_parse($conn, "SELECT does_not_exist FROM dual");
$r = oci_execute($stid);
if (!$r) {
    $e = oci_error($stid);  // For oci_execute errors pass the statement handle
    print htmlentities($e['message']);
    print "\n<pre>\n";
    print htmlentities($e['sqltext']);
    printf("\n%".($e['offset']+1)."s", "^");
    print  "\n</pre>\n";
}
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜