Results 1 to 2 of 2

Thread: How to display boolean values in oracle pl/sql code

  1. #1
    Senior Member vijay's Avatar
    Join Date
    May 2012
    Location
    Hyderabad
    Posts
    512

    How to display boolean values in oracle pl/sql code

    I am trying to display a boolean value in oracle plsql using the dbms output package. The plsql anonymous block code is shown below:

    Code:
    declare
    a boolean := false;
    begin
    dbms_output.put_line(a);
    end;
    /
    I am getting the below error when executed this block:

    Code:
    ERROR at line 4:
    ORA-06550: line 4, column 1:
    PLS-00306: wrong number or types of arguments in call to 'PUT_LINE'
    ORA-06550: line 4, column 1:
    PL/SQL: Statement ignored
    How to display the boolean values in plsql code.

  2. #2
    Senior Member vijay's Avatar
    Join Date
    May 2012
    Location
    Hyderabad
    Posts
    512
    The dbms_output.put_line function displays only string values. If you want to display non strings, you have to convert them to string data types using the to_char function. However the to_char function does not work on boolean data types and it cant convert boolean to varchar.

    You have to use if/else or case statement to display the boolean values. Sample plsql anonymous block code is shown below:

    Code:
    declare
    a boolean := false;
    begin
    if (a)
    then
    dbms_output.put_line('true');
    else
    dbms_output.put_line('false');
    end if;
    end;
    /

Similar Threads

  1. Replies: 0
    Last Post: 12-16-2012, 01:05 AM
  2. Display multiple highest values in Oracle
    By Oracleguy in forum Oracle
    Replies: 0
    Last Post: 12-13-2012, 10:47 PM
  3. Replies: 3
    Last Post: 08-27-2012, 10:31 AM
  4. Replies: 1
    Last Post: 06-27-2012, 03:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •