Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: running c++ program within database

Re: running c++ program within database

From: Spencer <spencerp_at_swbell.net>
Date: Mon, 4 Jun 2001 20:17:31 -0500
Message-ID: <WoWS6.95$j77.155794@nnrp2.sbc.net>

you didn't specifically ask the question as to why you would want to use packages...

there are several advantages to using packages vs. standalone procedures and functions. the two biggest benefits (for me) are

. recompilation of package body does not invalidate dependents   objects dependent are dependent on the package specification,   not the package body, which means the body can be modified   and recompiled, without invalidating any functions, procedures,   packages, views etc. that reference the package.

. function overloading
  the ability to have two (or more) functions with the same name,   each with its own argument list. one example of an overloaded   built-in function is TO_CHAR. one implementation accepts a   NUMBER as the first argument, the other a DATE

there are some other advantages, but the two i listed are the biggest ones for me.

as for c/c++, if you have complex logic or other requirements that are better handled in c than pl/sql, then creating external functions is the way to go. not quite the same as "running withint database", but close enough for practical purposes.

HTH "Jim Kennedy" <kennedy-family_at_home.com> wrote in message news:stAS6.104678$p33.2223837_at_news1.sttls1.wa.home.com...
> A package is a collection of (hopefully related ) stored procedures and
> functions.
> Jim
>
> <davidchantf_at_hotmail.com> wrote in message
> news:BnzS6.5806$Zy.4340832_at_newsrump.sjc.telocity.net...
> >
> > Hi,
> > I am already using Store Procedure for database query, Is package a
> > collection of SP ?
> > Is it package means more business logic in database ?
> > Thanks.
> > David
> >
> > Jim Kennedy <kennedy-family_at_home.com> wrote:
> > > Are you using host variables? ODBC doesn't support host variables
 natively.
> > > (better to use OCI or OLE objects correctly) Not using host variables
 would
> > > possibly show up as high CPU utilization on the server machine.
> > > Also you might try to do an explain plan on each type of query to see
 if
> > > there are proper indexes etc.
 

> > > Using pl/sql might be a good idea, it would mean that you are not
 dragging
> > > the information accross the network. It depends upon what you need to
 do.
> > > You would write a package and call the package from your c++ program.
 

> > > Can you give us a flow of what you are doing?
 

> > > Jim
 

> > > <davidchantf_at_hotmail.com> wrote in message
> > > news:2JOR6.1277$Zy.1232642_at_newsrump.sjc.telocity.net...
> > >> Hi,
> > >> I am using oracle ODBC 8.01.72, VC++ 6.0 on winnt 4.0. I have one
> > >> operation that needs about 20*x database access, where x can be from
 5
 to
> > >> 30.
> > >> I can set up the program and database in one computer, but still
> > >> slow. Right now I only have hundreds of records for testing, but in
> > >> production mode, it can grow to millions of records.
> > >> And the table design is complex and highly normailized.
> > >> I never try to use PL/SQL, Is it a much better choice than ODBC ? Do
 I
> > >> need to rewrite my program at all ?
> > >> Thanks.
> > >> David
> > >>
> > >> wayne <no_at_email.please.com> wrote:
> > >> >> I have a C++ program that need to make a lot of database access
 within
 one
> > >> >> operation, which is very slow. So I am wondering if I can run this
 program
> > >> >> inside database? so to reduce the number of database access, and
 increase
> > >> >> performance.
 

> > >> > First of all, you would need to access the database anyway,
 regardless
 of
> > >> > whether it's running on the database or outside.
 

> > >> > Now, as far as performance optimization, there are lots of things
 you
 could
> > >> > do: Server-side tweaks as well as client-side... you can also
 scrutinize
 the
> > >> > design of both the server and the overall process...
 

> > >> > In answer to your question, I have never seen a C++ program be part
 of
 the
> > >> > database itself. You can call out from the PL/SQL to the C++, but
 the
 C++
> > >> > would have to be an external module (and may have to have a C
 wrapper,
> > >> > possibly), as in a DLL or SO file.
 

> > >> > What would I do at this point if I were you (and I _have_ been in
 your
> > >> > situation before)? I would start with the overall design. Minor
 tweaks
 do
> > >> > not help if the underlying design is bad. I would then move on to
> > >> > optimizing the server and the client code (and what I would do
 depends
> > >> > heaviliy on what the exact tasks are and how long each takes to
 run).  

> > >> > If you describe your project more we can help more (ie. what
 operations
 are
> > >> > being dome that take a long time, how many records are we talking
 about,
> > >> > what platform you run in, whether or not you are already running
 the
 program
> > >> > on the same machine as the server, etc...).
> > >>
> > >>
> >
> >
>
>
>
Received on Mon Jun 04 2001 - 20:17:31 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US