Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Defining a cursor of %TYPE rather than %ROWTYPE
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ian  
View profile  
 More options Oct 2 2012, 1:04 pm
Newsgroups: comp.databases.oracle.server
From: Ian <ian.ew...@gmail.com>
Date: Tue, 2 Oct 2012 10:04:22 -0700 (PDT)
Local: Tues, Oct 2 2012 1:04 pm
Subject: Defining a cursor of %TYPE rather than %ROWTYPE
Hello,

I have a question about cursors. I have created a simple package, package body, and procedure. Everything works fine (code to follow), my goal is to move the cursors out of the procedure and into the package body, and declare them in the package. However I have only been able to use cursors that return %ROWTYPE to declare effectively, if I use %TYPE is complains:
4/1      PL/SQL: Declaration ignored
4/32     PLS-00320: the declaration of the type of this expression is
         incomplete or malformed.
Is there a way to create a cursor that returns %TYPE, can a reference cursor be used for that?

Thanks!
code:
----------------------------------------PACKAGE HEADER-------------------------------------------

create or replace package TESTING
is
cursor their_names return customers%ROWTYPE;
procedure InvoiceCalc;
function ship_dates(a in orders.ono%TYPE)
return date;
end;
------------------------------------------PACKAGE BODY----------------------------------------------
create or replace package body TESTING
is
        cursor their_names return customers%ROWTYPE
        is
                select *
                from customers;
        function ship_dates(a in orders.ono%TYPE)
        return date
        is
                ship_date date;
        begin
                select shipped
                into ship_date
                from orders
                where orders.ono=a;
                return ship_date;
        end;
        procedure InvoiceCalc
        is
                CUST_ID customers%ROWTYPE;
                test_ono orders.ono%TYPE;
                test_ODpno odetails.pno%TYPE;
                test_ODono odetails.ono%TYPE;
                test_ODqty odetails.qty%TYPE;
                test_Ocno orders.cno%TYPE;
                test_Pprice parts.price%TYPE;
                test_Psubtotal parts.price%TYPE;
                test_TOTAL parts.price%TYPE;
                test_TEMP number;
                test_Cname customers.cname%TYPE;

        cursor their_ordernumber
        is
                select distinct orders.ono
                from customers,orders
                where customers.cno=orders.cno
                and   customers.cno=CUST_ID.cno;
        cursor their_orderdetails
        is
                select a.pno,a.qty,b.price*a.qty
                from odetails a, parts b
                where a.pno=b.pno
                and   a.ono=test_ODono;
begin
        open their_names;
        loop
                fetch their_names into CUST_ID;
                exit when their_names%NOTFOUND;
                dbms_output.put_line('Customer: '||CUST_ID.CNAME||'     ID: '||CUST_ID.CNO);
                test_TEMP:=0;
                open their_ordernumber;
                loop
                        fetch their_ordernumber into test_ODono;
                        exit when their_ordernumber%NOTFOUND;
                        dbms_output.put_line('Customer Order Number is: '||test_ODono);
                        open their_orderdetails;
                        loop
                                fetch their_orderdetails into test_ODpno,test_ODqty,test_Psubtotal;
                                exit when their_orderdetails%NOTFOUND;
                                dbms_output.put_line('Part #: '||test_ODpno||'    Quantity Ordered: '||test_ODqty||'    SubTotal: '||test_Psubtotal);
                                test_TEMP:=test_TEMP+test_Psubtotal;
                                test_TOTAL:=test_TEMP;
                        end loop;
                        if(ship_dates(test_ODono) is NOT NULL) then
                                dbms_output.put_line('SHIPPED ON: '||ship_dates(test_ODono));
                        else
                                dbms_output.put_line('SHIPPED ON: NOT YET SHIPPED');
                        end if;
                        close their_orderdetails;
                end loop;
                dbms_output.put_line('                                            Grand Total: '||test_TOTAL);
                DBMS_output.NEW_LINE;
                close their_ordernumber;
        end loop;
        close their_names;
        end InvoiceCalc;
end;


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ddf  
View profile  
 More options Oct 2 2012, 4:11 pm
Newsgroups: comp.databases.oracle.server
From: ddf <orat...@msn.com>
Date: Tue, 2 Oct 2012 13:11:19 -0700 (PDT)
Local: Tues, Oct 2 2012 4:11 pm
Subject: Re: Defining a cursor of %TYPE rather than %ROWTYPE
Comments embedded.

On Tuesday, October 2, 2012 11:04:22 AM UTC-6, Ian wrote:
> Hello,

> I have a question about cursors. I have created a simple package, package body, and procedure. Everything works fine (code to follow), my goal is to move the cursors out of the procedure and into the package body, and declare them in the package. However I have only been able to use cursors that return %ROWTYPE to declare effectively, if I use %TYPE is complains:

> 4/1      PL/SQL: Declaration ignored

> 4/32     PLS-00320: the declaration of the type of this expression is

>          incomplete or malformed.

As it should; cursors return rows of data, even those that return single columns.

> Is there a way to create a cursor that returns %TYPE, can a reference cursor be used for that?

No, that is not possible.  Not in a currently available release of Oracle.

> Thanks!

David Fitzjarrell

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mladen Gogala  
View profile  
 More options Oct 2 2012, 6:18 pm
Newsgroups: comp.databases.oracle.server
From: Mladen Gogala <gogala.mla...@gmail.com>
Date: Tue, 2 Oct 2012 22:18:11 +0000 (UTC)
Local: Tues, Oct 2 2012 6:18 pm
Subject: Re: Defining a cursor of %TYPE rather than %ROWTYPE

On Tue, 02 Oct 2012 13:11:19 -0700, ddf wrote:
> No, that is not possible.  Not in a currently available release of
> Oracle.

Jonathan posted a teaser about partitioning in 12C. Larry said that 12C
will become available at the early January 2013. Maybe then....

--
Mladen Gogala
The Oracle Whisperer
http://mgogala.byethost5.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Ian  
View profile  
 More options Oct 3 2012, 11:46 am
Newsgroups: comp.databases.oracle.server
From: Ian <ian.ew...@gmail.com>
Date: Wed, 3 Oct 2012 08:46:39 -0700 (PDT)
Local: Wed, Oct 3 2012 11:46 am
Subject: Re: Defining a cursor of %TYPE rather than %ROWTYPE

Ahh, thank you!
Ian

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »