I am having trouble trying to insert a timestamp input into my Oracle SQL Developer database. I have a table named userappt and the column called appt_date is a timestamp value. Then, I have a stored procedure called insertapptpro that will be called in my php file named insertappt.php as the action for a html form file named userappt.html. I tried inserting a new appointment but the error Warning: oci_execute(): ORA-01843: not a valid month ORA-06512
appears and returns nothing to my database.
Here is my table and stored procedure code:
create table appt
(
appt_id varchar(15) primary key,
pet_name varchar(100),
purpose varchar(50),
appt_date timestamp
);
create or replace procedure insertapptPro(
p_name appt.pet_name%type, p_purpose appt.purpose%type, p_date appt.appt_date%type)
is
begin
insert into appt(pet_name, purpose, appt_date)
values (p_name, p_purpose, p_date);
end;
/
declare
a varchar(100);
b varchar(50);
c timestamp;
begin
a := 'Jack Jack';
b := 'Rear bleeding';
c := '15-Dec-2019 09:00';
insertapptpro(a,b,c);
end;
/
And this is my php code for the file insertappt.php:
$name = $_POST['PET_NAME'];
$purp = $_POST['PURPOSE'];
$date = $_POST['APPT_DATE'];
$query1 = 'BEGIN INSERTAPPTPRO(:PET_NAME, :PURPOSE, :APPT_DATE);END;';
$result = oci_parse($connection, $query1);
oci_bind_by_name($result, ':PET_NAME', $name);
oci_bind_by_name($result, ':PURPOSE', $purp);
oci_bind_by_name($result, ':APPT_DATE', $date);
oci_execute($result);
if (oci_fetch($result)==0)
{
echo "<script type=\"text/javascript\">window.alert('Booked Successfully!')";window.location.href='/system/userappt.php';</script>";
}
else
{
echo "<script type=\"text/javascript\">window.alert('Register Failed');</script>";
}
?>
And lastly, my html form code for the file userappt.html:
<form class="" action="insertappt.php" method="post">
<p>
Pet Name: <input type="text" name="PET_NAME" placeholder="Patient Name" class="inputtxt" required>
Purpose: <input type="text" name="PURPOSE" placeholder="Purpose" class="inputtxt" required>
Appointment date and time: <input type="datetime-local" name="APPT_DATE" placeholder="Appointment date and time" class="inputtxt" required>
<input type="submit" value="Book" class="subbtn">
</form>
I'm fairly new to using datetime-local in html and timestamp in oracle, so I hope I'll learn something from you guys.