如果查询有错误,我正在尝试输出错误消息,这是我的代码:
class app {
private $db;
private $con;
private $err;
...
public function addNewRelative($parentId, $name, $relationCode, $relation, $phone, $email) {
$sql = "BEGIN XXDM_DSQUARE_PKG.CREATE_CONTACTS(
:P_SUBJECT_PARTY_ID,
:P_OBJECT_PARTY_NAME',
:P_RELATIONSHIP_CODE,
:P_RELATIONSHIP_TYPE,
:P_MOBILE_NUMBER,
:P_EMAIL_ADDRESS,
:X_ERROR_MSG
); END;";
//Statement does not change
$stmt = oci_parse($this->con, $sql);
oci_bind_by_name($stmt, ':P_SUBJECT_PARTY_ID', $parentId);
oci_bind_by_name($stmt, ':P_OBJECT_PARTY_NAME', $name);
oci_bind_by_name($stmt, ':P_RELATIONSHIP_CODE', $relationCode);
oci_bind_by_name($stmt, ':P_RELATIONSHIP_TYPE', $relation);
oci_bind_by_name($stmt, ':P_MOBILE_NUMBER', $phone);
oci_bind_by_name($stmt, ':P_EMAIL_ADDRESS', $email);
oci_bind_by_name($stmt, ':X_ERROR_MSG', $this->err);
// Execute the statement as in your first try
if (oci_execute($stmt)) {
return json_encode(["response"=>1]);
} else {
return json_encode(["response"=>0]);
}
}
但是出现以下错误:
Warning: oci_execute(): ORA-06550: line 8, column 6: PLS-00363: expression '<null>' cannot be used as an assignment target ORA-06550: line 1, column 7: PL/SQL: Statement ignored in D:\Server\wamp\www\dmg-dsquares-bk\app.php on line 94
问题出在“ X_ERROR_MSG”参数,因为它是OUT参数,我不知道如何绑定它。