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

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to get count using OCI?

Re: How to get count using OCI?

From: Tee Parham <tparham_at___qmsoft.com>
Date: Thu, 15 Jul 1999 08:56:42 -0600
Message-ID: <378DF6AA.6BF856D0@__qmsoft.com>

I figured it out-- since this is probably a common mistake not limited to getting counts, but anything via OCI, I'll share:

I kept getting an unhandled exception error when I did the ofetch. The problem was with the 3rd parameter of the odefin() function, [ ub1 *buf ] , which is the pointer to the defined variable.

My call looked like this:

long Count;
odefin(&cda, 1, (ub1*) Count, ....)

when it should be

odefin(&cda, 1, (ub1*) &Count, ....)

So make sure you pass in the address of your defined variable, not its value. Note that the odefin() statement executes without an error, as does the subsequent oexec(). You will only see an error when you get to the ofetch(). Another obvious error (after the fact) that is hard to discover in OCI.

-tee

dgallardo_at_my-deja.com wrote:

> What are you actually passing for the type when you do the define? You
> say you tried numeric, float and character, but what you mean by that.
> You need to pass OCI the external type you, not the Oracle native type,
> & OCI will do the appopriate conversion.
>
> - D
>
> In article <378B8309.32CC1BFD@__qmsoft.com>,
> Tee Parham <tparham@__qmsoft.com> wrote:
> > I am using OCI 7 on a 7.3.4 server. I can't figure out the best way
> to
> > simply get a count of the number of rows in a table-- all I want to do
> > is duplicate the "select count(*) from table_x" sql string.
> >
> > What I am currently doing looks like this:
> >
> > 1. Parse the SQL statement "select count(*) from table_x"
> > 2. Define an output variable by position (1). I have tried numeric,
> > float, & character.
> > 3. Execute
> > 4. Fetch 1 row
> >
> > All of this works without an error, but the output variable I have
> > defined does not contain the correct data-- it looks like the first 4
> > bytes are '' and the rest contain junk. It looks like the rpc of the
> > cursor is 1, so I would think the fetch worked.
> >
> > What data type should I use for the define variable? Any other ideas?
> >
> > -tee
> >
> > <<<remove the underscores (_) to reply to my email address>>>
> >
> >
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
Received on Thu Jul 15 1999 - 09:56:42 CDT

Original text of this message

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