Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Cursor with variable database link

Re: Cursor with variable database link

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: Wed, 08 Mar 2000 12:59:24 GMT
Message-ID: <8a5irb$fmn$1@nnrp1.deja.com>


In article <38C630D0.2FD0302_at_post.ch>,
  Braendle Pascal <braendlepa_at_post.ch> wrote:
> I'm trying to make a cursor using a database link as a variable.
>
> example:
> cursor c_emp is
> select * from emp_at_V_NODE;
>
> how can I do this?
>
> -- Pascal Braendle
>
>

In 8.0 and before you cannot use a 'cursor' but you can use the dbms_sql package to dynamically execute a query and get the results. You'll not be using a plsql cursor but rather an API to prepare, execute, fetch and get the columns back.

In Oracle8i, release 8.1 it would look like:

declare

   type rc is ref cursor;
   c rc;
begin

   open c for 'select * from t@' || v_node;

   loop

      fetch c into ...
      exit when c%notfound;

   end loop;
   close c;
end;

--

Thomas Kyte                              tkyte_at_us.oracle.com
Oracle Service Industries
http://osi.oracle.com/~tkyte/index.html --
Opinions are mine and do not necessarily reflect those of Oracle Corp

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Wed Mar 08 2000 - 06:59:24 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US