使用OCI检索最新ID

时间:2019-03-21 16:53:38

标签: php oracle oci

我如何检索插入的最新BoatId。以便将其插入到Operator表中。这是我当前已完成的代码。

    $bName = $_POST['boatName'];
    $bOperatorName = $_POST['boatOperatorName'];
    $bOperatorNoPhone = $_POST['boatOperatorNoPhone'];
    $bCapacity = $_POST['boatCapacity'];
    $bPrice = $_POST['boatPrice'];
    $bService = "ON DUTY";

    $query = 'INSERT INTO BOAT(BOAT_NAME,BOAT_CAPACITY,BOAT_PICTURE,BOAT_SERVICE_STATUS,BOAT_PRICE)' 
 . 
         'VALUES(:boatName ,:boatCapacity,:boatPicture,:boatService,:boatPrice) RETURNING BOAT_ID INTO :p_val';

    $query1 = 'INSERT INTO OPERATOR(BOAT_ID,OPERATOR_NAME,OPERATOR_NO_PHONE)'.
    'VALUES(:p_val,:oName,:oNoPhone)';

    $compiled = oci_parse($dbconn, $query);

    $compiled2 = oci_parse($dbconn,$query1);

    oci_bind_by_name($compiled, ':boatName', $bName);
    oci_bind_by_name($compiled2, ':oName', $bOperatorName);
    oci_bind_by_name($compiled, ':boatCapacity', $bCapacity);
    oci_bind_by_name($compiled2, ':oNoPhone', $bOperatorNoPhone);
    oci_bind_by_name($compiled, ':boatPicture', $name);
    oci_bind_by_name($compiled, ':boatService', $bService);
    oci_bind_by_name($compiled, ':boatPrice', $bPrice);
    oci_bind_by_name($compiled,':p_val',$val,18);

    oci_execute($compiled);

    oci_execute($compiled2);

我希望任何人都能帮助我...

0 个答案:

没有答案