Comments (9)
I think this has been the default behaviour inherited from the original node-sqlserver.
How about something like the following:
loadedQuery = `SET NOCOUNT ON ${loadedQuery}`;
from node-sqlserver-v8.
@NoelAbrahams I don't think that would work when loadedQuery is actually a call to a stored procedure.
For now I'm solving this by using the more
flag (which doesn't seem to be documented) :
let q = conn.query(loadedQuery, (err, res, more) => {
results = res;
if (more === false) {
console.log(`Final result from query: ${JSON.stringify(results)}`)
}
});
from node-sqlserver-v8.
Actually it should work for stored procedures:
CREATE PROC dbo.foo
AS
DECLARE @v1 table(id int)
DELETE @v1
DELETE @v1
GO
SET NOCOUNT OFF
EXEC dbo.foo
GO
SET NOCOUNT ON
EXEC dbo.foo
GO
DROP PROC dbo.foo
from node-sqlserver-v8.
@NoelAbrahams Yes, but not if part of the stored proc sets NOCOUNT OFF...I don't have any control over how the stored procs were set up, so I can't guarantee that isn't the case.
from node-sqlserver-v8.
@jdpearce, I see what you mean - although it is very unusual to set no-count to off. (You could do a find and replace of NOCOUNT in your stored procedure string, but that's probably going into hack territory.)
The reason I suggested the workaround is because the more
flag is normally used to process a stored procedure that returns multiple result sets, e.g.
CREATE PROC dbo.foo
AS
SELECT v = 'result one'
SELECT v = 'result two'
from node-sqlserver-v8.
@NoelAbrahams Unfortunately all I have to work with is something that often looks like exec myschema.MyStoredProc @thing = <value>, @thing2 = <value2>...
It's not something I can hack easily, or even tell the library it's a stored proc, because I don't want to get into parsing that string for the params.
So, I can either stick to using the more flag, which works for now and probably won't change, or I can use the "done"/"completed" event incorrectly, i.e. wait for the event and then assume the next result is the last one. That the latter might change seems more likely to me.
from node-sqlserver-v8.
an interesting discussion. I guess it boils down to should a change be made to the event ordering, specifically should done actually only fire at the end or should we leave things as they are and add documentation around the more flag explaining how it could be used.
Let me know what you think is the best option given where things stand.
thanks for raising the issue, and for the ensuing discussion.
from node-sqlserver-v8.
You're welcome. ๐ค
I'd suggest documentation around the "more" flag either way.
If the event ordering is simply inherited from the original project and not an artefact of the underlying protocol, then I'd suggest that the ordering should be changed such that "done" and "completed" both fire after results are received. Documentation should be added to indicate this.
(small aside - what's the difference between "done" and "complete"?)
However, if the event ordering is actually an artefact of the underlying protocol, then simply add documentation about the expected ordering of events.
from node-sqlserver-v8.
This issue is resolved in latest version I will hence close. Please let me know if there are anymore problems
from node-sqlserver-v8.
Related Issues (20)
- Why are database field names garbled when using Chinese fields๏ผ HOT 3
- msnodesqlv8 can't find sqltypes.h HOT 2
- install msnodesqlv8 through npm failed HOT 2
- Keep saying Module not found of sqlserverv8 HOT 6
- Question: Using prepared query with Pool
- unable to build on CentOS7 HOT 3
- Prebuilt binaries for Node 20 / alpine HOT 3
- Cannot use without 'require'? HOT 1
- Module not found: Can't resolve '../build/Release/sqlserverv8' HOT 10
- Module did not self-register: sqlserverv8.node HOT 7
- npm install --save msnodesqlv8 fails MSBuild.exe failed with exit code: 1 HOT 5
- import { SqlClient } from "msnodesqlv8/types"; Cannot find module 'msnodesqlv8/types' or its corresponding type declarations HOT 1
- Unable to initialize msnodesql during Hot Module Reload (HMR) HOT 2
- Security vulnerability detected in latest HOT 1
- uncaughtException: Cannot read properties of null (reading 'query') HOT 3
- `ConcreteColumnType.parseSS` method tampers with plain date strings HOT 3
- Cannot find module '../build/Release/sqlserverv8.node' - Windows 10 / node.js v20.11.0/v21.6.1 HOT 1
- npm install results in LNK1127: library is corrupt HOT 1
- Uncaught Exception: static Sybase = new ServerDialect("Sybase")
- Cannot find module 'msnodesqlv8/types' or its corresponding type declarations. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-sqlserver-v8.