my dog learned polymorphism*
The moose likes Oracle/OAS and the fly likes Difference Between Named Queries and Stored Procedures Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Difference Between Named Queries and Stored Procedures" Watch "Difference Between Named Queries and Stored Procedures" New topic
Author

Difference Between Named Queries and Stored Procedures

Deepika Saxena
Ranch Hand

Joined: Jul 05, 2009
Posts: 59
Hi,
Could any body please let me know the differences Between Named queries and Stored Procedures?

Thanks.
--Deepika
John Bengler
Ranch Hand

Joined: Feb 12, 2009
Posts: 133
Hi Deepika,

a Named Query is e.g. in EJB a EJBQL querywhich you give a name - and therefore resides inside the application server.

A Stored Procedure is procedure usually written in PL/SQL and resides inside the database.


John
Deepika Saxena
Ranch Hand

Joined: Jul 05, 2009
Posts: 59
Thanks John.
cant a named query use the same execution plan, like a Stored Procedure? or is it like that whenever the named query gets called, every time it will be parsed and executed?

--Deepika
John Bengler
Ranch Hand

Joined: Feb 12, 2009
Posts: 133
Yes, if a stored procedure contains a select which is the same as the one of a named query they will have the same execution plan.

But a stored procedure is more a kind of program, not just a select statement. You can write stored procedures with a lot of select statement, with one select statement or without any select.

Here you can find a short introduction to PL/SQL:

Using PL/SQL
Introduction to PL/SQL

Here is an example of a simple PL/SQL stored procedure that doesn't access any table:



Of course this doesn't make too much sense in real life.

John
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Difference Between Named Queries and Stored Procedures
 
Similar Threads
Hibernate
Spring hibernate issue
procedures vs stored procedures
diff b/w stored proc and triggers
EJB3.0 and Stored Procedure