| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Dynamic cursors
If your table is really like the example, the ids are sequential and the email address follows the username, then you could use something like the following:
SELECT a.field_value username, b.field_value email
  FROM mytbl a, mytbl b
 WHERE UPPER(a.field_name) = 'USERNAME'
   AND b.field_id = a.field_id + 1
/
Hope it helps.
Alton
Sam Habbab wrote:
> Hi,
>
> Is there a way to create a cursor and set the column names dynamically?
>
> Here is what I'm trying to do.
> I have the following table:
>
> field_id field_name, field_value
> ---------------------------------
> 1         username    sam
> 2         email          sam_at_sam.com
> 3         company    Sam Inc.
> 4         username    bill
> 5         email           bill_at_bill.com
> 6         company     Bill Inc
>
> P.S.: I have no control over the field_name column.
> That's why I can't change this table to:
> field_id, username, email, company, field_value
>
> I want to call a function with any of the following parameters:
> username, company, email.
> for example, call the function with username and email ==> the return
> cursor should be:
>
> username     email
> ----------------------------
> sam            sam_at_sam.com
> bill              bill_at_bill.com
>
> This means that the cursor was dynamically created with two columns:
> username and email.
>
> Is this even possible?
>
> Thanks in advance.
>
> Sam Habbab
Received on Thu Jun 01 2000 - 00:00:00 CDT
![]()  | 
![]()  |