如何在SQL Developer中执行SQL Server存储过程?
我获得了一个 SQL Server 数据库的用户帐户,该帐户仅具有执行存储过程的权限。我将 JTDS SQL Server JDBC jar 文件添加到 SQL Developer 中,并将其添加为第三方 JDBC 驱动程序。我可以成功登录SQL Server数据库。我得到了运行该过程的语法:
EXEC proc_name 'paramValue1' 'paramValue2'
当我将其作为语句或脚本运行时,我收到此错误:
Error starting at line 1 in command:
EXEC proc_name 'paramValue1' 'paramValue2'
Error report:
Incorrect syntax near the keyword 'BEGIN'.
我尝试将语句包装在 BEGIN/END
中,但收到相同的错误。是否可以从 SQL Developer 调用该过程?如果是这样,我需要使用什么语法?
I've been given a user account to a SQL Server database that only has privileges to execute a stored procedure. I added the JTDS SQL Server JDBC jar file to SQL Developer and added it as a Third Party JDBC driver. I can successfully log in to the SQL Server database. I was given this syntax for running the procedure:
EXEC proc_name 'paramValue1' 'paramValue2'
When I run this as either a statement or a script, I get this error:
Error starting at line 1 in command:
EXEC proc_name 'paramValue1' 'paramValue2'
Error report:
Incorrect syntax near the keyword 'BEGIN'.
I tried wrapping the statement in BEGIN/END
, but get the same error. Is it possible to call the procedure from SQL Developer? If so, what syntax do I need to use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(12)
您不需要 EXEC 子句。只需使用
(并且您需要逗号,如误称)
You don't need EXEC clause. Simply use
(and you need commas as Misnomer mentioned)
您缺少
,
You are missing
,
你需要这样做:
You need to do this:
您需要在 paramValue1 和 paramValue2 之间添加
,
。你错过了。You need to add a
,
between the paramValue1 and paramValue2. You missed it.我知道这是旧的。但这可能对其他人有帮助。
我在BEGIN/END之间添加了SP调用功能。这是一个工作脚本。
I know this is the old one. But this may help others.
I have added SP calling function between BEGIN/END. Here is a working script.
如果存储过程的目标是在声明了 Identity 字段的表上执行
INSERT
,则应声明该字段(在本例中为@paramValue1
),然后将其传递给值 0,因为它会自动递增。If the Stored Procedure objective is to perform an
INSERT
on a table that has an Identity field declared, then the field, in this scenario@paramValue1
, should be declared and just pass the value 0, because it will be auto-increment.我们可以通过两种方式调用存储过程
CALL
数据库名称'。 '存储过程名称
(参数值);示例:- 调用
dbs_nexopay_sisd1_dec_23
。spr_v2_invoice_details_for_invoice_receipt_sub_swiss
(1, 1, 1, 1);从您的 MySQL 工作台您也可以做到这一点。
我。右键单击存储过程。
二.发送到 SQL 编辑器
三.过程调用。
There are two ways we can call stored procedure
CALL
database name'. 'stored procedure name
(parameter values);example:- CALL
dbs_nexopay_sisd1_dec_23
.spr_v2_invoice_details_for_invoice_receipt_sub_swiss
(1, 1, 1, 1);From your MySQL workbench also you can do that.
i. Right-click on stored procedure.
ii. Send to SQL editor
iii. Procedure call.
如果您只需要执行存储过程
proc_name 'paramValue1', 'paramValue2'...
同时您正在执行多个查询,例如一个选择查询和存储过程,您必须添加
从表名中选择*
EXEC proc_name paramValue1,paramValue2...
If you simply need to excute your stored procedure
proc_name 'paramValue1' , 'paramValue2'...
at the same time you are executing more than one query like one select query and stored procedure you have to add
select * from tableName
EXEC proc_name paramValue1 , paramValue2...
存储过程可以使用以下语法
BEGIN 在 sql Developer 工具中运行
程序名();
结尾;
如果有任何参数,则必须传递它。
The stored procedures can be run in sql developer tool using the below syntax
BEGIN
procedurename();
END;
If there are any parameters then it has to be passed.