question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not able to parametarize the limit in stored procedure

See original GitHub issue

const command = SELECT * FROM TableName ORDER BY id LIMIT ?;; await connect.promise().execute(command, [itemsPerPage]);

Hello, i am parameterize the limit VALUE and requesting the query using execute command, its throwing me error status 500, how can i achieve the same?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
sidorarescommented, Nov 27, 2022

@Himadri93 not sure if related, but have a look at https://github.com/sidorares/node-mysql2/issues/1239

TLDR: currently execute sends js numbers as DOUBLE mysql type in a PS call parameter, and mysql server > 8.0.22 does not like this combination ( LONG int in expected parameter type and DOUBLE in actual type ). One way to work around this issue right now is to convert your number parameter to a string, in that case its sent as VAR_STRING and for some reason string -> long conversion is allowed )

0reactions
sidorarescommented, Dec 4, 2022

closing as exact duplicate of #1239

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL - Limiting stored procedure input parameters
One way is to add simple validation: CREATE PROCEDURE UPDATECATS @UPDTYPE CHAR(1) AS BEGIN IF @UPDTYPE IN ('R', 'U') BEGIN -- your code...
Read more >
SP does not accept variables in LIMIT clause - MySQL Bugs
It is bug that results in a serious limitation on functionality and means that paging is not possible when using stored procedures.
Read more >
SQL Server Stored Procedure with Parameters
In this tutorial topic we will cover how to create SQL Server stored procedures that use input parameters.
Read more >
Stored Procedure With an Optional Parameter Limiting Rows ...
The "easiest" way is to parameterize input to TOP. The number I'm using is the maximum value for BIGINT. You'll probably never have...
Read more >
Limits and differences for stored procedure support
Limits. The following are limits on stored procedures in Amazon Redshift: The maximum number of stored procedures for a database is 10,000.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found