SQLPLUS Help with a Linux Script
I am receiving an SQLPLUS error of 155.
Apparently my SQL code is being truncated (I believe).
I originally had all of this code on separate lines to make it readable. Unfortunately for that try I also received a return code of 155.
I copied this SQL from my SQL DEVELOPER where this SQL works properly.
Can anybody make any suggestions?
BTW, I am newbie to both Linux Shell Scripts, SQL, and SQLPLUS.
Here is the log from the run of the script:
SQL*Plus: Release 11.2.0.2.0 Production on Fri May 4 17:49:38 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL> SQL> Connected.
SQL> SQL> SQL> SELECT to_char(c.update_date, 'FMMonth, YYYY') 'Shipment Update Date'||'|'||b.SHIPMENT_GID 'Shipment Number'||'|'||count (distinct (b.SHIPMENT_GID)) 'No of Shipments'||'|'||count(distinct(a.i_transaction_no)) 'Auctions per Shipment'||'|'||count(*) 'No. of Carriers Notified'||'|'||sum (case when a.responding_gl_user_gid is null then 0 else 1 end) 'No of Bidders'||'|'||min (numtodsinterval((b.expected_response - b.insert_date),'day')) 'Duration of Auction'||'|'||min (numtodsinterval((a.update_date - a.transaction_time),'day')) 'Elapse time for first bid'||'|'||max (numtodsinterval((a.update_date - a.transaction_time),'day')) 'Elapse time for last bid'||'|'||numtodsinterval((max(a.update_date) - min(a.update_date)),'day') 'Elapse time of bidding'||'|'||numtodsinterval((max(b.shipment_time) - max(c.insert_date)),'day') 'Lead Time of Auction to P/U'||'|'||(max(a.bid_amount) - min(a.bid_amount)) 'High Bid- Low Bid Diff' from tender_collab_servprov a, tender_collaboration b, shipment c where a.i_transaction_no = b.i_transaction_no and b.shipment_gid not in (select sqa.shipment_gid from tender_collaboration sqa, tender_collab_servprov sqb where sqa.i_transaction_no = sqb.i_transaction_no and sqb.acceptance_code = 'A') and a.i_transaction_no in (select i_transaction_no from tender_collaboration where tender_type = 'Spot Bid') and b.shipment_gid = c.shipment_gid AND c.update_date >= trunc(last_day(to_date((to_char(add_months(SYSDATE,-2), 'MM-DD-YYYY')),'MM-DD-YYYY')) + 1) group by c.update_date, b.SHIPMENT_GID order by c.update_date, b.shipment_GID
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Here is the Linux Shell script:
/bin/sh
LOGFILE="$(date +"%Y-%m-%d %H") Oracle REPORT LOG.TXT"
FILENAME="$(date +"%Y-%m-%d") PROD Unfinished Spot Bids.CSV"
echo "File Name for the spool is:" "$FILENAME"
#spool "$FILENAME"
sqlplus /nolog <<EOF >$LOGFILE
whenever sqlerror exit sql.sqlcode
connect glog_read/parker@OTMDEV
spool PROD_Unfinished.CSV
set linesize 32000 trimspool on pagesize 3000
SELECT to_char(c.update_date, 'FMMonth, YYYY') 'Shipment Update Date'||'|'||b.SHIPMENT_GID 'Shipment Number'||'|'||count (distinct (b.SHIPMENT_GID)) 'No of Shipments'||'|'||count(distinct(a.i_transaction_no)) 'Auctions per Shipment'||'|'||count(*) 'No. of Carriers Notified'||'|'||sum (case when a.responding_gl_user_gid is null then 0 else 1 end) 'No of Bidders'||'|'||min (numtodsinterval((b.expected_response - b.insert_date),'day')) 'Duration of Auction'||'|'||min (numtodsinterval((a.update_date - a.transaction_time),'day')) 'Elapse time for first bid'||'|'||max (numtodsinterval((a.update_date - a.transaction_time),'day')) 'Elapse time for last bid'||'|'||numtodsinterval((max(a.update_date) - min(a.update_date)),'day') 'Elapse time of bidding'||'|'||numtodsinterval((max(b.shipment_time) - max(c.insert_date)),'day') 'Lead Time of Auction to P/U'||'|'||(max(a.bid_amount) - min(a.bid_amount)) 'High Bid- Low Bid Diff' from tender_collab_servprov a, tender_collaboration b, shipment c where a.i_transaction_no = b.i_transaction_no and b.shipment_gid not in (select sqa.shipment_gid from tender_collaboration sqa, tender_collab_servprov sqb where sqa.i_transaction_no = sqb.i_transaction_no and sqb.acceptance_code = 'A') and a.i_transaction_no in (select i_transaction_no from tender_collaboration where tender_type = 'Spot Bid') and b.shipment_gid = c.shipment_gid AND c.update_date >= trunc(last_day(to_date((to_char(add_months(SYSDATE,-2), 'MM-DD-YYYY')),'MM-DD-YYYY')) + 1) group by c.update_date, b.SHIPMENT_GID order by c.update_date, b.shipment_GID;
spool off
EOF
RV=$?
echo "The return code fronm the sqlplus was:" "$RV"