Home » Developer & Programmer » Forms » Retrive a cursor from a package
Retrive a cursor from a package [message #173566] Tue, 23 May 2006 04:00 Go to next message
axehigh
Messages: 9
Registered: March 2006
Junior Member
Hi guys.

I need to have a dynamic sql statement in a package (not in forms because of the percentile limitation). The package will generate a sql statement with the percentile_cont keyword and forms cannot compile that.

Based on some parameters I am passing down, I need to generate the WHERE-statement and return the cursor so that I can iterate through it and populate a block.

Currently I have tried to use a weak referenced cursor, but I seem to run into problems. Constanlty getting an invalid cursor error message or invalid pointer(ORA-01001)

I am able to use the OPEN FOR statement and returning this cursor, but unfortunately this cursor is a bit too static since I need to pass some variables to the cursor.

The simplest form of my cursor is like this:
  OPEN o_cur FOR 'select 1,2,3,4 FROM tbl_ name WHERE varenr = :i' USING i_varenr;      

where i_varenr is a variable I am passing to the procedure and o_cur is the cursor name that will be passed out from the procedure.

What am I doing wrong?

[Updated on: Tue, 23 May 2006 04:04]

Report message to a moderator

Re: Retrive a cursor from a package [message #173588 is a reply to message #173566] Tue, 23 May 2006 05:10 Go to previous messageGo to next message
axehigh
Messages: 9
Registered: March 2006
Junior Member
This is basically what I would like to accomplish,

CREATE OR REPLACE PROCEDURE get_my_cursor
                        (p_column IN  <your choice>,
                         p_table IN  <your choice>,
                         p_predicate IN <your choice>,
                         p_jobid  IN  dept.jobid%TYPE,
                         p_cursor OUT SYS_REFCURSOR)

sql_stmt VARCHAR2(1000);
job_rec  dept%ROWTYPE;

BEGIN

sql_stmt := 'SELECT job_name, :c
               FROM :t
              WHERE :w > :j';

 OPEN p_cursor FOR sql_stmt
    USING p_column, p_table, p_predicate, p_jobid;

 ..
END;



This is taken from this site: http://www.freelists.org/archives/oracle-l/06-2004/msg01054.html

Now, I'd like to take the p_cursor and use this is Forms 6i. Is this possible?

thanks

[Updated on: Tue, 23 May 2006 05:11]

Report message to a moderator

Re: Retrive a cursor from a package [message #173642 is a reply to message #173566] Tue, 23 May 2006 13:05 Go to previous messageGo to next message
RJ.Zijlstra
Messages: 104
Registered: December 2005
Location: Netherlands - IJmuiden
Senior Member
Hi axehigh,

Sorry not to be able to answer you here, but the phrase in your message 'not in forms because of the percentile limitation' caught my attention.

Could you explain what is meant by this? I currently work in a shop with Forms 5 ( yes I know...), and they have a conviction set in concrete, that they must code anything in forms itself. (preferably in triggers, I suppose even program-units/libraries are more or less suspect in their eyes..). The mentioning of a thing like 'package' will freeze them up, because they heard ( and of course 'know') that ...(you fill in anything that pops up now)

Any extra reason to code as far as possible in packages will be very much appreciated bu me, therefore the question to elaborate a bit on this.

Thanks in advance,

Regards,

Rob Zijlstra
Re: Retrive a cursor from a package [message #173699 is a reply to message #173566] Wed, 24 May 2006 02:01 Go to previous message
axehigh
Messages: 9
Registered: March 2006
Junior Member
Hi Rob.

The reason for me wanting to do it in a package, check out this thread http://www.orafaq.com/forum/t/63618/83516/.

Apparently the pl/sql engine is not able to compile sql-statements with the percentile keyword. What others keyword is forms 6i not able to compile (I don't know)?

And for "why put it in packages" I have put a link to Steve Feuerstein's webpage http://www.quest-pipelines.com/pipelines/plsql/archives.htm#pp04 which will explain it alot better than what I could.

Good luck

[Updated on: Wed, 24 May 2006 02:02]

Report message to a moderator

Previous Topic: Error when I access DB objects from Form
Next Topic: default alert buttons
Goto Forum:
  


Current Time: Fri Sep 20 08:16:47 CDT 2024