Home » SQL & PL/SQL » SQL & PL/SQL » boolean value to string
boolean value to string [message #394747] Mon, 30 March 2009 02:04 Go to next message
bananaman
Messages: 71
Registered: March 2009
Member
hi.. i'm trying to view the output of the value of a variable of type boolean using dbms_output.put_line syntax but i'm getting the error: wrong number or types of arguments in call 'PUT_LINE'..below is my sample code..

---===start===---
declare
total_sales number :=5;
no_revenue boolean;
begin
case
when total_sales <= 0 then no_revenue := true;
else no_revenue := false;
end case;
dbms_output.put_line(no_revenue);
end;
---===end===---

does this mean that the value of a boolean variable cannot be printed using dbms_output.put_line()? is there a way for me to output the value (true, false, null) of the variable of type boolean? or some sort of function to convert that value to string?
Re: boolean value to string [message #394748 is a reply to message #394747] Mon, 30 March 2009 02:18 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
dbms_output.put_line has indeed a string as parameter, not a boolean.
You need to convert the boolean to a string. Use case or decode to do the conversion.

[Edit:]
By the way, your code snippet seems a bit "off" to me. You used case here, where my gut feeling says you should use an IF-THEN-ELSE structure. Case is, in my opinion, more appropriate to use on the right-hand side of an equation.

[Updated on: Mon, 30 March 2009 02:20]

Report message to a moderator

Re: boolean value to string [message #394749 is a reply to message #394747] Mon, 30 March 2009 02:18 Go to previous messageGo to next message
bonker
Messages: 402
Registered: July 2005
Senior Member
How about like this?


if no_revenue then

 dbms_output.put_line('True'); 

else

 dbms_output.put_line('False'); 

end if;

Re: boolean value to string [message #394763 is a reply to message #394747] Mon, 30 March 2009 04:08 Go to previous message
bananaman
Messages: 71
Registered: March 2009
Member
actually the code i posted was just truncated so it's a little off to see such code in this case..thanks for the reply and comments for improvement!
Previous Topic: how to specify dynamic cursorname in FETCH INTO statement
Next Topic: Updating status
Goto Forum:
  


Current Time: Tue Dec 06 04:16:15 CST 2016

Total time taken to generate the page: 0.05389 seconds