Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> database design - bind variable query
Hello, I'd appreciate the any comments on an approach I'm considering
to enhance database information retrieval and general access
efficiency.
I have a call-centre application that has literally hundreds of simple SQL statements, all almost identical, that query an Oracle (v8.17) database on NT & Win2K servers from about 70 clients. The database servers thrash during working hours & the users suffer with significant dataretrieval delays.
All the SQL queries are simple, typified by the three examples below, and the queries generated ad-hoc by the client code.
So, as you have no doubt guess I've decided to use bind variables and expect to hopefully improve database caching on the server with knock-on speed improvements client side.
I originally thought I should create many different PL/SQL stored functions, each with a different number of bind variables, for each of the queries with one set of values (query 1 above), for two sets of values (query 2 above), for ...., for 4 sets of values (query 3 above) etc. But where I need advice is on whether there a better way of approaching the problem because I'm doubting that dozens (the real app has more than 4 pairs as shown in 3. above) of stored functions with bind variables would be much better. I think there might be and my current line of thinking is that I should create **one** stored function with 4 parameters pairs and when I need to perform a query with less than 4 parameters I just duplicate the input variable values.
For example, assuming the table created using [CREATE TABLE tblTest(datatype1 VARCHAR2(1), datavalue1 NUMBER)]
--Something like this would be my stored function
CREATE OR REPLACE FUNCTION testFunction(type1 VARCHAR2, value1 NUMBER,
type2 VARCHAR2, value2 NUMBER, type3 VARCHAR2, value3 NUMBER, type4
VARCHAR2, value4 NUMBER) RETURN NUMBER AS
xcount NUMBER;
BEGIN
SELECT COUNT(*)
INTO xcount
FROM tblData
WHERE (datatype=type1 AND datavalue=value1) OR (datatype=type2 AND datavalue=value2) OR (datatype=type3 AND datavalue=value3) OR (datatype=type4 AND datavalue=value4);RETURN xcount;
A few relevant facts not in the mesage body above
Many thanks & I hope to receive a comment or two.
Best regards
Jeff
Received on Sat Aug 24 2002 - 15:47:18 CDT
![]() |
![]() |