Note that there are some explanatory texts on larger screens.

plurals
  1. POSQL - Using Cursor & Implement statement
    primarykey
    data
    text
    <pre><code>CREATE OR REPLACE procedure verify_employee IS Emp_name trkemployee.name#%TYPE, Emp_ID trkemployee.E#%TYPE, CURSOR c1; IS select e.e#, e.name from trkemployee e where e# IN (select e# from trkdriver intersect select e# from trkmechanic); IN (select e# from trkdriver intersect select e# from trkmechanic); BEGIN OPEN c1(); LOOP END LOOP; close c1; END; / </code></pre> <p>Above is my PL/SQL code.. what i am trying to achieve is to list all the employee who work as driver &amp; mechanic at same time..</p> <p>i execute the sql statement alone at the terminal and the output is as followed..</p> <pre><code>SQL&gt; select e.e#, e.name from trkemployee e where e# IN (select e# from trkdriver intersect select e# from trkmechanic); E# NAME ---------- -------------------------------------------------- 14 Andrew R. Smith </code></pre> <p>But i wanna do it in PL/SQL and do a DMBS_OUTPUT.PUT(result);</p> <p>I Know to check for multiple record , i need use cursor. assuming in future there will be more than 1 row return, how should i change my pl/sql and when i load procedure, terminal say got compilation error.</p> <p>Below is my 3 tables..</p> <pre><code>SQL&gt; desc trkdriver; Name Null? Type ----------------------------------------- -------- ---------------------------- E# NOT NULL NUMBER(12) L# NOT NULL NUMBER(8) STATUS NOT NULL VARCHAR2(10) SQL&gt; desc trkmechanic; Name Null? Type ----------------------------------------- -------- ---------------------------- E# NOT NULL NUMBER(12) L# NOT NULL NUMBER(8) STATUS NOT NULL VARCHAR2(10) EXPERIENCE NOT NULL VARCHAR2(10) SQL&gt; desc trkemployee; Name Null? Type ----------------------------------------- -------- ---------------------------- E# NOT NULL NUMBER(12) NAME NOT NULL VARCHAR2(50) DOB DATE ADDRESS NOT NULL VARCHAR2(300) HIREDATE NOT NULL DATE </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload