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.
Related
My goal is to enable logging and tracing for the oracle database using the oracle client and npm package oracledb so that I can check when the query was started and when results were returned or if the query was timed out.
More precisely I want to check if it's the oracle client which is taking the time or if there is something wrong with the oracledb package.
I want to check logs for any errors and want to trace slow queries or queries for which a timeout error has occurred or any deadlock that occurs.
So far I'm successfully able to enable logging and tracing for the oracle database client and it's working only when I use sqlplus CLI but when it comes to the oracledb npm package it's not working.
I have created sqlnet.ora in $ORACLE_HOME/network/admin directory, and then pasted this content to enable logging and tracing for oracle-client.
LOG_DIRECTORY_CLIENT=C:\Oracle\instantclient_21_3\network\admin\cl-log
LOG_DIRECTORY_SERVER=C:\Oracle\instantclient_21_3\network\admin\srv-log
LOG_FILE_CLIENT=client
LOG_FILE_SERVER=svr.log
TRACE_LEVEL_CLIENT=ADMIN
DIAG_ADR_ENABLED=ON
ADR_BASE=C:\Oracle\instantclient_21_3\network\admin\log-adr
And as far as the implementation of oracledb with NodeJs is concerned I create connection pools using oracledb.createPool({...config}) and then when I need to query into DB I use oracledb.getPool('poolName').execute(query).
To me, the error is that it creates random .trc files and does not put logs to the sqlnet.log file only when using the oraceldb npm package.
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
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
I have setup a custom SSIS IR, however I'm having problems reading files from the current working directory or temp folder on the IR node
https://learn.microsoft.com/en-us/sql/integration-services/lift-shift/ssis-azure-files-file-shares?view=sql-server-2017
The work flow of my test package is
Load compressed file to Azure file share
Unzip file
Modify file, saving it the current working group folder on the IR node (this path .\testfile.json)
Load file to Azure SQL DB
The last step is where I'm having issues, I receive the below error message. Maybe looks to be related to security, but no idea how to access the SSIS IR node to check this.
Execute SQL Task:Error: Executing the query "DECLARE #request
VARCHAR(MAX) SELECT #request =..." failed with the following error:
"Cannot bulk load because the file ".\testfile.json" could not be
opened. Operating system error code (null).". Possible failure
reasons: Problems with the query, "ResultSet" property not set
correctly, parameters not set correctly, or connection not established
correctly.
How can I fix this issue?
From just the error message, looks like you're using BULK INSERT in Execute SQL Task to load data into Azure SQL DB. BULK INSERT into Azure SQL DB can only work from Azure Storage Blob, but not from file systems/SSIS IR nodes. To load data from the current working directory of SSIS IR nodes into Azure SQL DB, you can use a Data Flow with Flat File Source and ADO.NET Destination.
I have been sitting at this computer for 7 hours straight trying to deploy my app. There is a node/express backend serving up restricted API json data at different endpoints. In order to get access to this json data you have to have a token.
It all works fine and dandy on my local server during development. However, when I go to send the migrations to heroku (using 'heroku run bash', then 'sequelize db:migrate), I get some random error saying "SyntaxError: Unexpected String"..as shown below.
As you can see, when I run sequelize:db:migrate:undo, it says that no executed migrations found.
```
Sequelize [Node: 5.11.1, CLI: 2.4.0, ORM: 3.24.3, pg: ^6.1.0]
Loaded configuration file "config/config.json".
Using environment "production".
== 20160917224717-create-user: migrating =======
[SyntaxError: Unexpected string]
~ $ sequelize db:migrate:undo
Sequelize [Node: 5.11.1, CLI: 2.4.0, ORM: 3.24.3, pg: ^6.1.0]
Loaded configuration file "config/config.json".
Using environment "production".
No executed migrations found.
~ $
```
However, when I look in my heroku database, I DO see that there is now 1 table. However, that table does not work, and I am still getting an error on form submit to create a user. The error I get on form submit is:
message: "relation "users" does not exist"
name: "SequelizeDatabaseError"
What gives? This alleged syntax unexpected string error does not throw when I am running locally. It runs smooth as butter with the migrations. What could this be?
Thanks.
Either you have not updated your code on the server to match your local environment or your database does not match. "Users relation" implies the users table is related to another table. Make sure the code is really updated (if sequelize code mentions this relation) AND all other tables are reproduced on the server.
Once I got a problem with accessing postgres db on Heroku (provided as an add-on):
I installed SQL Shell (psql) on my laptop
I logged-in to the db (used all necessary credentials)
run: \dt to check db schema => result: 'no relations', so the migration wasn't done yet
run migrate:db
run: \dt => schema is here - OK!
now: run heroku console
login to your account
run: heroku restart -a=<my_app>
If the lack of db:migration was a problem only, it should be fine now.
You can also try to reset your db first (if your data isn't precious!) running: heroku pg:reset -a=<my_app>