I have two databases, one is in a test environment and is sqllite3 and the other is an oracle db for qa/prod. It’s not my system and I am not in control of this set-up. I wrote an SQL query that works in my test environment but failed against qa. I’m assuming it has something to do with discrepancies between oracle and sqllite3 but I can’t figure out what’s going on. thanks for the help.
here’s the error and the SQL:
OCIError: ORA-00903: invalid table name:
SELECT 'agency' AS came_from,
account.name as account_name, agency.id as id,
agency.name as name,
agency.contact_name as contact_name,
agency.contact_email as
contact_email, agency.phone_number as phone_number,
agency.account as account
FROM 'agency' LEFT OUTER JOIN account
ON account.id ='agency'.account WHERE account in (1601)
UNION SELECT 'advertiser' AS came_from,
account.name as account_name, advertiser.id as id,
advertiser.name as name, advertiser.contact_name as contact_name,
advertiser.contact_email as contact_email,
advertiser.phone_number as phone_number,
advertiser.account as account
FROM 'advertiser'
LEFT OUTER JOIN account ON account.id = 'advertiser'.account
WHERE account in (1601) AND (advertiser.workflow_state <> 'deleted'
OR advertiser.workflow_state
IS NULL) ORDER BY name asc
‘agency’ and ‘advertiser’ are not valid table names in Oracle.
Most commonly, the tables would be named
AGENCYandADVERTISERand you could then change yourFROMclauses to remove the single quotes. Potentially, however, you created the tables using case-sensitive identifiers and would need to use double-quotes to refer to the table name, i.e.Even less likely, you created the tables using case sensitive identifiers and included single quotes in the table name in which case you’d need both double-quotes and single quotes but that would be exceptionally odd
If you’re not sure what the name of the table is, you can query the data dictionary