Question

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:

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.

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.

Thanks everyone.

Was it helpful?

Solution

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

This is 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..

and... Stored Procedures in PL/SQL

OTHER TIPS

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

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

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

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 procedures that refer to shared libraries in the operating system.

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.

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:

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top