• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Difference Between Named Queries and Stored Procedures

 
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
 
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!