Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Patience for a Oracle Noobie

Question posted by: Chad (Guest) on June 27th, 2008 07:04 PM
Hi, I am a SQL Server programmer using Oracle for the first time.

In our .NET client apps which use a SQL Server back end, we would use Stored
Procedure exclusively for all database access for increased security as well
as the pre-compiled advantage.

To minimize trips to the db server, we would often call SPs that return more
than one recordset. For example:

CREATE Stored Procedure HelloWorld As
BEGIN
SELECT * FROM HELLO
SELECT * FROM WORLD
END

Using ADO.NET, the results would be returned as 2 tables within a dataset
object.

We are using Oracle 10g with version 10.2 ODP.NET (data provider) on the
client. Is there a *PRODUCTION* version of software available which allows
me to do this simple task?

If Multiple returned Recordsets are not an option in Oracle SPs, can someone
please show me the latest and greatest (excluding beta software) for writing
a baby Oracle SP to return a query result for use by a client app? I am
found one example that utilizes TYPEs and CURSORs and it looks ugly as hell
and surprisingly complicated for what it is doing and involves looping
through a cursor and populating what looks like an array of TYPES which are
defined as output params. Please tell me that there is a better way of doing
this in Oracle.

We could construct the query as a string on the client but I would really
like to put the DB access in the database as compiled queries.

It would be great if someone could write the Oracle equivalent of the 5 line
SQL Server proc above for me, it would help a lot. If two returned queries
is too much for it, a one query example would still be useful.

Thanks


Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Jim Kennedy's Avatar
Jim Kennedy
Guest
n/a Posts
June 27th, 2008
07:04 PM
#2

Re: Patience for a Oracle Noobie

"Chad" <chaddokmanovich@comcast.netnetwrote in message
news:NcCdnYMOhc36x_jZ4p2dnA@comcast.com...
Quote:
Originally Posted by
Hi, I am a SQL Server programmer using Oracle for the first time.
>
In our .NET client apps which use a SQL Server back end, we would use

Stored
Quote:
Originally Posted by
Procedure exclusively for all database access for increased security as

well
Quote:
Originally Posted by
as the pre-compiled advantage.
>
To minimize trips to the db server, we would often call SPs that return

more
Quote:
Originally Posted by
than one recordset. For example:
>
CREATE Stored Procedure HelloWorld As
BEGIN
SELECT * FROM HELLO
SELECT * FROM WORLD
END
>
Using ADO.NET, the results would be returned as 2 tables within a dataset
object.
>
We are using Oracle 10g with version 10.2 ODP.NET (data provider) on the
client. Is there a *PRODUCTION* version of software available which allows
me to do this simple task?
>
If Multiple returned Recordsets are not an option in Oracle SPs, can

someone
Quote:
Originally Posted by
please show me the latest and greatest (excluding beta software) for

writing
Quote:
Originally Posted by
a baby Oracle SP to return a query result for use by a client app? I am
found one example that utilizes TYPEs and CURSORs and it looks ugly as

hell
Quote:
Originally Posted by
and surprisingly complicated for what it is doing and involves looping
through a cursor and populating what looks like an array of TYPES which

are
Quote:
Originally Posted by
defined as output params. Please tell me that there is a better way of

doing
Quote:
Originally Posted by
this in Oracle.
>
We could construct the query as a string on the client but I would really
like to put the DB access in the database as compiled queries.
>
It would be great if someone could write the Oracle equivalent of the 5

line
Quote:
Originally Posted by
SQL Server proc above for me, it would help a lot. If two returned queries
is too much for it, a one query example would still be useful.
>
Thanks
>
>


Hi,
Oracle!=SQLServer. They are two very different products. In Oracle you
don't have to use a stored procedure to get the advantage of "compiled" SQL.
(the explain plan) You do have to use bind variables and that is a good
practice in any RDBMs to get reuse of the execution plan.

That said it is a good idea to use stored procedures for what you are trying
to do. In your case you can use ref cursors as out parameters. You should
also use packages. asktom.oracle.com has some great examples:
http://asktom.oracle.com/pls/ask/f?...:10369303150185

The select statement gets returned into a ref cursor. If you want to return
two sets then return each one into a ref cursor. (thus you would have 2 out
parameters.)

Don't construct a string on the client even with stored procedures. Use
bind variables and call the stored procedures with bind variables. You will
get better scaling and better performance.
Jim



 
Not the answer you were looking for? Post your question . . .
182,494 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors