Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Build and execute stored procedure 'on the fly'

Reply
Thread Tools

Build and execute stored procedure 'on the fly'

 
 
iksrazal@terra.com.br
Guest
Posts: n/a
 
      10-17-2005
Hi all,

I've been requested to build a String that represents a stored
procedure (SP) dynamically at runtime, and afterwards execute it. The
DB is beta mysql5. My questions are:

1) Is it mandatory that in JDBC a SP be called by a CallableStatement?
For example, a SELECT statement can be built and executed at runtime,
could this also be done for a SP?
2) Does a SP need to be installed into the DB before being invoked?

I ask because I think I my need to install the SP at runtime, after
being built, and then call it via a CallableStatement. This would
require, I believe, redirecting the SP to a SQL client shell via Java
and stdin, and afterwards, invoke the CallableStatement.

Any ideas?
iksrazal

 
Reply With Quote
 
 
 
 
Bjorn Abelli
Guest
Posts: n/a
 
      10-17-2005

<> wrote...

> 1) Is it mandatory that in JDBC a SP be called by a CallableStatement?


Yes, although "some" JDBC-drivers could provide other means...


> For example, a SELECT statement can be built and
> executed at runtime, could this also be done for a SP?


That depends on the actual JDBC-driver, but I would say that it should work
in most cases.

But the creation of an SP is "just" a statement (CREATE PROCEDURE...), so
you should use a simple "execute(...)" on a simple "Statement" for that.

> 2) Does a SP need to be installed into the DB before being invoked?


By its nature an SP is an element in the database, so I can't see how it
would be possible to call it otherwise... ?

There's a reason why it's named *stored* procedures...


// Bjorn A


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'Procedure or function <stored procedure name> has too many arguments specified',,,ARGH! Mike P ASP .Net 0 06-19-2006 01:19 PM
Stored Procedure vs direct execute SQL =?Utf-8?B?SklNLkgu?= ASP .Net 7 05-27-2005 10:12 PM
Help with Code to Execute a Stored Procedure Jeff Thur ASP .Net 2 02-07-2005 08:58 PM
SWsoft Acronis Disk Director Suite 9.0 Build 508, Acronis OS Selector 8.0 Build 917, Acronis Partition Expert 2003 Build 292, Acronis Power Utilities 2004 Build 502, F-SECURE.ANTI vIRUS.PROXY v1.10.17.WINALL, F-SECURE.ANTI vIRUS v5.50.10260 for CITRI vvcd Computer Support 0 09-25-2004 01:38 AM
How can I execute a stored procedure in .net? FireListen ASP .Net 1 06-27-2003 01:39 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57