Oracle: Why am I getting Error: ORA-00903: invalid table name when database table exists? - node.js

Background
I have a NodeJS server powered by ExpressJS that fetches data from Oracle database. I manage the database with Oracle SQL Developer tool. There is a database called MCF01 created using Database Configuration Assistant with pluggable database also named MCF01.
I connect to it using SYSTEM and the admin password both inside Oracle SQL Developer tool and from my server:
Now I created a table named CM_ITM_ALL:
CREATE TABLE "SYS"."CM_ITM_ALL" ...
I can without a problem query inside CM_ITM_ALL from Oracle SQL Developer tool like so:
Problem
I cannot execute the same query SELECT ITM_NM FROM CM_ITM_ALL WHERE ITM_NUM='a800004' using my nodejs server. What is the problem here?
Here is the error message from the Oracle via my server:
[Error: ORA-00942: table or view does not exist] {
errorNum: 942,
offset: 19
}
Table does exist. Connection is not a problem as it is giving out the table does not exist error. Otherwise it would give out wrong credentials error.
What I tried
Appending SYS into the query: SELECT ITM_NM FROM SYS.CM_ITM_ALL WHERE ITM_NUM='a800004'
Quoting the table name inside the query to SELECT ITM_NM FROM 'SYS'.'CM_ITM_ALL' WHERE ITM_NUM='a800004'
Dev environment
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0
NodeJS v16.13.0
ExpressJs 4.17.2
node-oracledb 5.3.0
Oracle SQL Developer 21.4.2

Related

Excel 365 How to run an Oracle Stored Procedure from Get Data

I am having a problem working out how to run an Oracle Stored Proc from Excel's:-
Get Data -> From Database -> From Oracle Database -> Advanced Options section.
I can connect ok to Oracle and query tables from within the Advanced Options, but when I try and execute the following stored proc, EXEC sp_Test or EXECUTE sp_Test
I get the following error message:-
Unable to connect
We encountered an error while trying to connect
Details: "Oracle: ORA-00900: invalid SQL statement"
This stored proc works fine from both within SQL Developer and from an SSRS report.
There are no parameters in the Stored Proc.
Any thoughts on how I can achieve this will be gratefully accepted.
Regards,
NJC

IBM AS400 File not Found error while the Table Object is still there

I'm relatively new to working with remote IBM databases. I am connecting to a remote IBM AS400 database using an ODBC Python3 connector in an Anaconda virtual environment on Windows 10. My connection that successfully works is:
import pyodbc
connection = pyodbc.connect(
Driver='{iSeries Access ODBC Driver}',
System='<host>',
database='<database>',
uid='<username>',
pwd='<password>')
c1 = connection.cursor()
print('Connection established')
After connecting I run this command to see the list of tables:
c1.execute("select table_name from sysibm.sqltables")
And I see all the tables that I would need to query. But then when I try to query the contents of a specific table using:
c1.execute("select * from <database>.<table> LIMIT 100")
I get an error:
ProgrammingError: ('42S02', '[42S02] [IBM][System i Access ODBC Driver][DB2 for i5/OS]SQL0204 - <table> der Art *FILE in <database> nicht gefunden. (-204) (SQLExecDirectW)')
(It's in German, it means table of type *FILE in database not found)
(And I'm not using angle brackets, it's just for demonstration)
But a software like DBeaver returns valid data for both of them, for the tables list query and the specific table query. It's only python that gives the error.
Can anyone point out what could I be doing wrong? Or what can I run to pinpoint the problem?
<database>.<table> is not correct.
On Db2 you have
database
-schema
--table
you should be using <schema>.<table> as the database has been specified in the connection string.
<database>.<schema>.<table> is supported when connecting to a remote database from the "local" one...but only for basic selects. Db2 for IBM i doesn't support for example joining between a "local" and remote table.

How to setup ODBC connection via command line for Teradata driver?

I am trying to setup a Teradata ODBC User DSN via below command line code.
%WINDIR%\System32\odbcconf.exe CONFIGDSN "Teradata" "DSN=Test|Description=Test|SERVER=ServerName|Trusted_Connection=Yes|Database=Controltub|UID=<LoginId>"
%WINDIR%\SysWOW64\odbcconf.exe CONFIGDSN "Teradata" "DSN=Test|Description=Test|SERVER=ServerName|Trusted_Connection=Tes|Database=Controltub|UID=<LoginId>"
This code works fine for "SQL Server" driver. However when I try to make changes accordingly for Teradata ODBC creation, it fails without any error.
I get blank in text fields for server name/IP field & user id in ODBC window.
The following worked for me with the Teradata 16.20 Driver on Windows 7:
%WINDIR%\System32\odbcconf.exe CONFIGDSN “Teradata Database ODBC Driver 16.20” “DSN=Test|Description=Test|DBCName={server}|DefaultDatabase=DBC|MechanismName=TD2|Username={user}”
Once you create the DSN, you can go into the Registry under Computer\HKEY_CURRENT_USER\Software\ODBC\ODBC.INI{DSN Name} and try the other property (key) names to customize the DSN creation further. What I provide should get you a basic DSN to connect to Teradata.
Replace TD2 with LDAP if your environment uses LDAP authentication.

Execute SQL file which contains multiple stored procedures in Node.js?

How can I execute a SQL file which contains multiple stored procedures and a lot of SQL script in Node.js?
I have tried to execute the sql file using npm package execsql but it doesn't work. Here is the link which I have tried.
Able to install
Did DB configuration
Getting this error while executing sql statement or sql file:
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'usernane'#'myipaddress' (using password: YES) –
Yet I am able to execute sql statements using npm package mysql with the same db configuration.

Unable to query SQL server 2008 databse from linux?

I have written a JAVA SPRING RESTFUL web-service to query SQL server 2008 database using sqljdbc4 driver. It works fine from windows machine, but when I deploy the code to a Linux box I am not be to execute both select and insert queries.
I tried using “SET NOCOUNT ON”, but no luck.
Error while executing select query
org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [ Select statement ………. );]; SQL state [null]; error code [0]; The statement did not return a result set.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: The statement did not return a result set.
Error while executing insert query
org.springframework.dao.DataAccessResourceFailureException: PreparedStatementCallback; SQL [Insert into log(id, datetime) values(?,?)]; SQL Server did not return a response. The connection has been closed.; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: SQL Server did not return a response. The connection has been closed.
JDBC driver POM dependency.
com.microsoft.sqlserver
sqljdbc4
4.0
I tried some other stuff that I read on google but no luck. If some can point me to a right direction, I would really appreciate help.
Try using jtds driver instead of microsoft jdbc driver.

Resources