Microsoft
Software
Hardware
Network
Question : Get return value from SQL stored Procedure with Javascript
Hello experts.
We have a stored procedure written in SQL (MS SQL Server 2005 ):
ALTER PROCEDURE [dbo].[test_insert]
@person_nbr varchar(12) output
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SELECT @person_nbr = max(last_generated) + 1
from system_counters
where counter_type = 'person_nbr'
END
// and the javascript that reads in the SP:
var dbConn = DatabaseConnectionFactory.
createData
baseConnec
tion ('com.microsoft.sqlserver.
jdbc.SQLSe
rverDriver
','jdbc:sq
lserver://
localhost:
1433;datab
aseName=Te
st;','un',
'pw');
var result = 0;
var sql = "exec dbo.test_insert()"
logger.warn("Running query: " + sql); //changeme to info or debug once its all working
result = dbConn.executeUpdate(sql);
globalMap.put('PER_NBR', result)
dbConn.close();
return message;
----------------------
Utlimate goal is to get the value of the person_nbr variable in the SQL Stored Proc to return and store into a javascript variable. Any thoughts as to where to code goes wrong? We get an "unknown syntax" error.
Thanks in advance!
Answer : Get return value from SQL stored Procedure with Javascript
HI
Change
var sql = "exec dbo.test_insert()"
to
var sql = "exec dbo.test_insert"
Random Solutions
Globally Hide Mouse after Inactive without using constantly running Timer Interval
Mailman, the GNU Mailing List Manager - is there an interface to programmatically maintain email addrs?
added shortcut to Public Desktop but some users not getting it - Win 2008 R2 Terminal Server
backup multiple DBs in script
Auto fill user name in "Login" field
access gridview checkbox and rotate though rows to save
qmail ,mutt problem: Error sending message, child exited 127 (Exec error.).
how to truncate the transaction logs in exchange 2010 after NT backup
can#t Compile PNG Image Lib
How to increase speed of UltraVNC