• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

problem with my procedure

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written a procedure and I'm trying to run it in my SQL plus console, which is not working. I don't understand, could anyone please tell me what I'm doing wrong. I have attached my code below:
 
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Bobby,
Try this procedure in scott/tiger schema:
====================================
CREATE OR REPLACE PROCEDURE SHOW_EMPLOYEES
AS
V_RECORD EMP%ROWTYPE;
BEGIN
SELECT *
INTO V_RECORD
FROM EMP
WHERE EMPNO=7934;
END;
/
====================================
Points to be considered
1. Use of INTO clause while using SELECT as record is being fethced and assigning it to a record.
2. Only ONE record can be fetched through select/into statement in a procedure (use of where clause).
3. First you have to declare a variable (here I have declare a variable of record type as the whole record is in question).
HIH,
[ April 09, 2002: Message edited by: Muhammad Farooq ]
 
bobby, morkos
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried it and it gives me a compilation error. Could you please tell me what I did wrong. Thanks.
 
Muhammad Farooq
Ranch Hand
Posts: 356
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Line 3, change "emp" with "customers"
 
bobby, morkos
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot, it works. How do you call that procedure from a java program. I have something like show below, please tell me if I'm doing it right. Thanks.

Originally posted by Muhammad Farooq:
Line 3, change "emp" with "customers"

reply
    Bookmark Topic Watch Topic
  • New Topic