Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing XML over 2000 characters long to stored procedure results in "[Microsoft][SQL Server Native Client 11.0]Invalid precision value" #24

Closed
davewthompson opened this issue Jul 26, 2016 · 3 comments

Comments

@davewthompson
Copy link

Hey there,

I have noticed that trying to pass a XML string of over 2000 characters to a stored procedure as a parameter results in SQL returning "[Microsoft][SQL Server Native Client 11.0]Invalid precision value".

I suppose it's being truncated, but I can't find a way to stop this happening?

I'm just using:

procManager.callproc('SEL_GetDataByXml', parameters, function (err, result) {

Any advice?

Thanks!

Dave

@TimelordUK
Copy link
Owner

Have you tried

sql.WLongVarChar(xml);

As the xml parameter in Param array.

Is param[0] =sql.WLongVarChar(xml);

This should force the driver to bind the string

I'm away from terminal so cannot test currently.

I'll take a look later to see if this will fix it.

Sent from my iPad

On 26 Jul 2016, at 17:57, Dave Thompson notifications@github.com wrote:

Hey there,

I have noticed that trying to pass a XML string of over 2000 characters to a stored procedure as a parameter results in SQL returning "[Microsoft][SQL Server Native Client 11.0]Invalid precision value".

I suppose it's being truncated, but I can't find a way to stop this happening?

I'm just using:

procManager.callproc('SEL_GetDataByXml', parameters, function (err, result) {

Any advice?

Thanks!

Dave


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

@TimelordUK
Copy link
Owner

function largeText() {
console.log("largeText");
var len = 2200;
var s = "A".repeat(len);
sql.open(connStr, function (err, conn) {
conn.query("declare @s NVARCHAR(MAX) = ?; select @s as s", [sql.WLongVarChar(s)], function (err, res) {
//conn.query("declare @s NVARCHAR(MAX) = ?; select @s as s", [s], function (err, res) {
assert.ifError(err);
var ss = res[0].s;
assert(ss.length == len);
});
});
}

@davewthompson
Copy link
Author

That's how I got it to work in the end - sql.WLongVarChar(s)!

Thanks very much!

Dave

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants