469,167 Members | 1,277 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,167 developers. It's quick & easy.

stored procedure, cusor help

sam
I'm trying to develop a stored procedure for a Crystal reports.
Here's the stored procedure. The SP uses the following package for
the REF CURSOR.

CREATE OR REPLACE PACKAGE J1R_TYPES AS
TYPE ReturnCursorType IS REF CURSOR;
END J1R_TYPES;
CREATE OR REPLACE PROCEDURE custom_report(
STARTDATE_STR_IN IN VARCHAR2 DEFAULT '01/01/2000',
STOPDATE_STR_IN IN VARCHAR2 DEFAULT '01/01/2000',
RC1 OUT J1R_TYPES.ReturnCursorType)

AS

startdate DATE;
stopdate DATE;
startdate_str VARCHAR2(10);
stopdate_str VARCHAR2(10);
SQLtext VARCHAR2(2000);
BEGIN

startdate_str := STARTDATE_STR_IN;
stopdate_str := STOPDATE_STR_IN;

startdate := TO_DATE(startdate_str, 'mm/dd/yyyy');
stopdate := TO_DATE(stopdate_str, 'mm/dd/yyyy');

SQLtext := 'select max(query_original) as query, count(q.query_pk) as
query_count, ';
SQLtext := SQLtext || 'max(url) as url, count(url) as url_count from
query q, match m, pick p, document d ';
SQLtext := SQLtext || 'where q.query_pk = m.query_pk and m.match_pk =
p.match_pk ';
SQLtext := SQLtext || 'and p.document_pk = d.document_pk and
q.query_pk <> 0 and q.create_date >= startdate ';
SQLtext := SQLtext || 'and q.create_date <= stopdate group by
query_original, url ';

OPEN RC1 FOR SQLtext;

END custom_report;
Whenever I try to run the report in Crystal, I keep getting an invalid
column commance at the 'OPEN RC1 FOR SQLTEXT' line. Can anyone tell
me how I can run the stored procedure in SqlPlus? I executed the SQL
command and I'm sure the column names are correct. Any help is
greatly appreciated. Thanks.

Sam
Jul 19 '05 #1
1 5915
sv*****@hotmail.com (sam) wrote in message news:<ce**************************@posting.google. com>...
I'm trying to develop a stored procedure for a Crystal reports.
Here's the stored procedure. The SP uses the following package for
the REF CURSOR.

CREATE OR REPLACE PACKAGE J1R_TYPES AS
TYPE ReturnCursorType IS REF CURSOR;
END J1R_TYPES;
CREATE OR REPLACE PROCEDURE custom_report(
STARTDATE_STR_IN IN VARCHAR2 DEFAULT '01/01/2000',
STOPDATE_STR_IN IN VARCHAR2 DEFAULT '01/01/2000',
RC1 OUT J1R_TYPES.ReturnCursorType)

AS

startdate DATE;
stopdate DATE;
startdate_str VARCHAR2(10);
stopdate_str VARCHAR2(10);
SQLtext VARCHAR2(2000);
BEGIN

startdate_str := STARTDATE_STR_IN;
stopdate_str := STOPDATE_STR_IN;

startdate := TO_DATE(startdate_str, 'mm/dd/yyyy');
stopdate := TO_DATE(stopdate_str, 'mm/dd/yyyy');

SQLtext := 'select max(query_original) as query, count(q.query_pk) as
query_count, ';
SQLtext := SQLtext || 'max(url) as url, count(url) as url_count from
query q, match m, pick p, document d ';
SQLtext := SQLtext || 'where q.query_pk = m.query_pk and m.match_pk =
p.match_pk ';
SQLtext := SQLtext || 'and p.document_pk = d.document_pk and
q.query_pk <> 0 and q.create_date >= startdate ';
SQLtext := SQLtext || 'and q.create_date <= stopdate group by
query_original, url ';

OPEN RC1 FOR SQLtext;

END custom_report;
Whenever I try to run the report in Crystal, I keep getting an invalid
column commance at the 'OPEN RC1 FOR SQLTEXT' line. Can anyone tell
me how I can run the stored procedure in SqlPlus? I executed the SQL
command and I'm sure the column names are correct. Any help is
greatly appreciated. Thanks.

variable cur refcursor;
begin
your procedure(p1,p2, :cur);
end;
/
print :cur

Sybrand Bakker
Senior Oracle DBA
Sam

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Michael Trosen | last post: by
3 posts views Thread by Jarrod Morrison | last post: by
reply views Thread by SOI_0152 | last post: by
1 post views Thread by sam | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.