Welcome to dbFreaks.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

Bind Variables ADO - Oracle

 
   Database Help (Home) -> Visual Basic -> ADO RSS
Next:  PHP and Threading - is it possible?  
Author Message
kp

External


Since: Feb 08, 2005
Posts: 2



(Msg. 1) Posted: Tue Feb 08, 2005 4:40 pm
Post subject: Bind Variables ADO - Oracle
Archived from groups: microsoft>public>vb>database>ado (more info?)

Hello,

I am trying to call a stored procedure in Oracle from my Visual Basic code.
I am using MS ADO 2.7 library to do this. Everytime I call the stored
procedure it creates a new entry for the SP in the global sql area as if it
is not using bind variables to call the SP. This only happens with numeric
type (NUMBER) of SQL parameters. This in turns tries to fill up the DB
shared pool very soon. Has anyone come across this behaviour while working
with ADO? I have tried this with both Oracle 8i and 9i, same results. any
help would be appreciated.

Thanks,
kp


Below is the code snippet:

Dim strConnect As String:
strConnect = GetConnectString(strDataSource)
Set oCon = getNewConnection(strConnect)

'Prepare the command object ..........................
Set oCmd = New ADODB.Command
With oCmd
.CommandText = "TEST_BINDVARIABLE"
.CommandType = adCmdStoredProc
Set .ActiveConnection = oCon
End With

'Init the IN and INOUT Params ........................
oCmd.Parameters.Refresh

For Each oParam In oCmd.Parameters
If (oParam.Direction = adParamInput) _
Or (oParam.Direction = adParamInputOutput) Then
oParam.Value = arrParamValues(iParamCounter)
End If
Next oParam

'Execute the SP ......................................
oCmd.Execute



Result:

SQL>select sql_text from v$sql where sql_text like 'begin TEST%';
SQL_TEXT
--------------------------------------------------
begin TEST_BINDVARIABLE(378,182,:V00003); end;
begin TEST_BINDVARIABLE(678,882,:V00003); end;
begin TEST_BINDVARIABLE(1,2,:V00003); end;
begin TEST_BINDVARIABLE(:V00001,:V00002,:V00003); end;

 >> Stay informed about: Bind Variables ADO - Oracle 
Back to top
Login to vote
Kevin Yu MSFT

External


Since: Nov 20, 2003
Posts: 67



(Msg. 2) Posted: Thu Feb 10, 2005 3:40 am
Post subject: RE: Bind Variables ADO - Oracle [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi kp,

First of all, I would like to confirm my understanding of your issue. I'm
not quite sure what has occurred from your description. Could you let me
know what kind of entry is created when the SP is called?

It would also be helpful if you could post your SP here, with both actual
results and expected results. Thank you!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

 >> Stay informed about: Bind Variables ADO - Oracle 
Back to top
Login to vote
kp

External


Since: Feb 08, 2005
Posts: 2



(Msg. 3) Posted: Thu Feb 10, 2005 12:14 pm
Post subject: Re: Bind Variables ADO - Oracle [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi Kevin,

The issue here is MSDAORA is 'not' binding parameters when calling Oracle
objects. We have experienced this using ADO 2.7, win2000 (sp4), Oracle
9.2.0.4.0. This increases the amount of parsing done and use of the global
sql area, reducing the database performance significantly.

Take a look at the following SQL:

SQL>select sql_text from v$sql where sql_text like 'begin TEST%';

and the results:

SQL_TEXT
--------------------------------------------------
begin TEST_BINDVARIABLE(378,182,:V00003); end;
begin TEST_BINDVARIABLE(678,882,:V00003); end;
begin TEST_BINDVARIABLE(1,2,:V00003); end;

Notice how the first and second input parameters has been inlined as apposed
to:

begin TEST_BINDVARIABLE(:V00001,:V00002,:V00003); end;

Obviously, this is filling up my shared_pool very fast. Now the questions
is: Why isn't everything being parameterized/binded? Also, all my procs are
exhibiting similar behavior, mostly with database variables of the type
NUMBER.
Any Ideas?

Below is the stored procedure code getting called:
create or replace procedure Test_bindvariable
( iOrderNo IN NUMBER
, iOrderItemNo IN NUMBER
, irefnumber OUT VARCHAR2
) IS
lv_count number;
BEGIN
SELECT count(*) into lv_count FROM TABLE_LJ
WHERE OrderNo = iOrderNo
AND OrderItemNo = iOrderItemNo;
irefnumber := '12345678';
END Test_bindvariable;

Hope this helps, Thanks, kp

"Kevin Yu [MSFT]" <v-kevy.RemoveThis@online.microsoft.com> wrote in message
news:vwU0PS0DFHA.2876@TK2MSFTNGXA01.phx.gbl...
 > Hi kp,
 >
 > First of all, I would like to confirm my understanding of your issue. I'm
 > not quite sure what has occurred from your description. Could you let me
 > know what kind of entry is created when the SP is called?
 >
 > It would also be helpful if you could post your SP here, with both actual
 > results and expected results. Thank you!
 >
 > Kevin Yu
 > =======
 > "This posting is provided "AS IS" with no warranties, and confers no
 > rights."
 ><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: Bind Variables ADO - Oracle 
Back to top
Login to vote
Kevin Yu MSFT

External


Since: Nov 20, 2003
Posts: 67



(Msg. 4) Posted: Mon Feb 14, 2005 7:16 am
Post subject: Re: Bind Variables ADO - Oracle [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Hi kp,

I would not recommend to use adNumeric with the MSDAORA provider because
internally doesn't bind the parameter and the Shared SQL Area becomes full
of "different" statements due to the lack of binding, which decreases the
performance of the Oracle Server.

If you are using integer values, use adInteger instead. If you are using
decimal values, use adDouble instead. These datatypes don't exhibit the
behaviour.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 >> Stay informed about: Bind Variables ADO - Oracle 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
newbie - late bind datalist doesn't populate - Private Sub cmdLookUpGroupInfo_Click() In the code below, I succesfully was able to bind and polpulate a text box with my select statement. But I need multiple table rows to be populated so I cannot use the text box. So I am trying to use the..

CommandTimeout for Oracle - My environment: WIN XP SP2, VB6 SP5, MS ADO 2.5, Oracle 9.i, MS ODBC for Oracle 2.575 I have a VB application in which I connect to a Oracle database via ADO and ODBC. I used to use the ODBC driver from Oracle, but for some reason I MUST use the ODBC..

runtime error 3021 and user permissions - I have a VB6 application that uses ADO 2.7 to access an Access2000 database. I have found on Windows XP and 2000, that if the user is not part of the administrators group, they receive: "runtime error 3021. Either BOF or EOF is true, or the current ...

updatable ado-recordset - Hi, In the code below i have an updatable ado-recordset. However it is not working how i thought it would be. Maybe someone can help me out here? The global connection (Thanks to Brendan): Option Compare Database Option Explicit Public mconn As..

ADO Connection Access Database VB - I have been accessing a database on a local drive thru an ADO connection. The following is the code that I have been using. cnCejco.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Y:\Cejco.mdb;Persist Security Info=False" The problem is n...
   Database Help (Home) -> Visual Basic -> ADO All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]