• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference Between Named Queries and Stored Procedures

 
Deepika Saxena
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Could any body please let me know the differences Between Named queries and Stored Procedures?

Thanks.
--Deepika
 
John Bengler
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 133
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic