Oracle SQL Developer 上的存储过程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1333233/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 18:52:55  来源:igfitidea点击:

Stored Procedures on Oracle SQL Developer

sqldatabaseoraclestored-proceduresoracle-sqldeveloper

提问by Alessandro

could you point me to a good place to start with Oracle stored procedures syntax/usage? I can't seem to find any good place there. I'm fairly proficient in (java, C/C++) programming and I do know enough SQL for my needs right now, but I've been suggested to use stored procedures to do my business, which is:

你能给我指出一个开始使用 Oracle 存储过程语法/用法的好地方吗?我似乎在那里找不到任何好地方。我相当精通(java,C/C++)编程,并且我现在确实了解足够的 SQL 来满足我的需要,但是有人建议我使用存储过程来做我的业务,​​即:

Take results from a query (2 columns) and insert them, row by row, in another table, along with an incrementing key whose value is taken from a third table. And of course this last value must be incremented once for every row.

从查询(2 列)中获取结果并将它们逐行插入到另一个表中,以及从第三个表中获取值的递增键。当然,最后一个值必须为每一行增加一次。

I have the query to do the first part (extract data to be inserted) and the second part (insert data into table with incrementing key, then increment key on keygenerator table), all I need now is combine both so I can batch-insert the 6000 or so rows I have.

我有查询来执行第一部分(提取要插入的数据)和第二部分(将数据插入表中并使用递增键,然后在 keygenerator 表上递增键),我现在需要的是将两者结合起来,以便我可以批量插入我有 6000 行左右。

Thanks everyone.

谢谢大家。

回答by Svetlozar Angelov

Oracle uses PL/SQL programming language for their stored procedures. Here is an info about PL/SQL in wiki

Oracle 对其存储过程使用 PL/SQL 编程语言。这是wiki 中有关 PL/SQL 的信息

Thisis a good source too.

也是一个很好的来源。

Oracles provides a lot of tools to make the programmer's life easier, but my advice is to start as simple as you can to get familiar with the language..

Oracles 提供了很多工具来让程序员的生活更轻松,但我的建议是尽可能简单地开始熟悉该语言。

and... Stored Procedures in PL/SQL

和... PL/SQL 中的存储过程

回答by Jaskirat

What you want looks pretty simple.This looks like a nice place to start.

你想要的看起来很简单。这看起来是一个不错的起点。

http://www.devshed.com/c/a/Oracle/Oracle-Stored-Procedures/

http://www.devshed.com/c/a/Oracle/Oracle-Stored-Procedures/

回答by Bhavesh Modi

As beginner, you can go through below link, it contains all basics related to procedure. link

作为初学者,您可以通过以下链接,它包含与程序相关的所有基础知识。 关联

回答by Daniela Petruzalek

Regarding stored procedures, the basic syntax is:

关于存储过程,基本语法是:

-- The REPLACE keyword is optional. Without it the CREATE statement 
-- will fail if there there is already a procedure with the same name
CREATE [OR REPLACE] PROCEDURE procedure_name AS|IS
-- Variable declarations
BEGIN
  -- Stored procedure body

-- Optional exception block
[EXCEPTION]
  -- Exception handlers
END [procedure_name];
/

-- The procedure_name after the END statement is optional, used
-- mostly for readability

The programing language is PL/SQL by default, but Oracle also allows you to write stored procedures in java. You can also call external C code (or any language that can generate C linkage object libraries) by creating external proceduresthat refer to shared libraries in the operating system.

编程语言默认为 PL/SQL,但 Oracle 也允许您用 java 编写存储过程。您还可以通过创建引用操作系统中共享库的外部过程来调用外部 C 代码(或任何可以生成 C 链接对象库的语言)。

PL/SQL resembles pascal and Delphi. It is based in the Ada language that is based in pascal. PL stands for "procedural language", but it also allows the object oriented programming paradigm.

PL/SQL 类似于 pascal 和 Delphi。它基于基于 pascal 的 Ada 语言。PL 代表“过程语言”,但它也允许面向对象的编程范式。

For a more complete syntax reference, I'm particularly fond of the PSOUG (http://psoug.org) reference library for syntax and usage tips. Here are two links good for starters:

对于更完整的语法参考,我特别喜欢 PSOUG ( http://psoug.org) 参考库中的语法和使用技巧。这里有两个适合初学者的链接:

http://psoug.org/definition/procedure.htm
http://psoug.org/reference/procedures.html

http://psoug.org/definition/procedure.htm
http://psoug.org/reference/procedures.html