Error 2147217900 Invalid SQL statement; expected .... (mind alteringissue)

G

gssstuff

I have a real mind-bender.

I am using an access db to run several data pulls from different
sources. Two sources are Oracle databases. I have a series of SQL
scripts that are run and append the data to a local database. All but
one script works fine. the one that doesn't throws out the error
shown above.

I am using a vba script that reads the SQL scripts from a table for
each data pull.

I have tried attempts to simplify the SQL by limiting tables to see if
that is the cause of the error. I backed down to one table and one
field and still get the error.

Here is the SQL that errors out:
select
msi.segment1
from inv.mtl_system_items_b msi
where msi.organization_id = 1234
and msi.segment1 = 'PART_NUMBER_X

Here is the SQL that works:
Select
msi.segment1 item_number,
'XXX' org,
msi.primary_unit_of_measure,
msi.planner_code,
msi.inventory_item_status_code,
to_char(msi.creation_date,'mm/dd/yyyy') created,
to_number(to_char(msi.last_update_date,'yyyymmdd.hh24miss'))
last_update,
msi.item_type,
msi.attribute3 modality,
msi.attribute2 pole,
decode(msi.ato_forecast_control,1,'Consume',2,'Consume and Derive',
3,'None','Other') forecast_control,
decode (msi.mrp_planning_code,3,'MRP planning',4,'MPS planning',6,'Not
planned',7,'MRP and MPP planning',8,'MPS and MPP planning',9,'MPP
planning','Other') planning_method,
decode(msi.SHELF_LIFE_CODE,1,'None',2,'Days',4,'User-Defined','Other')
SHELF_LIFE_METHOD,
decode(msi.SERIAL_NUMBER_CONTROL_CODE,1,'None',2,'Predefined',5,'Rcpt',
6,'Issue','Other') SER_CTRL,
decode(msi.LOT_CONTROL_CODE,1,'None',2,'Full','Other') LOT_CTRL,
msi.description
from inv.mtl_system_items_b msi
where msi.ORGANIZATION_ID = 1234


I have tried just about everything, including evaluating each string
for any special/hidden characters. When I paste both scripts into SQL
Developer or TOAD, both run fine.

Any ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top