is there any way to discard image files in oracle database?
Clash Royale CLAN TAG#URR8PPP
is there any way to discard image files in oracle database?
<?php
$conn = oci_connect('ABCC', 'abcAA', 'orrfgfd2/UID1');
if (!$conn)
$m = oci_error();
echo $m['message'], "n";
exit;
else
$d = new DateTime();
$yesterday = $d->sub(new DateInterval('P1D'))->format('Y.m.d');
$filename = "access.$yesterday.txt";
if(file_exists($filename))
$myfile = fopen($filename, "r");
while(!feof($myfile))
$content= fgets($myfile);
$carray=explode(',',$content);
list($IP_ADDRESS, $USER_IDENTIFIER, $USERID , $REQUEST_TIME , $CLIENT_REQUEST ,$RESPONSE_CODE ,$SIZEOFOBJECT, $COOKIES)=$carray;
$stdii = 'INSERT INTO LOGS(IP_ADDRESS, USER_IDENTIFIER, USERID , REQUEST_TIME , CLIENT_REQUEST ,RESPONSE_CODE ,SIZEOFOBJECT, COOKIES)'.
'values(:IP_ADDRESS, :USER_IDENTIFIER, :USERID , :REQUEST_TIME , :CLIENT_REQUEST ,:RESPONSE_CODE ,:SIZEOFOBJECT, :COOKIES)';
$compiled1 = oci_parse($conn, $stdii);
oci_bind_by_name($compiled1, ':IP_ADDRESS', $IP_ADDRESS);
oci_bind_by_name($compiled1, ':USER_IDENTIFIER', $USER_IDENTIFIER);
oci_bind_by_name($compiled1,':USERID', $USERID);
oci_bind_by_name($compiled1, ':REQUEST_TIME', $REQUEST_TIME);
oci_bind_by_name($compiled1, ':CLIENT_REQUEST', $CLIENT_REQUEST);
oci_bind_by_name($compiled1, ':RESPONSE_CODE', $RESPONSE_CODE);
oci_bind_by_name($compiled1, ':SIZEOFOBJECT', $SIZEOFOBJECT);
oci_bind_by_name($compiled1, ':COOKIES', $COOKIES);
oci_execute($compiled1, OCI_COMMIT_ON_SUCCESS);
$message="File Uploaded";
echo "<script type='text/javascript'>alert("$message");</script>";
fclose($myfile);
else
$message2="File Doesn't exists";
echo "<script type='text/javascript'>alert("$message2");</script>";
oci_close($conn);
?>
I have designed a script which will upload log file data to oracle database. However i want to filter images in my data upload. Here in this case,i don't want my code to upload CLIENT_REQUEST("GET /icons/back.gif HTTP/1.1") having .gif extensions in my request. Can someone please help me with the query.
My Log File
127.0.0.1,-,-,[06/Aug/2018:09:22:02 +0200],"GET /icons/back.gif HTTP/1.1",304,-,"-"
127.0.0.1,-,-,[06/Aug/2018:09:22:02 +0200],"GET /icons/blank.gif HTTP/1.1",304,-,"-"
127.0.0.1,-,-,[06/Aug/2018:09:22:02 +0200],"GET /icons/unknown.gif HTTP/1.1",304,-,"-"
127.0.0.1,-,-,[06/Aug/2018:09:22:02 +0200],"GET /icons/image2.gif HTTP/1.1",304,-,"-"
127.0.0.1,-,-,[06/Aug/2018:09:22:02 +0200],"GET /icons/text.gif HTTP/1.1",304,-,"-"
grep
I have added my code. I am taking my log file(txt file) data and inserting into oracle database. However i want to discard image data to upload to my table.
– SSneha
Aug 6 at 11:56
1 Answer
1
If you use the log file as an external table, then you can load it via (PL/)SQL and actually write a WHERE
clause which will reject such rows. For example:
WHERE
insert into your_table (col1, col2, ...)
select ...
from log_file_as_external_table
where instr(log_file_line, '.gif HTTP/1.1') = 0
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
What is you script doing, and how does it load the data? You might just want to filter the rows from the source data e.g. with
grep
, but it depends what you are doing already. An external table could use a preprocessor to do the same thing. Or you can filter it after loading. Etc.– Alex Poole
Aug 6 at 11:44