View Single Post
Join Date: Apr 2007
Posts: 37
Reputation: bondo is an unknown quantity at this point 
Solved Threads: 0
bondo's Avatar
bondo bondo is offline Offline
Light Poster

Bind Variable Not Declared??

 
0
  #1
Oct 24th, 2008
Ok, so I'm learning about procedures and functions in Oracle and I'm stuck here with my procedure. I have the function part down pretty good, but the whole returning variables with procedures through OUT mode is confusing me. My task is this: "Write a procedure that accepts a zipcode & returns the city & state for that value as well as a "status" parameter whose value 'ok' or 'nok' includes whether or not the request was satisfied."

So here is the procedure I wrote:

  1. CREATE OR REPLACE PROCEDURE getCityState
  2. (v_zipcode IN location.zipcode%TYPE,
  3. v_city OUT location.city%TYPE,
  4. v_state OUT location.state%TYPE,
  5. v_status OUT VARCHAR2)
  6. AS
  7. BEGIN
  8. SELECT city, state INTO v_city, v_state
  9. FROM location
  10. WHERE zipcode = v_zipcode;
  11. IF SQL%FOUND THEN
  12. v_status := 'ok';
  13. END IF;
  14. EXCEPTION
  15. WHEN NO_DATA_FOUND THEN
  16. IF SQL%NOTFOUND THEN
  17. v_status := 'nok';
  18. END IF;
  19. WHEN OTHERS THEN
  20. v_status := 'nok';
  21. END getCityState;

And I'm trying to call the procedure, but I don't think I'm doing it correctly and I haven't found anything that's too terribly helpful for my dilemma. Here is my calling statement:

  1. DECLARE
  2. v_city location.city%TYPE := 0;
  3. v_state location.state%TYPE := 0;
  4. v_status VARCHAR2 := 0;
  5. BEGIN
  6. getCityState(99004, :v_city, :v_state, :v_status);
  7. END;
  8. /

I continue to get several different errors depending on how I structure the statement, but with this particular structure I am getting a "Bind variable "v_status" not declared" error. Can anyone help me and tell me what I am doing wrong, or give me a link to a site or something that can explain this a bit better to me? The lame-ass text book I have is a total piece of garbage and my instructor isn't exactly the kind of fellow who is pron to helping.

Thanks in advance!!!
Reply With Quote