I launch a pl/sql script by a PHP application but I notice when there is either an insert, an update or a delete in the script, the script stops. While there is no problem if I use this script directly in sqldeveloper.
Is there something particular to do in order to use insert, delete, update ?
Thanks
procedure update_nbr_execution
(dem_id in number)
IS
BEGIN
UPDATE BCN_DEMANDE_EXTRACTION
SET nombre_execution = nvl(nombre_execution,0) + 1
WHERE id = dem_id;
END;
In my php file :
$query = "BEGIN
ecrire_requete(:demande_id, :p_nom);
END;";
$stid = oci_parse($conn, $query);
$tabvars = oci_new_collection($conn,'MYTABLETYPE');
oci_bind_by_name($stid, ':p_nom', $tabvars, -1, SQLT_NTY);
oci_bind_by_name($stid, ':demande_id', $_POST['demande_id']);
oci_execute($stid, OCI_DEFAULT);
And update_nbr_execution is call by ecrire_requete.
There is a trigger involve in update_nbr_execution, a field date is automatically update with the fiel nbr_execution. May it come from the trigger ?
Edit : after isolating some part, I’m now getting this error : ORA-04088: error during execution of trigger. So it does come from the trigger which looks like this :
create or replace
TRIGGER BCN_FORMAT_NOM_FICHIER_BI
BEFORE INSERT OR UPDATE ON BCN_DEMANDE_EXTRACTION
REFERENCING NEW AS NEW
FOR EACH ROW
DECLARE
BEGIN
if inserting then
:new.FORMAT_NOM_FICHIER_DONNEES:='bcn_<nom_lot>_<id demande>_<n° version>_<description>_<date>.dat';
:new.FORMAT_NOM_FICHIER_CONTROLE:='bcn_<nom_lot>_<id demande>_<n° version>_<date>.ctr';
:new.FORMAT_NOM_FICHIER_JETON:='bcn_<nom_lot>_<id demande>_<n° version>_<date>.jet';
:new.FORMAT_NOM_FICHIER_ZIP:='bcn_<nom_lot>_<id demande>_<n° version>_<date>';
:new.CREATED_AT:=TO_CHAR(SYSDATE,'DD/MM/YY');
:new.UPDATED_AT:=TO_CHAR(SYSDATE,'DD/MM/YY');
else
:new.UPDATED_AT:=TO_CHAR(SYSDATE,'DD/MM/YY');
end if;
END;
This is probably a date format issue.
If
CREATED_ATandUPDATED_ATare both dates, then= TO_CHAR(SYSDATE,'DD/MM/YY')will convert SYSDATE to a string, and then implicitly convert the string back to a date. The implicit date conversion
depends on NLS_DATE_FORMAT, which is set by each client.
You probably have SQL Developer set to use something like DD/MM/YY, but PHP is using something else. If you just
want to remove the time from SYSDATE, you should use
TRUNC(SYSDATE)instead.