Bind Variable Not Declared??

Reply

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 Quick reply to this message  
Join Date: Oct 2006
Posts: 48
Reputation: yilmazhuseyin is an unknown quantity at this point 
Solved Threads: 5
yilmazhuseyin's Avatar
yilmazhuseyin yilmazhuseyin is offline Offline
Light Poster

Re: Bind Variable Not Declared??

 
1
  #2
Oct 24th, 2008
Hi! you are calling local variable the way you should call bind variables. so oracle things your variables are bind variables. you should not use ':' sign before variable names. anyway you should write it as

declare
v_city location.city%type := 0;
v_state location.state%type := 0;
v_status varchar2 := 0;
begin
getCityState(99004, v_city, v_state, v_status);
end;
/
Reply With Quote Quick reply to this message  
Join Date: Feb 2007
Posts: 2,068
Reputation: debasisdas will become famous soon enough debasisdas will become famous soon enough 
Solved Threads: 123
debasisdas's Avatar
debasisdas debasisdas is offline Offline
Postaholic

Re: Bind Variable Not Declared??

 
0
  #3
Oct 24th, 2008
you need not use bind variables for that. just try to use as suggested in the previous post.
Share your Knowledge.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Oracle Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC