Crystal Reports - Oracle Stored Procedures
Crystal Reports - Oracle Stored Procedures
Overview
This article provides information for Oracle stored procedures and Crystal
Reports (CR). You will find detailed information on the following:
Contents
INTRODUCTION ............................................................................................ 2
CR VERSIONS THAT SUPPORT ORACLE STORED PROCEDURES ...................... 2
CR 9 support ................................................................................................2
CR 8.5 support .............................................................................................2
CR 8 support ................................................................................................3
CR 7 support ................................................................................................3
CR 6 support ................................................................................................4
CR 5 support ................................................................................................4
CR 4 support ................................................................................................5
REQUIREMENTS TO ACCESS ORACLE STORED PROCEDURES FROM CR.......... 5
STRONGLY BOUND REF CURSORS VS WEAKLY BOUND REF CURSORS .. 6
CREATING AN ORACLE STORED PROCEDURE ................................................ 7
Sample 1 (Use With ODBC and Native Connections in CR) .......................7
Sample 2: Weakly Bound REF CURSOR (Use With Native Connection in
CR 8.5 or Higher Only) ...............................................................................8
Sample 3: Stored Procedure Created Within A Package (Use With Native
Connection in CR 9 Only)............................................................................9
EXECUTING AN ORACLE STORED PROCEDURE IN SQL*PLUS ...................... 11
CREATING A CRYSTAL REPORT OFF AN ORACLE STORED PROCEDURE ....... 11
FINDING MORE INFORMATION .................................................................... 12
CONTACTING CRYSTAL DECISIONS FOR TECHNICAL SUPPORT .................... 12
4/6/2004 2:51 PM Copyright 2001 Crystal Decisions, Inc. All Rights Reserved. Page 1
Crystal Reports Oracle Stored Procedures and Crystal Reports
Introduction
Most versions of CR support Oracle stored procedures. This document contains
detailed information of which CR versions support Oracle stored procedures.
You will also find information such as meeting requirements when reporting
from an Oracle stored procedure in CR, creating Oracle stored procedures, and
executing Oracle stored procedures in SQL*Plus.
NOTE Oracle stored procedures will not function correctly through OLE DB.
CR 9 support
CR 9 can report off Oracle stored procedures using the following database
drivers for the specified version of Oracle:
Oracle Oracle
32-bit only Oracle 7.x Oracle 9.x
8.05 8.1.x
Native Oracle
Driver
(Crdb_oracle.dll) No No Yes Yes
CR Oracle 7
No No No No
ODBC Driver
CR Oracle 8
No Yes Yes Yes
ODBC Driver
CR 8.5 support
CR 8.5 can report off Oracle stored procedures using the following database
drivers for the specified version of Oracle:
Native Oracle
Driver
(P2sora7.dll) Yes Yes Yes
CR Oracle 7
Yes No No
ODBC Driver
4/6/2004 2:51 PM Copyright 2001 Crystal Decisions, Inc. All Rights Reserved. Page 2
Crystal Reports Oracle Stored Procedures and Crystal Reports
CR Oracle 8
No Yes Yes
ODBC Driver
NOTE Crystal Reports 8.5 is able to connect to Oracle 9i using the Oracle 9i ODBC driver
provided by Oracle. This is the only driver that is supported for a connection between
Crystal Reports 8.5 and Oracle 9i.
CR 8 support
CR 8 can report off Oracle stored procedures using the following database
drivers for the specified version of Oracle:
Native Oracle
Driver
(P2sora7.dll) Yes Yes Yes (if updated)
CR Oracle 7
Yes No No
ODBC Driver
CR Oracle 8
No Yes Yes (if updated)
ODBC Driver
http://www.crystaldecisions.com/downloads
• Cror815.zip
This file contains an updated version of the Oracle 8 database driver
(Cror815.dll) for CR, from Merant’s 3.6 driver set. This is the first version of
the Oracle 8 driver that includes support for Oracle 8i.
• CR8_746.zip
• This updated Oracle native driver (P2sora7.dll) is designed to resolve the
empty login error that occurs when attempting to log onto an Oracle server
natively with an Oracle 8i client installed.
CR 7 support
CR 7 can report off Oracle stored procedures using the following database
drivers for the specified version of Oracle:
Native Oracle
Driver
4/6/2004 2:51 PM Copyright 2001 Crystal Decisions, Inc. All Rights Reserved. Page 3
Crystal Reports Oracle Stored Procedures and Crystal Reports
CR Oracle 7
Yes No No
ODBC Driver
http://www.crystaldecisions.com/downloads
• Cror815.zip
This file contains an updated version of the Oracle 8 database driver
(Cror815.dll) for CR, from Merant’s 3.6 driver set. This is the first version of
the Oracle 8 driver that includes support for Oracle 8i.
CR 6 support
CR 6 can report off Oracle stored procedures using the following database
drivers for the specified version of Oracle:
Native Oracle
Driver
(Pdsora7.dll or
Yes Yes No
P2sora7.dll)
CR Oracle 7
No No No
ODBC Driver
CR 5 support
CR 5 can report from Oracle stored procedures using the following database
drivers for the specified version of Oracle:
Native Oracle
Driver
(Pdsora7.dll or
Yes Yes No
P2sora7.dll)
CR Oracle
No No No
ODBC Driver
4/6/2004 2:51 PM Copyright 2001 Crystal Decisions, Inc. All Rights Reserved. Page 4
Crystal Reports Oracle Stored Procedures and Crystal Reports
http://www.crystaldecisions.com/downloads
• Ociw16.zip
This .zip file should only be used for CR version 5.0.x.108, 16-bit user who are
using Oracle 7.1 and Oracle 7.2 and are looking to use our 16-bit Native Oracle
driver.
• Ora16.zip
These files enable you to install the CR 16-bit ODBC drivers for connecting to
Oracle 6. These files only apply when using CR version 5.
• Ora716.zip
These files enable you to install the CR 16-bit ODBC drivers for connecting to
Oracle 7. These files only apply when using CR version 5.
• Ora732.zip
These files enable you to install the CR 32-bit ODBC drivers for connecting to
Oracle 7. These files only apply when using CR version 5.
CR 4 support
CR 4 does not support Oracle stored procedures. Oracle stored procedures
return data through output parameters and CR 4 cannot interpret output
parameters.
1. You must create a package that defines the REF CURSOR. This REF
CURSOR must be strongly bound to a static pre-defined structure (see
Strongly Bound REF CURSORs vs Weakly Bound REF CURSORs). This
package must be created separately and before the creation of the stored
procedure.
NOTE Crystal Reports 9 native connections will support Oracle stored procedures created within
packages as well as Oracle stored procedures referencing weakly bound REF
CURSORs.
Crystal Reports 8.5 native connections will support Oracle stored procedures referencing
weakly bound REF CURSORs.
2. The procedure must have a parameter that is a REF CURSOR type. This is
because CR uses this parameter to access and define the result set that the
stored procedure returns.
4/6/2004 2:51 PM Copyright 2001 Crystal Decisions, Inc. All Rights Reserved. Page 5
Crystal Reports Oracle Stored Procedures and Crystal Reports
A strongly bound REF CURSOR is bound with the same structure that is used
by the outputted SELECT statement in the Oracle stored procedure.
4/6/2004 2:51 PM Copyright 2001 Crystal Decisions, Inc. All Rights Reserved. Page 6
Crystal Reports Oracle Stored Procedures and Crystal Reports
NOTE Crystal Reports 8.5 will support Oracle stored procedures that use a weakly bound REF
CURSOR. This is only the case for a native connection in Crystal Reports 8.5.
NOTE These stored procedures are only samples. Please refer to your Oracle documentation
for more information on creating stored procedures.
1. Create a table.
CREATE TABLE Test_Table
(ID number(5),
Firstname varchar2(30),
Lastname varchar2(30),
Birthday date);
4/6/2004 2:51 PM Copyright 2001 Crystal Decisions, Inc. All Rights Reserved. Page 7
Crystal Reports Oracle Stored Procedures and Crystal Reports
4/6/2004 2:51 PM Copyright 2001 Crystal Decisions, Inc. All Rights Reserved. Page 8
Crystal Reports Oracle Stored Procedures and Crystal Reports
1. Create a table.
CREATE TABLE Test_Table
4/6/2004 2:51 PM Copyright 2001 Crystal Decisions, Inc. All Rights Reserved. Page 9
Crystal Reports Oracle Stored Procedures and Crystal Reports
(ID number(5),
Firstname varchar2(30),
Lastname varchar2(30),
Birthday date);
4. Create the Package Body (With The Code For The Stored Procedure).
4/6/2004 2:51 PM Copyright 2001 Crystal Decisions, Inc. All Rights Reserved. Page 10
Crystal Reports Oracle Stored Procedures and Crystal Reports
END Test_Procedure;
END Test_Package;
/
SET SERVEROUTPUT ON
declare
test_cursor test_package.test_type;
resultset test_cursor%rowtype;
begin
test_procedure(test_cursor, <parameter value>);
if not test_cursor%isopen then
dbms_output.put_line('the cursor is not open');
else
dbms_output.put_line('the cursor is open');
end if;
fetch test_cursor into resultset;
while test_cursor%found loop
dbms_output.put_line(resultset.ID);
dbms_output.put_line(resultset.Firstname);
dbms_output.put_line(resultset.Lastname);
dbms_output.put_line(resultset.Birthday);
fetch test_cursor into resultset;
end loop;
end;
/
NOTE If the script is executing correctly but you do not see any results displayed to the screen,
enter SET SERVEROUTPUT ON at the SQL> prompt to display results to the screen.
4/6/2004 2:51 PM Copyright 2001 Crystal Decisions, Inc. All Rights Reserved. Page 11
Crystal Reports Oracle Stored Procedures and Crystal Reports
3. In the Database Expert dialog box, find your data source. Double-click on
the data source and you will see a Stored Procedures node. Double-click
on that and you will see the tables in the stored procedure.
4. Move the table(s) you want to report off into the Selected Tables box. If the
stored procedure has a parameter you will be prompted to enter a value at
this point.
5. Click OK to close the Enter Parameter Values dialog box, and then click
OK to close the Database Expert.
NOTE If you do not see the Stored Procedures node in the Database Expert do the following. On
the File menu, click Options. On the Database tab, select the Stored Procedures check
box.
For more information regarding the creation of Oracle Stored procedures please
refer to www.oracle.com.
http://support.crystaldecisions.com/homepage/
http://support.crystaldecisions.com/support/answers.asp
Phone Support:
4/6/2004 2:51 PM Copyright 2001 Crystal Decisions, Inc. All Rights Reserved. Page 12