Database & SQL

Moderators: None (Apply to moderate this forum)
Number of threads: 1174
Number of posts: 2221

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Oracle Stored Procedure - OUT parameter Posted by sudsur on 7 Apr 2003 at 9:42 PM
Please help me .. its urgent ...

I have two procedures

procedure ShowData()
begin
getData
end

procedure getDate(isValid out boolean)
begin
isValid := true
end

I want to check for the value returned by 'getData' in the 'showData' procedure . How can i do it ? can i do it like this
if(getData := true) ...




Report
Re: Oracle Stored Procedure - OUT parameter Posted by infidel on 9 Apr 2003 at 8:06 AM
: Please help me .. its urgent ...
:
: I have two procedures
:
: procedure ShowData()
: begin
: getData
: end
:
: procedure getDate(isValid out boolean)
: begin
: isValid := true
: end
:
: I want to check for the value returned by 'getData' in the 'showData' procedure . How can i do it ? can i do it like this
: if(getData := true) ...

Stored procedures in Oracle are a lot like C functions, or even VB functions. The difference between "in" and "out" parameters is kind of like the difference between passing values by value vs. by reference.

The way you've defined your procedures, you would have to do this:

procedure ShowData is
   blnDateValid boolean;
begin
   getDate(blnDateValid);
   if blnDateValid then
      ...
   end if;
end;


See, you still have to pass in a parameter even though it is an "out" parameter. The procedure you are calling needs a variable to put that value into.

What you want is something like this:

procedure ShowData is
begin
  if DateIsValid then
     ...
  end if;
end;

function DateIsValid return boolean is
begin
  return true;
end;


Also, ":=" is the assignment operator, not the equation test. Just use "=" for testing if two values are equal. If you have a function that returns a boolean value, however, you don't need to have the "= true" test. Just name your functions appropriately and it should be obvious what you mean.


infidel

Report
Re: Oracle Stored Procedure - OUT parameter Posted by sudsur on 10 Apr 2003 at 2:58 AM
Thanks a lot for the reply :)


: : Please help me .. its urgent ...
: :
: : I have two procedures
: :
: : procedure ShowData()
: : begin
: : getData
: : end
: :
: : procedure getDate(isValid out boolean)
: : begin
: : isValid := true
: : end
: :
: : I want to check for the value returned by 'getData' in the 'showData' procedure . How can i do it ? can i do it like this
: : if(getData := true) ...
:
: Stored procedures in Oracle are a lot like C functions, or even VB functions. The difference between "in" and "out" parameters is kind of like the difference between passing values by value vs. by reference.
:
: The way you've defined your procedures, you would have to do this:
:
:
: procedure ShowData is
:    blnDateValid boolean;
: begin
:    getDate(blnDateValid);
:    if blnDateValid then
:       ...
:    end if;
: end;
: 

:
: See, you still have to pass in a parameter even though it is an "out" parameter. The procedure you are calling needs a variable to put that value into.
:
: What you want is something like this:
:
:
: procedure ShowData is
: begin
:   if DateIsValid then
:      ...
:   end if;
: end;
: 
: function DateIsValid return boolean is
: begin
:   return true;
: end;
: 

:
: Also, ":=" is the assignment operator, not the equation test. Just use "=" for testing if two values are equal. If you have a function that returns a boolean value, however, you don't need to have the "= true" test. Just name your functions appropriately and it should be obvious what you mean.
:
:
: infidel
:
:




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.