ARTICLE AD BOX
I have the following PHP script that I have inherited, I am getting the following error but I cannot find the issue.
<?php if(php_sapi_name() == "cli"){ // c:\php\php.exe C:\inetpub\wwwroot\Sandpit\workOrderreportInCli.php //echo 'Set Work orders to Reported'; $headerLineCount = 1; $urlName = 'http://localhost:8024'; $fileName = 'SOWA%20WO%20Reported';//Spaces converted for URL $fileExtension = 'csv'; $fullFileName = $urlName.'/'.$fileName.'.'.$fileExtension; $fileHandle = fopen($fullFileName, 'r'); if($fileHandle === false){ echo 'Error getting file contents: '.$fullFileName; }else{ include 'settings.php'; include 'functions.php'; echo 'Found file, connecting to database...'.PHP_EOL; $c = oci_connect($db_username, $db_password, $db_connection); if($c){ $sql = 'select ifsapp.cd_file_upload_api.get_next_seq_no(:lu_name) from dual;'; $lu_name = 'UploadSowaWoReported'; $stmtId = oci_parse($c, $sql); oci_bind_by_name($stmtId, ':lu_name', $lu_name); oci_execute($stmtId); $resultRow = oci_fetch_array($stmtId); $sequenceNo = $resultRow['NEXT_SEQUENCE_NO']; $rowNo = 0; $recordNo = 0; $rowsPerBlock = 50; echo 'Next Sequence No: '.$sequenceNo.PHP_EOL; $sqlInsertHead = " declare info_ varchar2(2000); objid_ varchar2(200); objversion_ varchar2(200); attr_ varchar2(2000); begin "; $sqlInsertBody = ''; $isFirstRow = true; while(($fileCsv = fgetcsv($fileHandle, 1000, ',')) !== false){ $rowNo += 1; $referenceNo = addslashes($fileCsv[0]); if($rowNo > $headerLineCount && strlen(trim($referenceNo)) > 0){ $isFirstRow = false; $recordNo += 1; $sqlInsertBody .= " ifsapp.client_sys.clear_attr(attr_); ifsapp.client_sys.add_to_attr('CF\$_SEQUENCE_NO', ".$sequenceNo.", attr_); ifsapp.client_sys.add_to_attr('CF\$_ROW_NO', ".($rowNo-$headerLineCount).", attr_); ifsapp.client_sys.add_to_attr('CF\$_ROW_STATE', 'New', attr_); ifsapp.client_sys.add_to_attr('CF\$_DATE_CREATED', sysdate, attr_); ifsapp.client_sys.add_to_attr('CF\$_ROW_MESSAGE', '', attr_); ifsapp.client_sys.add_to_attr('CF\$_REFERENCE_NO', '".$referenceNo."', attr_); ifsapp.upload_sowa_wo_reported_clp.New__(info_, objid_, objversion_, attr_, 'DO'); "; if($recordNo == $rowsPerBlock){//End of each Block $stmtInsert = oci_parse($c, $sqlInsertHead.$sqlInsertBody." end;"); $resultInsert = oci_execute($stmtInsert); if(!$resultInsert){ $errorInsert = oci_error($stmtInsert); echo var_dump($errorInsert).PHP_EOL; }else{ $sqlInsertBody = ''; } $recordNo = 0; }////End of each Block }//Skip Header line }//WHILE each line in the csv file //Do for the last rows in the last block $stmtInsert = oci_parse($c, $sqlInsertHead.$sqlInsertBody." end;"); $resultInsert = oci_execute($stmtInsert); if(!$resultInsert){ $errorInsert = oci_error($stmtInsert); echo var_dump($errorInsert).PHP_EOL; }else{ //echo 'Rows Inserted'.PHP_EOL; } //Delete or rename the file after processing -- CAN'T DO THIS because the file is comming in from an http URL }else{ $err = oci_error(); echo 'Oracle Connect Error ' . $err['text']; } fclose($fileHandle); //Now that all the rows are in, expecute the procedure to process them $sqlExecute = " begin ifsapp.cd_file_upload_api.process_sowa_wo_reported(".$sequenceNo."); end; "; $stmtExecute = oci_parse($c, $sqlExecute); $resultExecute = oci_execute($stmtExecute); if(!$resultExecute){ $errorExecute = oci_error($resultExecute); echo var_dump($errorExecute).PHP_EOL; }else{ echo 'Rows Processes'.PHP_EOL; } }//if file found }else{ echo 'Do not call CLI files from the browser.'; }The job is failing see below, 1 thing that I have noticed is that the next sequence number is blank.
Found file, connecting to database... Next Sequence No: array(4) {
["code"]=> int(6550) ["message"]=> string(489) "ORA-06550: line
10, column 2: PLS-00103: Encountered the symbol "/" when expecting one
of the following:
( begin case declare end exception exit for goto if loop mod
null pragma raise return select update while with
<<
continue close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge pipe purge
json_exists json_value json_query json_object json_array"
["offset"]=> int(171) ["sqltext"]=> string(1313) " declare
info_ varchar2(2000); objid_ varchar2(200); objversion_
varchar2(200); attr_ varchar2(2000); begin
ifsapp.client_sys.clear_attr(attr_); //
ifsapp.client_sys.add_to_attr('CF$SEQUENCE_NO', , attr);
ifsapp.client_sys.add_to_attr('CF$SEQUENCE_NO', 45, attr);
ifsapp.client_sys.add_to_attr('CF$ROW_NO', 1, attr);
ifsapp.client_sys.add_to_attr('CF$ROW_STATE', 'New', attr);
ifsapp.client_sys.add_to_attr('CF$DATE_CREATED', sysdate, attr);
ifsapp.client_sys.add_to_attr('CF$ROW_MESSAGE', '', attr);
ifsapp.client_sys.add_to_attr('CF$REFERENCE_NO', '14373164', attr);
ifsapp.upload_sowa_wo_reported_clp.New__(info_, objid_, objversion_,
attr_, 'DO');
ifsapp.client_sys.clear_attr(attr_); //
ifsapp.client_sys.add_to_attr('CF$SEQUENCE_NO', , attr);
ifsapp.client_sys.add_to_attr('CF$SEQUENCE_NO', 45, attr);
ifsapp.client_sys.add_to_attr('CF$ROW_NO', 2, attr);
ifsapp.client_sys.add_to_attr('CF$ROW_STATE', 'New', attr);
ifsapp.client_sys.add_to_attr('CF$DATE_CREATED', sysdate, attr);
ifsapp.client_sys.add_to_attr('CF$ROW_MESSAGE', '', attr);
ifsapp.client_sys.add_to_attr('CF$REFERENCE_NO', '14343401', attr);
ifsapp.upload_sowa_wo_reported_clp.New__(info_, objid_, objversion_,
attr_, 'DO');
Fatal error: Uncaught TypeError: oci_error(): Argument #1 ($connection_or_statement) must be of type resource or null, bool given in C:\inetpub\wwwroot\Sandpit\workOrderReportInCli.php:101 Stack trace: #0 C:\inetpub\wwwroot\Sandpit\workOrderReportInCli.php(101): oci_error(false) #1 {main} thrown in C:\inetpub\wwwroot\Sandpit\workOrderReportInCli.php on line 101
