Varchar2 boolean expresion to boolean

Hi,
I have a boolean expresion that looks like "TRUE AND (TRUE OR FALSE)" and is kept in a VARCHAR2 SQL type. How can I evaluate this string to the boolean value using PL/SQL? Is there any function, custom package that do this conversion?
Thanks,
Darius

this example might be of some help. since there is no direct boolean dataype in oracle table, we can use the varchar2 datatype restricting the value to 0 and 1. the 1 represents the TRUE while 0 represent the FALSE.
SQL> create table my_demo
  2  (acct_no number,
  3   flag    varchar2(20) check (flag in (0,1)));
Table created.
SQL> insert into my_demo values(525, '1');
1 row created.
SQL> insert into my_demo values(526, '0');
1 row created.
SQL> commit;
Commit complete.
SQL> select acct_no, decode(flag,1,'TRUE',0,'FALSE') from my_demo;
   ACCT_NO DECOD
       525 TRUE
       526 FALSE
SQL>

Similar Messages

  • How to pass multiple parameters while calling a pl/sql procedure based serv

    Hi,
    I have a pl/sql procedure based service that needs to be invoked from the bpel console for testing purpose. This procedure accepts multiple input values which are of varchar2,boolean and datetime data types. How can I get the bpel console to throw a UI where I can enter these values --in other words where(which file and where) can I specify that these are the input parameters that need to be entered along with their types.
    Thanks for yr help!

    Change the payload of the request 'Process WSDL' message type. Change the element of the payload for the RequestMessage to be 'InputParameters' from the XSD generated by the DB Adapter wizard.
    Edit the payload (Element) - Choose 'Project Schema Files'. Select 'InputParameters' from the XSD.
    You can also change the ResponseMessage by doing the same thing, except that you select 'OutputParameters' from the XSD.

  • Problem with getAttribute() for Booleans

    Hi
    We have an Application which has undergone all the migration path from JDeveloper 9i beta up to JDeveloper 9.0.5.2 (in several steps certainly :-) ) . Now we try do the next step: we want to upgrade from 9.0.5.2 to 10.1.3.
    But there is a problem with Boolean attributes:
    Since there were some problems with Booleans in elder versions of JDeveloper all our Booleans are stored in Attributes of type VARCHAR2(1) ("1" is TRUE, "0" is FALSE). This worked well since 9.0.5.2. But now in JDeveloper 10.1.3 all Boolean Attributes return FALSE, no matter of the content of the database. Since we do not want to convert our data in the database I am now looking for a way, how I can enable this Application to correctly read Booleans from VARCHAR2(1) .
    I've already found some classes like "TypeFactory" and "TypeMapEntries", and I've found the Property "jbo.TypeMapEntries". But I've found no clue, how to use them for my problem.
    Can anyone give me a hint?
    Thanks in advance
    Frank Brandstetter

    You have several problems:
    1. On-Insert will ONLY run if you have created a new record in a base-table block. If you haven't done that, then the POST command will not cause it to run.
    2. Select for update without a "no wait" will lock records for the first form, but when the second form tries this, it will hit the ORA-00054 exception, and will NOT wait. The only way you could make it wait is to issue an UPDATE sql command, which is not such a good way to go.
    All POST does is issues SQL insert or update commands for any changes the user has made to records in a form's base-table blocks, without following with a Commit command.
    Also understand that Commit is the same as Commit_Form, and Rollback is the same as Clear_Form. You should read up on these in the Forms help topics.

  • Passing of BOOLEAN parameters to PL/SQL stored procedures

    Hi ,
    How i can pass BOOLEAN parameter to store Procedure or do i need to pass it as Integer?
    waiting for quick reply
    Thanks in advance ,
    Pramod

    Disclaimer: I work for the company that makes the product mentioned below.
    Procedures that take boolean parameters can be called using JDBC without having to modify them or write additional 'wrapper' procedures. The secret is to write an anonymous block that accepts a numeric parameter and sets a boolean PL/SQL variable with it before calling the procedure.
    [url http://www.orindasoft.com/]OrindaBuild is a utilty made by my employer that does this along with a bunch of other stuff. If you open
    [url http://www.orindasoft.com/public/Java2HTML/com/orindasoft/demo/generated/plsql/simpleExamplesDirectFlightAvailable.java.html]this URL and scroll to the bottom you'll see an example of this technique in use for a BOOLEAN OUT parameter. The relevent code is:
    public String getProcCallStatement()                                            
    236    {                                                             
    237    return("DECLARE \n"
    238          +"/* Generated By OrindaBuild 4.0.1919 */ \n"
    239          +"/* Which can be obtained at www.orindasoft.com */ \n"
    240          +"p_fromcity VARCHAR2(32767) := ?; \n"
    241          +"p_tocity VARCHAR2(32767) := ?; \n"
    242          +"p_direct BOOLEAN := null; \n"
    243          +"p_direct_SN SIGNTYPE := null; \n"
    244          +"BEGIN  \n"
    245          +"SIMPLE_EXAMPLES.DIRECT_FLIGHT_AVAILABLE(p_fromcity,p_tocity,p_direct); \n"
    246          +"  \n"
    247          +"IF p_direct IS NULL THEN  \n"
    248          +"  p_direct_SN := 0;  \n"
    249          +"ELSIF p_direct = FALSE THEN  \n"
    250          +"  p_direct_SN := -1;  \n"
    251          +"ELSIF p_direct = TRUE THEN  \n"
    252          +"  p_direct_SN := 1;  \n"
    253          +"END IF;  \n"
    254          +"? := p_direct_SN; \n"
    255          +"END; ");
    256    }     'p_direct' is a boolean variable we use to capture the result of the stored procedure.
    'p_direct_SN' is a variable of SIGNTYPE, a numeric datatype that can have the values -1, 0, or 1. This makes it ideal for representing booleans. The IF statement afte the procedure call sets p_direct_SN based on the value of p_direct. The magic code is in line 254:
    ? := p_direct_sn;
    If you bind '?' as a numeric out parameter you get -1, 0 or 1 back when you run call the stored procedure.
    This technique allows you to call PL/SQL procedures that have boolean parameters without having to write additional PL/SQL code. The only drawback is that you have to work with -1,0 and 1 on the Java side.
    David Rolfe
    Orinda Software
    Dublin, Ireland
    David Rolfe
    Dublin, Ireland

  • How to populate a static junk dimension made of N boolean flags

    Hi, we want to populate a junk dimension (a table with N boolean fields - 18 in our case).
    The records must contain all the possibile combinations of all the fields (with 18 integer fields whose value can be either 0 or 1, the number of possible combinations is 262144).
    I'm looking for suggestions on how to do this (with a single SQL statement or with a cursor inside a procedure, they are both fine).
    Thanks,
    Andrea

    You could use cross products/joins to achieve the result. Here is an example:
    SQL> WITH boolean_flags AS
      2  (
      3          SELECT  0 AS FLG FROM DUAL UNION ALL
      4          SELECT  1 AS FLG FROM DUAL
      5  )
      6  SELECT  A.FLG
      7  ,       B.FLG
      8  ,       C.FLG
      9  FROM    BOOLEAN_FLAGS   A
    10  ,       BOOLEAN_FLAGS   B
    11  ,       BOOLEAN_FLAGS   C
    12  /
           FLG        FLG        FLG
             0          0          0
             0          0          1
             0          1          0
             0          1          1
             1          0          0
             1          0          1
             1          1          0
             1          1          1If you need it to be more dynamic you can generate the SQL dynamically as shown below. This example would work for the number of columns ranging from 1-26 (I didn't do heavy testing):
    SQL> VAR c REFCURSOR;
    SQL>
    SQL> DECLARE
      2          numDimensions   NUMBER  := 3;
      3          sqlText         VARCHAR2(4000) :='WITH boolean_flags AS
      4                                          (
      5                                                  SELECT  0 AS FLG FROM DUAL UNION ALL
      6                                                  SELECT  1 AS FLG FROM DUAL
      7                                          )
      8                                          SELECT A.FLG ';
      9          sqlFromText     VARCHAR2(4000) :='FROM BOOLEAN_FLAGS    A';
    10  BEGIN
    11          FOR i IN 2..numDimensions
    12          LOOP
    13                  sqlText := sqlText || ', ' || CHR(64+i) || '.FLG ';
    14
    15                  sqlFromText := sqlFromText || ', BOOLEAN_FLAGS ' || CHR(64+i);
    16          END LOOP;
    17
    18          OPEN :c FOR sqlText || sqlFromText;
    19  END;
    20  /
    PL/SQL procedure successfully completed.
    SQL> PRINT C
           FLG        FLG        FLG
             0          0          0
             0          0          1
             0          1          0
             0          1          1
             1          0          0
             1          0          1
             1          1          0
             1          1          1
    8 rows selected.Edited by: Centinul on Dec 28, 2009 9:35 AM

  • File and boolean attribute on item

    Hi,
    I work with Oracle9iAS Portal PL/SQL API (9.0.2.6).
    I define an item type (CAID = 213/ ID = 37399) with several attributes. When I try to create/modify an item I have problems with boolean attributes and file attributes.
    In case of boolean attributes, I'm not able to set the value to true. I try with several values (IS_ON, True, 1) but the attribute is still set to false. Is there anything wrong with the value I assign to the attribute before creating the item ? When I try to create the item and then modifying the attribute, the value stay to false.
    For the file attributes, I use the upload_blob function inside wwsbr_api and the file appear in the wwdoc_document table. I set the file attribute value with the return value of the upload_blob function.
    When I call the add_item_post_upload, an error occurs (ORA-29532: Java call terminated by uncaught Java exception: java.lang.NullPointerException : -29532)
    Is this a bug or not ?
    Thanks Eddy.
    For help see my sample code below :
    (ID of attribute, page, region are correct. I also test each type of attribute separately)
    declare
    l_master NUMBER;
    l_store portal.wwsto_api_session;
    l_custom_attribute portal.wwsbr_type.array := portal.wwsbr_type.empty;
    l_custom_attribute_id portal.wwsbr_type.array := portal.wwsbr_type.empty;
    l_custom_attribute_caid portal.wwsbr_type.array := portal.wwsbr_type.empty;
    l_custom_attribute_data_type portal.wwsbr_type.array := portal.wwsbr_type.empty;
    l_str VARCHAR2(100);
    l_Blob BLOB;
    l_filename VARCHAR2(100);
    begin
    -- set context
    portal.wwctx_api.SET_CONTEXT('ctx','ctx01','');
    -- load a session (Allow use of set_Attribute ...)
    DBMS_OUTPUT.put_line('Load session');
    l_store := portal.wwsto_api_session.load_session('ctx','ctx');
    -- set parameters
    -- item type = 'Item_ed'
    l_store.set_attribute('ITEM_TYPE', 37399); -- Item type id
    l_store.set_attribute('ITEM_CAID', 213); -- Item type caid (page group owner of item type)
    l_store.set_attribute('PAGE_GROUP_ID', 213); -- Page group
    l_store.set_attribute('FOLDER_ID', 37179); -- Page within page group
    l_store.set_attribute('REGION_ID', 3216); -- Region id within page
    -- see wwv_user_corners to determine template of page
    -- see wwsbr_all_folder_regions for region display_name and region id (for template)
    -- Get date format to insert right date string
    SELECT DISTINCT value
    INTO l_str
    FROM v$nls_parameters
    WHERE parameter = 'NLS_DATE_FORMAT';
    dbms_output.put_line('date format ins : ' || l_str);
    -- define attributes (for example, id are hardcoded
    DBMS_OUTPUT.put_line('Define attributes');
    -- 1080 = PRODUCT_CODE
    l_custom_attribute(1) := 'MEHI';
    l_custom_attribute_id(1) := 1080;
    l_custom_attribute_caid(1) := portal.wwsbr_api.SHARED_OBJECTS; -- = 0
    l_custom_attribute_data_type(1) := 'text';
    -- 1081 = PRODUCT_AUTHOR
    l_custom_attribute(2) := 'ESTAT';
    l_custom_attribute_id(2) := 1081;
    l_custom_attribute_caid(2) := portal.wwsbr_api.SHARED_OBJECTS; -- = 0
    l_custom_attribute_data_type(2) := 'text';
    -- 1469 = LANGUAGE
    l_custom_attribute(3) := 'fr';
    l_custom_attribute_id(3) := 1469;
    l_custom_attribute_caid(3) := portal.wwsbr_api.SHARED_OBJECTS; -- = 0
    l_custom_attribute_data_type(3) := 'text';
    -- 3 = title
    l_custom_attribute(4) := 'title value';
    l_custom_attribute_id(4) := 3;
    l_custom_attribute_caid(4) := portal.wwsbr_api.SHARED_OBJECTS; -- = 0
    l_custom_attribute_data_type(4) := 'text';
    -- 50 = wwsbr_text_
    l_custom_attribute(5) := 'wwsbr_text_ value';
    l_custom_attribute_id(5) := 50;
    l_custom_attribute_caid(5) := portal.wwsbr_api.SHARED_OBJECTS; -- = 0
    l_custom_attribute_data_type(5) := 'text';
    -- 1464 = Release date
    l_custom_attribute(6) := TO_CHAR(TO_DATE('21-JAN-2004 10:00 AM', 'DD-MON-YYYY HH12:MI PM'),l_str);
    l_custom_attribute_id(6) := 1464;
    l_custom_attribute_caid(6) := portal.wwsbr_api.SHARED_OBJECTS; -- = 0
    l_custom_attribute_data_type(6) := 'date';
    -- 1108 = download
    l_custom_attribute(7) := 'http://www.oracle.com/';
    l_custom_attribute_id(7) := 1108;
    l_custom_attribute_caid(7) := portal.wwsbr_api.SHARED_OBJECTS; -- = 0
    l_custom_attribute_data_type(7) := 'url';
    -- 1485 = CDROM
    l_custom_attribute(8) := '1';
    l_custom_attribute_id(8) := 1485;
    l_custom_attribute_caid(8) := portal.wwsbr_api.SHARED_OBJECTS; -- = 0
    l_custom_attribute_data_type(8) := 'boolean';
    -- 1111 = PAGE_NB
    l_custom_attribute(8) := '1';
    l_custom_attribute_id(8) := 1111;
    l_custom_attribute_caid(8) := portal.wwsbr_api.SHARED_OBJECTS; -- = 0
    l_custom_attribute_data_type(8) := 'number';
    -- 1783 = COVER_IMAGE
    -- get image
    SELECT BANNER
    INTO l_Blob
    FROM metadata_tbl
    WHERE PRODUCT_CODE = 'caa10000';
    -- upload image in repository
    l_filename := portal.wwsbr_api.upload_blob('BANNERupload',l_Blob, 'image/pjpeg');
    DBMS_OUTPUT.put_line('filename : ' || l_filename);
    l_custom_attribute(9) := l_filename;
    l_custom_attribute_id(9) := 1783;
    l_custom_attribute_caid(9) := portal.wwsbr_api.SHARED_OBJECTS; -- = 0
    l_custom_attribute_data_type(9) := 'file';
    DBMS_OUTPUT.put_line('Insert item starts');
    l_master := portal.wwsbr_api.add_item_post_upload(
    p_caid => l_store.get_attribute_as_number('PAGE_GROUP_ID'),
    p_folder_id => l_store.get_attribute_as_number('FOLDER_ID'),
    p_display_name => 'Insert : MEHI',
    p_type_id => l_store.get_attribute_as_number('ITEM_TYPE'),
    p_type_caid => l_store.get_attribute_as_number('ITEM_CAID'),
    p_region_id => l_store.get_attribute_as_number('REGION_ID'), --to set or default
    p_display_option => portal.WWSBR_API.IN_PLACE,
    -- p_category_id in number default general_category,
    -- p_category_caid in number default shared_objects,
    -- p_perspectives in g_perspectiveidarray default g_perspectiveidemptyarray,
    -- p_perspectives_caid in g_caid_array default g_empty_caid_array,
    -- p_author in varchar2 default wwctx_api . get_user,
    -- p_image_name => l_filename,
    -- p_image_alignment in varchar2 default align_left,
    -- p_description in varchar2 default null,
    -- p_keywords in varchar2 default null,
    -- p_file_name =>l_filename, --in varchar2 default null,
    p_text => 'text field',
    -- p_url in varchar2 default null,
    -- p_plsql in varchar2 default null,
    -- p_plsql_execute_mode in varchar2 default null,
    -- p_plsql_execute_user in varchar2 default null,
    -- p_folderlink_id in number default null,
    -- p_folderlink_caid in number default null,
    -- p_publish_date in varchar2 default null,
    -- p_expire_mode in varchar2 default permanent,
    -- p_expiration in varchar2 default null,
    -- p_master_item_id in number default null,
    -- p_hide_in_browse in number default no,
    -- p_checkable in number default no,
    -- p_parent_item_id in number default 0,
    p_attribute_id => l_custom_attribute_id,
    p_attribute_caid => l_custom_attribute_caid,
    p_attribute_data_type => l_custom_attribute_data_type,
    p_attribute_value => l_custom_attribute
    DBMS_OUTPUT.put_line('Insert item ends. Item identifier : ' || l_master);
    -- Invalidate cache from SQLPLUS
    portal.wwpro_api_invalidation.execute_cache_invalidation;
    DBMS_OUTPUT.put_line('Cache invalidated');
    -- Drop session
    portal.wwsto_api_session.drop_session('ctx','ctx');
    -- Clean context
    portal.wwctx_api.clear_context;
    COMMIT;
    exception
    WHEN portal.wwctx_api.AUTHENTICATION_EXCEPTION THEN
    DBMS_OUTPUT.PUT_LINE('AUTHENTICATION_EXCEPTION : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.CANNOT_INSERT_DOCUMENT THEN
    DBMS_OUTPUT.PUT_LINE('CANNOT INSERT DOCUMENT : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.DUPLICATE_FOLDER THEN
    DBMS_OUTPUT.PUT_LINE('DUPLICATE_FOLDER : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.DUPLICATE_ID THEN
    DBMS_OUTPUT.PUT_LINE('DUPLICATE_ID : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.DUPLICATE_NAME THEN
    DBMS_OUTPUT.PUT_LINE('DUPLICATE_NAME : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.FOLDER_VERSIONING_IS_AUDIT THEN
    DBMS_OUTPUT.PUT_LINE('FOLDER_VERSIONING_IS_AUDIT : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.FOLDER_VERSIONING_IS_NONE THEN
    DBMS_OUTPUT.PUT_LINE('FOLDER_VERSIONING_IS_AUDIT : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.ILS_DISABLED THEN
    DBMS_OUTPUT.PUT_LINE('ILS_DISABLED : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.ILS_DISABLED_FOR_ITEM THEN
    DBMS_OUTPUT.PUT_LINE('ILS_DISABLED_FOR_ITEM : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_CAID THEN
    DBMS_OUTPUT.PUT_LINE('INVALID CAID : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_CATEGORY THEN
    DBMS_OUTPUT.PUT_LINE('INVALID CATEGORY : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_EXPIRE_DATE THEN
    DBMS_OUTPUT.PUT_LINE('INVALID_EXPIRE_DATE : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_EXPIRE_DATE_FORMAT THEN
    DBMS_OUTPUT.PUT_LINE('INVALID_EXPIRE_DATE_FORMAT : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_EXPIRE_NUMBER THEN
    DBMS_OUTPUT.PUT_LINE('INVALID_EXPIRE_NUMBER : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_FOLDER THEN
    DBMS_OUTPUT.PUT_LINE('INVALID_FOLDER : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_FOLDER_ID THEN
    DBMS_OUTPUT.PUT_LINE('INVALID FOLDER ID : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_ITEM_ID THEN
    DBMS_OUTPUT.PUT_LINE('INVALID ITEM ID : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_ITEMTYPE THEN
    DBMS_OUTPUT.PUT_LINE('INVALID ITEMTYPE : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_MOVE THEN
    DBMS_OUTPUT.PUT_LINE('INVALID MOVE : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_NAME THEN
    DBMS_OUTPUT.PUT_LINE('INVALID NAME : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_NUMBER THEN
    DBMS_OUTPUT.PUT_LINE('INVALID NUMBER : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_PERSPECTIVE THEN
    DBMS_OUTPUT.PUT_LINE('INVALID PERSPECTIVE : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_PLSQL_EXECUTE_USER THEN
    DBMS_OUTPUT.PUT_LINE('INVALID_PL/SQL_EXECUTE_USER : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_PUBLISH_DATE_FORMAT THEN
    DBMS_OUTPUT.PUT_LINE('INVALID_PUBLISH_DATE_FORMAT : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_PUBLISH_DATE_VALUE THEN
    DBMS_OUTPUT.PUT_LINE('INVALID_PUBLISH_DATE_VALUE : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.INVALID_USERNAME THEN
    DBMS_OUTPUT.PUT_LINE('INVALID USERNAME : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.ITEM_CREATION_ERROR THEN
    DBMS_OUTPUT.PUT_LINE('ITEM_CREATION ERROR : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.ITEM_NOT_FOUND_ERROR THEN
    DBMS_OUTPUT.PUT_LINE('ITEM NOT FOUND ERROR : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.ITEM_UPDATE_ERROR THEN
    DBMS_OUTPUT.PUT_LINE('ITEM_UPDATE_ERROR : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.MISSING_DISPLAY_NAME THEN
    DBMS_OUTPUT.PUT_LINE('MISSING DISPLAY NAME : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.MISSING_ITEM_TYPE THEN
    DBMS_OUTPUT.PUT_LINE('MISSING ITEM TYPE : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.MISSING_NAME THEN
    DBMS_OUTPUT.PUT_LINE('MISSING NAME : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.MISSING_PLSQL_EXECUTE_USER THEN
    DBMS_OUTPUT.PUT_LINE('MISSING plsql execute user : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.NAME_TOO_LONG THEN
    DBMS_OUTPUT.PUT_LINE('name too long : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.NO_ITEM_REGION THEN
    DBMS_OUTPUT.PUT_LINE('not item region : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.NO_MASTER_ITEM_ID THEN
    DBMS_OUTPUT.PUT_LINE('no master item id : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.NOT_ENOUGH_PRIVS THEN
    DBMS_OUTPUT.PUT_LINE('not enough privs : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.NULL_EXPIRE_DATE THEN
    DBMS_OUTPUT.PUT_LINE('null expire date : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.NULL_EXPIRE_NUMBER THEN
    DBMS_OUTPUT.PUT_LINE('null expire number : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.PERMISSION_DENIED THEN
    DBMS_OUTPUT.PUT_LINE('permission denied : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.PLSQL_REQUIRED THEN
    DBMS_OUTPUT.PUT_LINE('plsql required : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.QUOTA_EXCEEDED THEN
    DBMS_OUTPUT.PUT_LINE('quota exceeded : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.REQD_ATTR_MISSING THEN
    DBMS_OUTPUT.PUT_LINE('reqd attr missing : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.UNKNOWN_ERROR THEN
    DBMS_OUTPUT.PUT_LINE('unknown error : ' || sqlerrm);
    ROLLBACK;
    WHEN portal.wwsbr_api.URL_REQUIRED THEN
    DBMS_OUTPUT.PUT_LINE('url required : ' || sqlerrm);
    ROLLBACK;
    when OTHERS then
    DBMS_OUTPUT.PUT_LINE('OTHERS : ' || sqlerrm || ' : ' || sqlcode);
    ROLLBACK;
    end;

    Hi Eddy:
    On Friday, we put in a TAR with Oracle support about the identical problem. When editing an item using the API, the boolean attributes always reset. The values of the boolean attributes aren't even being changed. The only reason we need to set them again is the limitation of the API where you have to feed all attributes back in.
    So far, Oracle has said it sounds like a bug and they want to know the exact sequence of steps to repeat it.
    Rgds/Mark M.
    Portal 9.0.2.6

  • Problem when calling a return type BOOLEAN SQL Function in a package

    Hi All,
    I am having problem when trying to call a SQL function in a package with return type BOOLEAN
    The SQL function signature is as follows
    CREATE OR REPLACE PACKAGE RMSOWNER.ORDER_ATTRIB_SQL ****
    FUNCTION GET_PO_TYPE_DESC(O_error_message IN OUT VARCHAR2,
    I_PO_TYPE       IN     VARCHAR2,
    O_PO_TYPE_DESC  IN OUT VARCHAR2)
    RETURN BOOLEAN;
    Following is my java code
    +CallableStatement cs3 = conn.prepareCall("{?=call ORDER_ATTRIB_SQL.GET_PO_TYPE_DESC(?,?,?)}");+
    +cs3.registerOutParameter(1, java.sql.Types.BOOLEAN);+
    +cs3.registerOutParameter(2, java.sql.Types.VARCHAR);+
    +cs3.registerOutParameter(4, java.sql.Types.VARCHAR);+
    +cs3.setString(2, "");+
    +cs3.setString(3, "ST");+
    +cs3.setString(4, "");+
    +ResultSet rs3 = cs3.executeQuery();+
    I get the following exception, i tried changing the sql type(registerOutParameter) from boolean to bit but i still getting this exception.
    But when i call any other functions with return type other than boolean they work perfectly fine.
    Please can anyone help me fix this issue, i am not sure if its anything to do with vendor JDBC classes?
    +java.sql.SQLException: ORA-06550: line 1, column 13:+
    +PLS-00382: expression is of wrong type+
    +ORA-06550: line 1, column 7:+
    +PL/SQL: Statement ignored+
    +     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)+
    +     at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)+
    +     at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)+
    +     at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:743)+
    +     at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:215)+
    +     at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:954)+
    +     at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1168)+
    +     at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3316)+
    +     at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3422)+
    +     at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4394)+
    #####

    Hello People!
    There is another workaround!!
    See the example below:
    private String callBooleanAPi(String tableName,String apikey,String dtInicio,String dtFim,String comando) throws SQLException {
                   CallableStatement cs = null;
                   String call = "";
                   String retorno = null;
                   try {
                        if(comando.equalsIgnoreCase("INSERT")){
                             call = "declare x BOOLEAN; y varchar2(2);begin x :=PKG.INSERT(?,?,?,?,?); if x then y := 'S'; else y :='N'; end if; ? := y;end;";
                        } else if(comando.equalsIgnoreCase("UPDATE")){
                             call = "declare x BOOLEAN; y varchar2(2);begin x := PKG.UPDATE(?,?,?,?,?); if x then y := 'S'; else y :='N'; end if; ? := y;end;";
                        } else if(comando.equalsIgnoreCase("DELETE")){
                             call = "declare x BOOLEAN; y varchar2(2);begin x := PKG.DELETE(?,?,?,?,?); if x then y := 'S'; else y :='N'; end if; ? := y;end;";
                        cs = conn.prepareCall(call);
                        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
                        SimpleDateFormat sdfToSqlDate = new SimpleDateFormat("yyyy-MM-dd");
                        java.util.Date dataInicialVigencia =null;
                        java.util.Date dataFinalVigencia = null;
                        Date dtInicialFormatada =null;
                        Date dtFinalFormatada = null;
                        if(dtInicio != null && !dtInicio.equals("")){
                             dataInicialVigencia = sdf.parse(dtInicio);
                             dtInicio =sdfToSqlDate.format(dataInicialVigencia);
                             dtInicialFormatada = Date.valueOf(dtInicio);
                        if(dtFim != null && !dtFim.equals("")){
                             dataFinalVigencia = sdf.parse(dtFim);
                             dtFim =sdfToSqlDate.format(dataFinalVigencia);
                             dtFinalFormatada = Date.valueOf(dtFim);
                        cs.setString(1, tableName);
    cs.setString(2, apikey);
    cs.setDate(3, dtInicialFormatada );
    cs.setDate(4, dtFinalFormatada );
    cs.registerOutParameter(5, java.sql.Types.VARCHAR);
    cs.registerOutParameter(6, java.sql.Types.VARCHAR );
    cs.execute();
                        retorno = cs.getString(6);
                        System.out.println( cs.getString(5));
                   } catch(SQLException e){
                   throw new SQLException("An SQL error ocurred while calling the API COR_VIGENCIA: " + e);
                   } catch(Exception e){
                   Debug.logger.error( "Error calculating order: " + id, e );
                   } finally {
                   if (cs != null) {
                   cs.close();
                   cs = null;
                   return retorno;
    As you can see the CallableStatement class acepts PL/SQl blocks.
    Best Regards.

  • Calling boolean function from tree query

    Hi all,
    I have placed a tree on my sidebar region from the following query
    select PAGE_NO id,
    PARENT_PAGE_NO pid,
    NAME name,
    'f?p=&APP_ID.:'||page_no||':&SESSION.' link,
    null a1,
    null a2
    from #OWNER#.APEX_PAGES
    WHERE page_no = :APP_PAGE_ID
    AND nvl(navigation,'N') = 'Y'
    Its running perfectly fine. Now i have my custom function "isUserAllowed(app_user, name_of_node, isParent)" which returns a boolean expression is the logged in User has access privilege on that node.
    How can i run my function inside the tree query so that node is visible only for those values in which my function returns "true"? and not on others?
    With Regards,
    Sunil Bhatia

    The "wrapper" function would actually be pretty easy - just another function to call the one returning the boolean and convert it to some other value, numeric or character. something like (untested)
    <pre>
    FUNCTION wrapper_function(P_whatever varchar2) return varchar2 IS
    v_return_value_c varchar2(5);
    BEGIN
    r_return_value_c := case boolean_function(p_whatever)
    when true then 'true'
    else 'false;
    return v_return_value_c;
    END;
    </pre>
    Using the function in the WHERE clause could look something like this (untested, but should work if done correctly)
    <pre>
    select whatever
    from your_table
    where wrapper_function(whatever) = 'true'
    </pre>

  • To display a VARCHAR field in database as select boolean checkbox

    Hi,
    i have a table in database having a VARCHAR2(1) field named IsActive with value 'Y' or 'N' , I need to display this field as select boolean check box in the JSF page
    using ADF Entity Object and ViewObject. We have followed the following method for displaying this field as select boolean check box.
    1. Changed the datatype of the IsActive field in the Entity Object as Boolean and the database column type as Varchar2(10)
    2. we have edited the query using case when IsActive='Y' then 1 else 0 end .
    3.and converted the IsActive inputtext to select boolean checkbox.
    Thus we where able to display this field as select boolean check box but the problem is that we where not able to insert the data as 'Y' or 'N' using this method.
    Please help us whether the method we are following is correct or is there any other method to insert and display the similar fields like IsActive as select boolean check box in ADF
    Thanks in Advance
    Anitha

    Anitha,
    Create a transient boolean attribute on your EO. Write the getter to return true/false if the real attribute is Y/N. Write the setter to do the converse. Bind the transient attribute to the checkbox.
    John

  • How to Use a boolean function in a process

    Hi,
    I created a boolean function named change_pwd with 3 varchar2 parameters : login_name, old-pwd and new_pwd. I would like to use it in a process but I can't, this is how I do it :<br><br>
    select change_pwd (
    v('P12_Login'),v('P12_Old_Pwd'),v('P12_New_Pwd')) from dual;
    <br><br>
    Benn

    I got this error : <br><br>
    ORA-06550: line 2, column 8: PLS-00382: expression is of wrong type ORA-06550: line 2, column 1: PLS-00428: an INTO clause is expected in this SELECT statement
    <br><br>
    and here is my function :<br><br>
    create or replace function "CHANGE_PWD"<br>
    (p_username in VARCHAR2,<br>
    p_old_password in VARCHAR2, <br>
    p_new_password in VARCHAR2)<br>
    return boolean<br>
    is<br>
    l_count number;<br>
    l_password varchar2(4000);<br>
    l_stored_password varchar2(4000); <br>
    l_idcontact number;<br>
    begin<br>
    -- Check to see if the user is in the user table<br>
    select count(*) into l_count from CONTACTS where MATRICULE = p_username;<br>
    if l_count > 0 then<br>
    -- take the stored password<br>
    select u.MOTDEPASSE, u.IdContacts into l_stored_password, l_idcontact from <br>UTILISATEURS u, CONTACTS c where u.IdContacts = c.IdContacts AND c.MATRICULE = p_username;<br>
    <br>
    -- apply the cash function<br>
    l_password := user_hash(p_username, p_old_password);<br>
    <br>
    -- compare the hashed password with the stored password<br>
    if l_password = l_stored_password then<br>
    -- change password<br>
    update UTILISATEURS set MotDePasse = user_hash(p_username, <br>p_new_password) where idcontacts = l_idcontact;
    return true;<br>
    else<br>
    return false;<br>
    end if;<br>
    else<br>
    return false;<br>
    end if;<br>
    end;<br>

  • Problem with boolean type in Informix via ODBC

    Hello,
    I'm connecting to an Informix database from an Oracle database via the ODBC Gateway. The connection works fine.
    However, when I select a boolean type column from a table in the Informix database, nothing is returned and I get the following error:
    SQL> select "stat" from bt@informix;
    ERROR:
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Informix][Informix ODBC Driver]Restricted data type attribute violation.
    {07006,NativeErr = -11013}
    ORA-02063: preceding 2 lines from INFORMIX
    no rows selected
    Selecting a boolean type column with isql works fine. Other column types work from Oracle.
    Can anyone help me resolve this issue? Please find configuration details and traces below.
    Software stack:
    Informix Database: Enterprise Edition 12.10 for Linux x86_64
    Informix ODBC driver: Informix Client SDK Developer Edition 4.10 for Linux 64-bit
    Oracle Database: Enterprise Edition 11.2.0.1.0 64-bit (Oracle Linux 6.6 64-bit)
    UnixODBC: 2.3.2 x86_64
    odbcinst.ini:
    [Informix]
    Driver=/opt/IBM/informix/lib/cli/libifcli.so
    Setup=/opt/IBM/informix/lib/cli/libifcli.so
    APILevel=1
    ConnectFunctions=YYY
    DriverODBCVer=03.51
    FileUsage=0
    SQLLevel=1
    smProcessPerConnect=Y
    [ODBC]
    TraceFile=/tmp/odbc.log
    Trace = Yes
    odbc.ini:
    [ol_informix1210]
    Driver=Informix
    Description=Test connection
    Database=sysutils
    LogonID=informix
    pwd=informix
    Servername=ol_informix1210
    CursorBehavior=0
    DB_LOCALE=en_us.8859-1
    TRANSLATIONDLL=/opt/IBM/informix/lib/esql/igo4a304.so
    [ODBC]
    UNICODE=UCS-2
    ; Trace file Section
    Trace=1
    TraceFile=/tmp/odbctrace.out
    InstallDir=/opt/IBM/informix
    TRACEDLL=idmrs09a.so
    Oracle Gateway init.ora:
    HS_FDS_CONNECT_INFO=ol_informix1210
    HS_FDS_SHAREABLE_NAME=/usr/local/lib/libodbc.so
    HS_FDS_TRACE_LEVEL=debug
    HS_LANGUAGE=AMERICAN_AMERICA.WE8ISO8859P1
    Oracle Gateway trace:
    Entered hgoftch, cursor id 1 at 2015/04/14-12:22:03
    hgoftch, line 130: Printing hoada @ 0x2007fe0
    MAX:1, ACTUAL:1, BRC:100, WHT=5 (SELECT_LIST)
    hoadaMOD bit-values found (0x20:NEGATIVE_HOADADTY)
    DTY     NULL-OK  LEN  MAXBUFLEN   PR/SC  CST IND MOD NAME
    -7 BIT Y          1          1   0/  0    0   0  20 stat
    Performing delayed open.
    SQLBindCol: column 1, cdatatype: -28, bflsz: 1
    Entered hgopoer at 2015/04/14-12:22:03
    hgopoer, line 233: got native error -11013 and sqlstate 07006; message follows...
    [Informix][Informix ODBC Driver]Restricted data type attribute violation. {07006,NativeErr = -11013}
    Exiting hgopoer, rc=0 at 2015/04/14-12:22:03
    hgoftch, line 730: calling SQLFetch got sqlstate 07006
    0 rows fetched
    Exiting hgoftch, rc=28500 at 2015/04/14-12:22:03 with error ptr FILE:hgoftch.c LINE:730 FUNCTION:hgoftch() ID:Fetch resultset data
    ODBC trace:
    [ODBC][11041][1429005970.973443][SQLPrepare.c][196]
                    Entry:
                            Statement = 0x276ecb0
                            SQL = [SELECT A1. stat  FROM  BT  A1][length = 29]
    [ODBC][11041][1429005970.973914][SQLPrepare.c][371]
                    Exit:[SQL_SUCCESS]
    [ODBC][11041][1429005970.973940][SQLNumResultCols.c][156]
                    Entry:
                            Statement = 0x276ecb0
                            Column Count = 0x26f5868
    [ODBC][11041][1429005970.973970][SQLNumResultCols.c][248]
                    Exit:[SQL_SUCCESS]
                            Count = 0x26f5868 -> 1
    [ODBC][11041][1429005970.974097][SQLDescribeCol.c][247]
                    Entry:
                            Statement = 0x276ecb0
                            Column Number = 1
                            Column Name = 0x7fffc3ff2d90
                            Buffer Length = 31
                            Name Length = 0x7fffc3ff2ed4
                            Data Type = 0x7fffc3ff2ed8
                            Column Size = 0x7fffc3ff2e70
                            Decimal Digits = 0x7fffc3ff2edc
                            Nullable = 0x7fffc3ff2ee0
    [ODBC][11041][1429005970.974140][SQLDescribeCol.c][501]
                   Exit:[SQL_SUCCESS]               
                            Column Name = [stat]               
                            Data Type = 0x7fffc3ff2ed8 -> -7               
                            Column Size = 0x7fffc3ff2e70 -> 1               
                            Decimal Digits = 0x7fffc3ff2edc -> 0               
                            Nullable = 0x7fffc3ff2ee0 -> 1
    [ODBC][11041][1429005970.974192][SQLSetStmtAttr.c][265]
                    Entry:
                            Statement = 0x276ecb0
                            Attribute = SQL_ATTR_ROW_ARRAY_SIZE
                            Value = 0x64
                            StrLen = 0
    [ODBC][11041][1429005970.974218][SQLSetStmtAttr.c][925]
                    Exit:[SQL_SUCCESS]
    [ODBC][11041][1429005970.974230][SQLSetStmtAttr.c][265]
                    Entry:
                            Statement = 0x276ecb0
                            Attribute = SQL_ATTR_ROW_BIND_TYPE
                            Value = (nil)
                            StrLen = -5
    [ODBC][11041][1429005970.974249][SQLSetStmtAttr.c][925]
                    Exit:[SQL_SUCCESS]
    [ODBC][11041][1429005970.974837][SQLExecute.c][187]
                    Entry:
                            Statement = 0x276ecb0
    [ODBC][11041][1429005970.975231][SQLExecute.c][348]
                    Exit:[SQL_SUCCESS]
    [ODBC][11041][1429005970.975255][SQLSetStmtAttr.c][265]
                    Entry:
                            Statement = 0x276ecb0
                            Attribute = SQL_ATTR_ROW_STATUS_PTR
                            Value = 0x27f5b78
                            StrLen = -4
    [ODBC][11041][1429005970.975280][SQLSetStmtAttr.c][925]
                    Exit:[SQL_SUCCESS]
    [ODBC][11041][1429005970.975291][SQLSetStmtAttr.c][265]
                    Entry:
                            Statement = 0x276ecb0
                            Attribute = SQL_ATTR_ROWS_FETCHED_PTR
                            Value = 0x26f5850
                            StrLen = -4
    [ODBC][11041][1429005970.975311][SQLSetStmtAttr.c][925]
                    Exit:[SQL_SUCCESS]
    [ODBC][11041][1429005970.975326][SQLBindCol.c][236]
                    Entry:
                            Statement = 0x276ecb0
                            Column Number = 1
                            Target Type = -28 SQL_C_UTINYINT
                            Target Value = 0x27f5af8
                            Buffer Length = 1
                            StrLen Or Ind = 0x27f5eb8
    [ODBC][11041][1429005970.975349][SQLBindCol.c][341]
                    Exit:[SQL_SUCCESS]
    [ODBC][11041][1429005970.975367][SQLFetch.c][162]
                    Entry:
                            Statement = 0x276ecb0
    [ODBC][11041][1429005970.975455][SQLFetch.c][348]
                    Exit:[SQL_ERROR]
                    DIAG [07006] [Informix][Informix ODBC Driver]Restricted data type attribute violation.
    [ODBC][11041][1429005970.975574][SQLGetDiagRec.c][758]
                   Entry:
                            Statement = 0x276ecb0
                            Rec Number = 1
                            SQLState = 0x7fffc3ff2e20
                            Native = 0x7fffc3ff2c14
                            Message Text = 0x7fffc3ff2c20
                            Buffer Length = 510
                            Text Len Ptr = 0x7fffc3ff2e70
    [ODBC][11041][1429005970.975615][SQLGetDiagRec.c][795]
                    Exit:[SQL_SUCCESS]
                            SQLState = 07006
                            Native = 0x7fffc3ff2c14 -> -11013
                            Message Text = [[Informix][Informix ODBC Driver]Restricted data type attribute violation.]
    [ODBC][11041][1429005970.975642][SQLGetDiagRec.c][758]
                    Entry:
                            Statement = 0x276ecb0
                            Rec Number = 2
                            SQLState = 0x7fffc3ff2e20
                            Native = 0x7fffc3ff2c14
                            Message Text = 0x7fffc3ff2c20
                         Message Text = 0x7fffc3ff2c20
                            Buffer Length = 510
                            Text Len Ptr = 0x7fffc3ff2e70
    [ODBC][11041][1429005970.975667][SQLGetDiagRec.c][795]
                    Exit:[SQL_NO_DATA]

    Here are my findings after consulting the unixODBC mailing list and the IBM documentation.
    There are several levels of data types at play here: native Informix SQL types, Informix ODBC driver SQL types and Informix ODBC driver C types (as well as standard C types).
    According to the Informix documentation (http://www-01.ibm.com/support/knowledgecenter/SSGU8G_11.70.0/com.ibm.odbc.doc/ids_odbc_108.htm), the ODBC driver SQL type for the native boolean type is SQL_BIT.
    The traces show that the ODBC SQL type is SQL_BIT (type code -7) and that this should be converted into the SQL_C_UTINYINT ODBC C type (type code -28).
    Oracle ODBC Gateway trace:
    DTY    NULL-OK  LEN  MAXBUFLEN  PR/SC  CST IND MOD NAME
    -7 BIT Y          1          1  0/  0    0  0  20 stat
    Performing delayed open.
    SQLBindCol: column 1, cdatatype: -28, bflsz: 1
    unixODBC trace:
    ODBC][11041][1429005970.975326][SQLBindCol.c][236]
                    Entry:
                            Statement = 0x276ecb0
                            Column Number = 1
                           Target Type = -28 SQL_C_UTINYINT
                            Target Value = 0x27f5af8
                            Buffer Length = 1
                            StrLen Or Ind = 0x27f5eb8
    [ODBC][11041][1429005970.975349][SQLBindCol.c][341]
    Oracle tries to bind the SQL_BIT type column to a buffer of SQL_C_UTINYINT type, which requires a conversion from SQL_BIT to SQL_C_UTINYINT  that is apparently not supported by the Informix ODBC Driver.
    According to the documentation (http://www-01.ibm.com/support/knowledgecenter/SSGU8G_11.70.0/com.ibm.odbc.doc/ids_odbc_108.htm) the Informix ODBC driver can only convert the SQL_BIT ODBC SQL type into SQL_C_BINARY, SQL_C_BIT and SQL_C_CHAR ODBC C types. (The ODBC C types are in turn converted into standard C types, for example the SQL_C_BIT type is converted into UCHAR which is a typedef for the standard C type unsigned char.)
    A possible workaround could be to tell Informix to present boolean as a different ODBC SQL type, for example SQL_CHAR (as it would be possible with PostgreSQL by setting BoolAsCharater=1 in odbc.ini), but Informix only seems to supports the SQL_BIT ODBC SQL type.
    A cumbersome workaround is to use the Gateway's pass-through feature that allows a query to be passed to Informix as is, which in turn allows us to cast the boolean field into a character field:
    SQL> set serveroutput on
    SQL> r
      1  DECLARE
      2    val  VARCHAR2(1);
      3    c    INTEGER;
      4    nr  INTEGER;
      5  BEGIN
      6    c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@informix;
      7    DBMS_HS_PASSTHROUGH.PARSE@informix(c,'select cast (stat as character) from bt');
      8    LOOP
      9    nr := DBMS_HS_PASSTHROUGH.FETCH_ROW@informix(c);
    10    EXIT WHEN nr = 0;
    11    DBMS_HS_PASSTHROUGH.GET_VALUE@informix(c, 1, val);
    12    DBMS_OUTPUT.PUT_LINE(val);
    13    END LOOP;
    14    DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@informix(c);
    15  END;
    16*
    t
    f
    PL/SQL procedure successfully completed
    Easier solutions are still welcome.

  • Calling Stored Procedure with Boolean Output Parameter

    Hi all,
    I'm running into an issue (or is it a BUG) when calling a Database Stored Procedure that has an output parameter of the boolean type.
    procedure proc(p_text in varchar2, p_result out boolean)
    is
    .....I use the following 'standard' code (developer guide 36-19 36-20) to invoke this procedure from my application module.
            try {
                // 1. Define the PL/SQL block for the statement to invoke
                String stmt = "begin proc(?,?); end;";
                // 2. Create the CallableStatement for the PL/SQL block
                st = getDBTransaction().createCallableStatement(stmt, 0);
                // 3. Register the positions and types of the OUT parameters
                st.registerOutParameter(2, Types.BOOLEAN);
                // 4. Set the bind values of the IN parameters
                st.setObject(1, "Some text");
                // 5. Execute the statement
                st.executeUpdate();
                ..............................As soon as 'st.registerOutParameter(2, Types.BOOLEAN);' is invoked I run into a SQLexception. "Invalid ColumnType: 16". Obviously 16 refers to Types.BOOLEAN.
    [edit by Luc]
    SOLUTION / WORKAROUND
    To answer my own question.
    It looks like BOOLEAN output parameters are not supported. I just Read "Appendix D Troubleshooting" of the Oracle® Database JDBC Developer's Guide and Reference 10g Release 2 (10.2).
    I found that JDBC drivers do not support the passing of BOOLEAN parameters to PL/SQL stored procedures. If a PL/SQL procedure contains BOOLEAN values, you can work around the restriction by wrapping the PL/SQL procedure with a second PL/SQL procedure that accepts the argument as an INT and passes it to the first stored procedure. When the second procedure is called, the server performs the conversion from INT to BOOLEAN.
    I'm not very happy with this but I guess I've no choice.
    Regards Luc
    Edited by: lucbors on Nov 30, 2010 10:37 AM

    fyi
    Related to the solution/workaround posted by Luc.
    see "Do Oracle's JDBC drivers support PL/SQL tables/result sets/records/booleans? "
    at http://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html#34_05
    regards
    Jan Vervecken

  • Calling PL/SQL procedure that returns boolean in java

    Hi All,
    Was not sure weather to post this on Java forum threads or PL/SQL forum threads. So posting at both locations.
    I have to call a PL/SQL procedure from java. This PL/SQL has IN/OUT parameters as well as return a Boolean value.
    The procedure definition is as follows:
    FUNCTION GET_NEXT(O_error_message IN OUT VARCHAR2,
    IO_item_no IN OUT ITEM_MASTER.ITEM%TYPE,
    I_item_type IN ITEM_MASTER.ITEM_NUMBER_TYPE%TYPE)
    return BOOLEAN;
    END ITEM_NUMBER_TYPE_SQL;
    And the java function I am using is as follows:
    This is in the ADF Application module impl code
    public String callNextItem(){
    CallableStatement callableStmt = null;
    String rmsUser = getDBTransaction().getConnectionMetadata().getUserName();
    String callableStatement = "begin ? := ITEM_NUMBER_TYPE_SQL.VALIDATE_FORMAT(?,?,?); end;";
    System.out.println("callableStatement "+callableStatement);
    try{
    callableStmt = getDBTransaction().createCallableStatement(callableStatement,0);
    callableStmt.registerOutParameter(1, Types.*BIT*);
    callableStmt.registerOutParameter(2, Types.VARCHAR);
    callableStmt.registerOutParameter(3, Types.VARCHAR);
    callableStmt.registerOutParameter(4, Types.VARCHAR);
    callableStmt.setBoolean(1, false);
    callableStmt.setString(2, "");
    callableStmt.setString(3, "");
    callableStmt.setString(4, "UPC-A");
    callableStmt.executeUpdate();
    System.out.println("STATUS : " + callableStmt.getString(3));
    System.out.println("ERROR : " + callableStmt.getString(2));
    String status = "";
    getDBTransaction().commit();
    System.out.println("commited ");
    callableStmt.close();
    return status;
    }catch(SQLException e){
    System.out.println("Error:" +e);
    throw new JboException(e);
    But this function never works. Throws "not valid expression type" error.
    I have called several PL/SQL procedures before, only difference being
    they never used to return any value. Particularly I feel the cause of the
    error is the Boolean type that is returned from the procedure.
    If you have any idea, please help.

    http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.html#34_05

  • Boolean Datatype declaration in PowerBuilder...Please HELP

    Hi,
    I have Oracle Stored procedure with last parameter as boolean, When I am calling this stored procedure in
    PowerBuilder 6.5 in the DECLARE I am getting compilation error and it is not working...
    I heard that there is some round about way to solve this problem...
    Any one knows the solution...please help me out...

    I don't know about PowerBuilder but we had a similar problem with Java not understanding Oracle's BOOLEAN implementation. I'm afraid we solved this by substituting a VARCHAR2 parameter with values of 'TRUE' and 'FALSE'. Not very elegant I'm afraid, but if your stored procedure is in a package you can at least overload it.
    cheers, APC

  • Use of boolean returning functions in a project

    Hello all gurus,
    in my project, we have a fairly important packaged functions that return boolean values. Working with these ones in pl/sql is very fine. But sometimes we need to reuse these functions in SQL, but no luck because bools are usable under pl/sql only and can't interact in any way in SQL statements. So the workaround should be to use these functions to return us some Y/N or 1/0 to emulate boolean behavior in SQL statements.
    Here what i tested with not luck:
    -- not work
    select r.role, sys.diutil.bool_to_int(dbms_session.is_role_enabled(r.role)) as is_role_enabled
    from   dba_roles r;
    -- not work
    select r.role
    from   dba_roles r
    where  sys.diutil.bool_to_int(dbms_session.is_role_enabled(r.role)) = 1;
    -- not work
    select t1.id,
           bool_to_char(my_bool_func(t1.x, t1.y, ...)) as is_something
    from   t1;
    -- not work
    select t1.id,
           sys.diutil.bool_to_int(my_bool_func(t1.x, t1.y, ...)) as is_something
    from   t1;The odd wrapping trick as a last resort solution is working....
    -- Works! Seems the only way, but a lot of wrapping work...
    create or replace function my_bool_func_wrap(p_x number, p_y number, ...) return varchar2 as
    begin
       return bool_to_char(my_bool_func(p_x, p_y, ...));
    end;
    select t1.id,
           my_bool_func_wrap((t1.x, t1.y, ...)) as is_something
    from   t1;I read a lot, but no elegant and working way.
    Is there a more standard, elegant universal way to call bool functions from SQL?
    Is creating a custom type visible and usable from both pl/sql and sql, if possible, a way to go?
    Any other pointers?
    For new development, is it good to make my boolean type returning functions using SQL compatible type like CHAR (Y/N) or NUMBER (1/0) ? It will make us less wrapping job, but more and less elegant bool handling code on the pl/sql side.
    What is the goal to have bool only in pl/sql and not usable in SQL? It's kind of a feature incompatibility in the same product. Strange...
    Thanks a lot
    Bruno

    brlav wrote:
    Finally, I'll have to dump the BOOLEAN return type to all our boolean functions and return char instead. With this I will be able to call then from SQL.... From this perspective, BOOLEAN is useless.I would not say that. Let's assume that you implement boolean in SQL as a single byte character string containing either Y or N, enforce that with a constraint and also add a not-null constraint to it.
    You simply define two PL functions (not usable from SQL) that deals with the conversion. You use the one function to change boolean to char before hitting the SQL engine, and the other to convert char to boolean when getting data from the SQL engine.
    As I/O routines are modularised, it means that you need to deal with these conversions once only when writing and once only when reading (per module).
    Simple example:
    SQL> create or replace function to_bool( c varchar2 ) return boolean is
      2  begin                                                            
      3          return( c = 'Y' );                                       
      4  end;                                                             
      5  /                                                                
    Function created.
    SQL>
    SQL> create or replace function bool_to_char( b boolean ) return varchar2 is
      2  begin
      3          if b then
      4                  return( 'Y' );
      5          else
      6                  return( 'N' );
      7          end if;
      8  end;
      9  /
    Function created.
    SQL>
    SQL> declare
      2          i       integer;
      3          b       boolean;
      4          flag    all_tables.temporary%type;
      5          tab     all_tables%rowtype;
      6  begin
      7          flag := bool_to_char(true);  
      8          select count(*) into i from all_tables where temporary = flag;
      9
    10          select t.* into tab from all_tables t where rownum = 1;
    11          b := to_bool( tab.temporary );
    12  end;
    13  /
    PL/SQL procedure successfully completed.
    SQL>

Maybe you are looking for

  • Using Automator to reply to everyone on an iCal event

    Hi all, I regularly need to email everyone who is invited to a meeting in an iCal event.  The manual way of doing this is: Double-click the event with all the invitees in iCal Click in the invitee field Command + A (select all) Command + C (copy) Cre

  • Adobe InDesign crashes frequently (Win8.1pro, CS6 Design Standard)

    I am experiencing an issue with Adobe InDesign. It crashes frequently, 3 or 4 times over an 8 hour work day. There doesn't seem to be a pattern in the crashes, it isn't when I'm doing anything specific, it just happens seemingly randomly. The compute

  • Audio out from HDMI port?

    I have connected my TV and Booklet via a standard HDMI cable.  This same HDMI cable works fine with my DVD player.   When I use it with my booklet, only video seems to be sent to the TV via the HDMI cable.  Is the HDMI out port supporting only video,

  • Numbers App or better than Mint!

    Can someone recommend an app that can be exported into pre-established numbers spread sheet? or excell??? I like to keep track of my cash expenditures, for deductions....Mint is not right for this and Quick Bank exported into non mac friendly text do

  • Different date on PO-printout

    Hi gurus, is there any way of printing a date onto the PO-printout that differs from the document date? E.g. PO is created on Aug 5, 2008. So, the document date is (and has to be!) Aug 5, 2008. But the date on the printed order document should be e.g