Like returns rows which do not macht if using NLS_SORT='BINARY_AI'

Hi,
I have a table with a nvarchar column in Oracle Xe 11. Using a select with like rows are returned which do not match the like condition. E.g. 'CR_abc' LIKE 'CR,%' is true for NLS_SORT=BINARY_AI. For GERMAN_AI the condition is false!
Example to reproduce:
set LINESIZE 200
ALTER SESSION SET NLS_COMP='LINGUISTIC';
ALTER SESSION SET NLS_SORT='BINARY_AI';
CREATE TABLE "LIBFIELDS_CONFIGF"  ("id1" NVARCHAR2(254) NOT NULL ENABLE, "id2" VARCHAR2(254) NOT NULL ENABLE );
INSERT INTO "LIBFIELDS_CONFIGF" ("id1", "id2") VALUES ('CR_abc', 'CR_abc');
select "id1" from libfields_configf where "id1" like 'CR,%';
EXPLAIN PLAN FOR select "id1" from libfields_configf where "id1" like 'CR,%';
SELECT * FROM TABLE(dbms_xplan.display);
select "id2" from libfields_configf where "id2" like 'CR,%';
EXPLAIN PLAN FOR select "id2" from libfields_configf where "id2" like 'CR,%';
SELECT * FROM TABLE(dbms_xplan.display);
DROP TABLE libfields_configf;This does not work on the nvarchar column (plan output)
   1 - filter(NLSSORT("id1",'nls_sort=''BINARY_AI''')>=HEXTORAW('00630072002C00
              ')  AND NLSSORT("id1",'nls_sort=''BINARY_AI''')<HEXTORAW('63722D00') )This works correctly on the varchar column (plan output)
   1 - filter(NLSSORT("id2",'nls_sort=''BINARY_AI''')>=HEXTORAW('63722C00')
              AND NLSSORT("id2",'nls_sort=''BINARY_AI''')<HEXTORAW('63722D00') )Switching NLS_SORT to GERMAN_AI produces the correct result for both queries. Is there a fix for this available or do I missunderstand the behaviour of NLS_SORT for BINARY_AI and GERMAN_AI?
Thx Jürgen

I'm not totally clear on what you're trying to do, given the like 'CR,%' pattern match, given that the sample data has the wildcard '_' character in it.
And trying a few different NLS_COMP and SORT settings, I'm also seeing unexpected matching. You're probably more informed on the diacriticals and how they should sort and match for different locales, americanamerica.<charset> NLS settings don't distinguish much beyond an ASCII binary sort, i.e. does 'ü' precede or follow 'u', or maybe even precede 'ă' ... ?
A dump( <col>,16) can also help especially when nvarchar character values, and the unistr() to get a few more entries for comparison are helpful too:
insert into <table> values ( unistr('\00c7R_abc'),unistr('\00c7R_abc') ); -- capital C cedille
insert into <table> values ( unistr('\010dR_abc'),unistr('\010dR_abc') ); -- lower C caron
insert into <table> values ( unistr('\0106R_abc'),unistr('\0106R_abc') ); -- capital C acute
select "id1", "id2",dump( "id1", 16) as dump_id1, dump( "id2",16 ) as dump_id2 from <table> where "id1" like 'C%';
alter session set nls_sort = 'german_ci';
... <repeat select>
alter session set nls_sort = 'binary_ai';
... <repeat select>
alter session set nls_sort = 'binary';BTW, case sensitive column names are generally frowned upon, it makes for extra keystrokes as well as a possible source of confusion. Does one want the "Emp", "EMP", or "EmP" table, they should all be the same but won't be when double quoted.
Edited by: clcarter on Oct 20, 2011 6:52 PM
fix quoting

Similar Messages

  • How can I detect workbooks which are not longer in use?

    Hello togehter,
    I am looking for a way to detect BEX Workbooks which are not longer in use. Is there something in the BC which I can use for that?
    Best would be some query with the information of when and by whom a workbook gets called up last time.
    Thanks!
    Andreas

    Hi Edward,
    there is no key figure providing this information.
    First of all you got convert the 0CALDAY from Date to Number, therefore you got to configure a new variable (by replacement path) and put it into a formula.
    Use the result of this formula as a column and create a new TOP 1 condition on it.
    Now you will only get one row per Workbook/Query (or whatever you have chosen) with the date of the last use of it.
    Regards,
    Andreas

  • How do I get my bookmarks to display again in a column on the left of my screen, just as it always has and the way I like them. I do not want to use full screen display without the bookmarks showing.

    I have a full screen and cannot see my bookmarks.
    How do I get my bookmarks to display again in a column on the left of my screen, just as it always has and the way I like them. I do not want to use full screen display without the bookmarks showing.

    View > Sidebar > Bookmarks (Ctrl+B)
    Press F10 or tap the Alt key to bring up the "Menu Bar" temporarily.

  • BADI for VA01 which are not for internal use ???

    Hello Folks,
    Im looking for BADIs which are not for internal use for the transaction VA01...
    Could anyone send all the BADIS which can be implemented for VA01...
    Thanks in advance...
    Reddy

    Hi there, you are lucky enough because I have found them almost a few days ago:
    ---------- BADI for VA01 ----------
    A1) BADI
    BEFORE (choosing any ORDER: ....) :
      - BADI_SD_SALES
      - BADI_SD_SALES_BASIC
      - UKM_R3_ACTIVATE
      - BADI_LAYER
      - BADI_MATN1
    AFTER (choosing ORDER NR - xxxx -) :
      - ADDR_PRINTFORM_SHORT
      - BADI_SD_SALES_ITEM
      - BADI_IBASE_AUTHORITY
      - BADI_IBASE_IBCO
      - CU_CONFIG_DELEGATION
      - CUKO_PLANT_CHANGE
      - EHS_DG_002
      - SD_COND_ACCESS_A
      - BADI_SD_TO_FM
    AFTER CHANGING something in all items and shifting to TAB "item detail":
      - BADI_SD_DPBP
      - CFOP_DET_PREP
      - ADJUST_NET_DAYS
      - BADI_SD_SALES_ADDON
    AFTER CHANGING something again in all items and shifting to TABS:
      - CFOP_DET_PREP
    AFTER SAVING:
      - /SAPSLL/CTRL_SD0A_R3
      - QUANTITY_STRUCT_CK
      - DYNPRO_EXTENSION_CK
      - IBRT_GEN_ADD_IN
      - VALUATION_CK
      - WORKORDER_UPDATE
      - ATP_PUBLISH_RESULTS
      - FM_FYC_RECOVERY_POST
      - FMAVC_DECO
      - GM_POSTING_CONTROL
      - BADI_ISPS_GRANT
      - DIP_UPDATE_FKDAT
      - CACL_CHARACTER_INPUT
      - /SAPSLL/CTRL_SD0A_R3
      - /SAPSLL/RFC_DEST
      - /SAPSLL/CTRL_SD0A_R3
      - /SAPSLL/IFEX_SD0A_R3
      - /SAPSLL/KMAT
      - BADI_SD_UPDATE_PLVAL
      - CUX_ADD_IN
      - BOM_EXIT
      - WORKORDER_EXEC_STEPS
    In case you may need them...
    ---------- USER EXIT for VA01 ----------
    A2) USER EXIT for VA01 :
    SDAPO001  Activating Sourcing Subitem Quantity Propagation
    SDTRM001  Reschedule schedule lines without a new ATP check
    V45A0001  Determine alternative materials for product selection
    V45A0002  Predefine sold-to party in sales document
    V45A0003  Collector for customer function modulpool MV45A
    V45A0004  Copy packing proposal
    V45E0001  Update the purchase order from the sales order
    V45E0002  Data transfer in procurement elements (PRreq., assembly
    V45L0001  SD component supplier processing (customer enhancements
    V45P0001  SD customer function for cross-company code sales
    V45S0001  Update sales document from configuration
    V45S0003  MRP-relevance for incomplete configuration
    V45S0004  Effectivity type in sales order
    V45W0001  SD Service Management: Forward Contract Data to Item
    V46H0001  SD Customer functions for resource-related billing
    V60F0001  SD Billing plan (customer enhancement) diff. to billing
    A3) CLASSICAL USER-EXIT per VA01:
    --- include MV45AFZZ ---
    FORM userexit_delete_document.
    FORM userexit_field_modification.
    FORM userexit_move_field_to_vbak.
    FORM userexit_move_field_to_vbap.
    FORM userexit_move_field_to_vbep.
    FORM userexit_move_field_to_vbkd.
    FORM userexit_number_range USING us_r
    FORM userexit_pricing_prepare_tkomk.
    FORM userexit_pricing_prepare_tkomp.
    FORM userexit_read_document.
    FORM userexit_save_document.
    FORM userexit_save_document_prepare.
    Hope its enough
    Denis Mullaraj

  • How to findout rows which are not null ?

    Hi friends,
    Can anyone tell me how to find out the no of rows which is having full data in each column (not null) ?
    Ex:- TEST_TABLE having 1000 columns and lakes of rows.
    myQuestion:- I need to find the no of rows which are filled with 1000 columns filled with not null data.
    Thanks in Advacne.
    Kishore.

    Hello
    You're just going to have to write the query with IS NOT NULL on each column. This will help generate the predicates for the WHERE clause to save quite a bit of typing...
    SELECT
        ' AND '||column_name||' IS NOT NULL'
    FROM
        all_tab_columns
    WHERE
        table_name = 'TEST_TABLE'You can take the output and add that to
    SELECT COUNT(*) FROM test_table WHERE 1=1 HTH
    David

  • I just made my apple account today and when i tried hen i to install a app my email and my password didn't work it just said like '' this apple id has not yet been used before in itunes store''

    i just made my apple id today abut when i tried to install a app from my iphone it didn't work it just said  '' this apple id has not yet been used before in itunes store'' i hope u can help me ...thx

    If you haven't already created an account in the app store:
    Scroll down to the bottom of the FEATURED page touch APPLE ID and CREATE ACCOUNT
    If you have already created an account in the app store:
    First of all, double check you're spelling the password right.
    If you're sure it's not the password, scroll down to the bottom of the FEATURED page in the App Store on your iPhone, touch APPLE ID: and then VIEW ACCOUNT and make sure you have the correct card details and billing address on your account.
    Also, connect your iPhone to your computer, then log in to the iTunes store in iTunes on your computer and check all your details. After you've updated your details sync your iPhone.
    If you still can't get it to work, book an appointment with a genius at your nearest Apple Store. They should be able to solve whatever the problem is.

  • Table compare deleting rows which does not exist in target table

    Hi Gurus,
    I am struggling with an issue in Data Services.
    I have a job which uses Table Compare, then History Preserving and then a Key Generation transforms.
    There is every possibility that data would get deleted from the source table.
    Now, I want to delete them from the target table also.
    I tried Detect deleted rows but it is not working.
    Could some one please help me on this issue.
    Thanks,
    Raviteja.

    Doesn't history preserving really only operate on "Update" rows.  Wouldn't it only process the deletes if you turned the "Preserve Delete row(s) as update row(s)" on?
    I would think if you turned on Detect Delete rows in the Table compare and did not turn this on in the history preserving it would retain those rows as delete rows and effectively remove them from the target.
    Preserve delete row(s) as update row(s)
    Converts DELETE rows to UPDATE rows in the target warehouse and, if you previously set effective date values (Valid from and Valid to), sets the Valid To value to the execution date. Use this option to maintain slowly changing dimensions by feeding a complete data set first through the Table Comparison transform with its Detect deleted row(s) from comparison table
    option selected.

  • How to get a stored function return value (which is not a cursor)?

    I want to do so with ADO inside Visual Basic. I know how to call a stored procedure, but nothing I tried could help me in calling a stored function and getting its return code. Note that the function has no cursors within its argument or return code.
    Your quick response would be appreciated
    Eyal

    Eyal,
    A stored function returns a value. You need to have the first parameter (of correct data type) for the returned value. The parameter binding is pretty much the same as you would do with stored procedures.
    e.g. "begin :1= proc(....); end;"
    Sinclair

  • Query returning record even when not satisfying the where condition

    Hi,
    Below Query is returning value '1D' though it doesnt fall under the range '01' and '99'.
    I actually want to get the last 2 characters of the string and filter out if its not a number. Please help me.
    select * from (
    select substr('qwe1D',4) val from dual )
    where val between '01' and '99';
    Thanks
    Madhuri

    Sven W. wrote:
    Madhuri wrote:
    Hi,
    Below Query is returning value '1D' though it doesnt fall under the range '01' and '99'.
    I actually want to get the last 2 characters of the string and filter out if its not a number. Please help me.
    select * from (
    select substr('qwe1D',4) val from dual )
    where val between '01' and '99';
    Thanks
    MadhuriBut '1D' is between '01' and '99'. Simply because '1' is between '0' and '9'.
    One more example: '1111111' is also between '01' and '99'. This is how an string comparison works.
    To filter out strings that do not have numeric chars in them you can use several functions. regexp_substr/regexp_replace/translate/regexp_like etc.
    This might work:
    select * from (
    select substr('qwe1D',4) val from dual )
    where regexp_like(val,'\d{2}$');Edited by: Sven W. on Sep 27, 2012 12:35 PMThere is still one problem with this. It will return '00' which is not part of the original requirement. You have to add
    AND val != '00'

  • Which HttpClient class should I use for Universal apps?

    Hi,
    I am developing a Windows Universal app for Windows phone and WinRT in C# and I would like to know which HttpClient class should i use? Should I use the System.Net.HttpClient or Windows.Web.HttpClient?

    Because the System.Net.Http and System.Net.Http.Headers namespaces might not be available in future versions of Windows for use by Windows Store apps. It is stated in the official documentation on MSDN here:
    https://msdn.microsoft.com/en-us/library/windows/apps/xaml/dn469431.aspx
    "Starting with Windows 8.1 and Windows Server 2012 R2, use Windows.Web.Http.HttpClient in the Windows.Web.Http namespace and the related Windows.Web.Http.Headers and Windows.Web.Http.Filters namespaces instead for Windows Store apps."
    And the Windows.Web.Http.HttpClient class is supported from Windows Phone 8.1, Windows 8.1 and Windows Server 2012 R2:
    https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.web.http.httpclient.aspx
    Hope that helps.
    Please remember to close your threads by marking all helpful posts as answer and then start a new thread if you have a new question.

  • Is there any BI Dashboard view not allowed to use in BIP report?

    My customer wants to display BI Dashboard page on BI Publisher report.
    Is there any BI Dashboard view which is not allowed to use in BI Publisher report?
    Seem no summarized document for this, and then can I understand like “No related limit for BIP report”?

    Explore this page OBIEE - Presentation Variable System (reserved variable) | GerardNico.com (BI, OBIEE, OWB, DataWarehouse)

  • Interaction enabled on dimensional columns though not marked as Use for display

    Hi,
    I am facing issue with few of the dimensional columns in OBI 11g. Drill down property is enabled for few columns which are not marked as Use for Display or added to any hierarchy level.
    Clicking on these columns is drilling down to the next lower lever. we can avoid this by setting a system wide defaults but not allowed to do that.
    Any other suggestions to overcome the issue?
    Thanks,
    Vj

    Any dimensional attribute column residing on a higher level of aggregation will automatically render the drill-down to its next lower-level child.
    "Use for display" defines the attribute(s) displayed by default after a drill and is used to populate the property of the (default) displayed presentation column in a presentation hierarchy.
    So you are experiencing standard, desired behaviour. Removing that interaction will necessitate setting system-wide defaults.
    Cheers

  • Select query does not return rows

    Hi all,
    The following query does not returning rows even though values are there in table.
    Kindly let me know why it is creating problem.
    thanks, P Prakash
    /* Formatted on 2011/05/11 16:44 (Formatter Plus v4.8.8) */
    SELECT pr.pa_rqst_sid, ptr.sbmtr_trnsctn_idntfr, ptr.athrztn_infrmtn,
    DECODE (ou.org_unit_name,
    'PA - MDCH', (SELECT property_value
    FROM hipaa_system_defaults
    WHERE property_name = 'RECEIVER_ID_1_PA'),
    'PA - MPRO', (SELECT property_value
    FROM hipaa_system_defaults
    WHERE property_name = 'RECEIVER_ID_2_PA'),
    'PA - DEFAULT', (SELECT property_value
    FROM hipaa_system_defaults
    WHERE property_name = 'RECEIVER_ID_1_PA'),
    NULL
    ) AS intrchng_sndr_idntfr,
    ptr.intrchng_sndr_idntfr AS intrchng_rcvr_idntfr, ptr.usg_indctr,
    ptr.intrchng_sndr_idntfr AS applctn_rcvr_code,
    ptr.trnsctn_set_cntrl_nmbr AS trnsctn_set_cntrl_nmbr,
    ptr.athrztn_infrmtn_qlfr AS athrztn_infrmtn_qlfr,
    ptr.scrty_infrmtn_qlfr AS scrty_infrmtn_qlfr,
    ptr.scrty_infrmtn AS scrty_infrmtn,
    ptr.intrchng_sndr_idntfr_qlfr AS intrchng_sndr_idntfr_qlfr,
    ptr.intrchng_rcvr_idntfr_qlfr AS intrchng_rcvr_idntfr_qlfr,
    ptr.intrchng_cntrl_stndrds_idntfr AS intrchng_cntrl_stndrds_idntfr,
    ptr.intrchng_cntrl_vrsn_nmbr AS intrchng_cntrl_vrsn_nmbr,
    ptr.intrchng_cntrl_nmbr AS intrchng_cntrl_nmbr,
    ptr.acknwldgmnt_rqstd_indctr AS acknwldgmnt_rqstd_indctr,
    ptr.cmpnt_elmnt_sprtr AS cmpnt_elmnt_sprtr,
    ptr.fnctnl_idntfr_code AS fnctnl_idntfr_code,
    ptr.grp_cntrl_nmbr AS grp_cntrl_nmbr,
    ptr.rspnsbl_agncy_code AS rspnsbl_agncy_code,
    ptr.vrsn_rls_indstry_idntfr_code AS vrsn_rls_indstry_idntfr_code
    FROM pa_request pr, pa_transaction_request ptr, org_unit ou
    WHERE ptr.pa_trnsctn_rqst_sid = pr.pa_trnsctn_rqst_sid
    AND pr.org_unit_sid = ou.org_unit_sid
    AND pr.oprtnl_flag = 'A'
    AND ptr.oprtnl_flag = 'A'
    AND ou.oprtnl_flag = 'A'
    AND pr.pa_mode_type_lkpcd = 'BT'
    AND (pr.status_cid = 86 OR pr.status_cid IN
    (20, 70, 30, 80, 25, 101, 96)
    AND pr.pa_rqst_sid = 75006271
    ORDER BY pr.pa_rqst_sid;
    the query is not giving result for this particular request sid.75006271 is present in table.

    833560 wrote:
    Hi all,
    The following query does not returning rows even though values are there in table.
    Kindly let me know why it is creating problem.
    thanks, P Prakash
    /* Formatted on 2011/05/11 16:44 (Formatter Plus v4.8.8) */
    SELECT pr.pa_rqst_sid, ptr.sbmtr_trnsctn_idntfr, ptr.athrztn_infrmtn,
    DECODE (ou.org_unit_name,
    'PA - MDCH', (SELECT property_value
    FROM hipaa_system_defaults
    WHERE property_name = 'RECEIVER_ID_1_PA'),
    'PA - MPRO', (SELECT property_value
    FROM hipaa_system_defaults
    WHERE property_name = 'RECEIVER_ID_2_PA'),
    'PA - DEFAULT', (SELECT property_value
    FROM hipaa_system_defaults
    WHERE property_name = 'RECEIVER_ID_1_PA'),
    NULL
    ) AS intrchng_sndr_idntfr,
    ptr.intrchng_sndr_idntfr AS intrchng_rcvr_idntfr, ptr.usg_indctr,
    ptr.intrchng_sndr_idntfr AS applctn_rcvr_code,
    ptr.trnsctn_set_cntrl_nmbr AS trnsctn_set_cntrl_nmbr,
    ptr.athrztn_infrmtn_qlfr AS athrztn_infrmtn_qlfr,
    ptr.scrty_infrmtn_qlfr AS scrty_infrmtn_qlfr,
    ptr.scrty_infrmtn AS scrty_infrmtn,
    ptr.intrchng_sndr_idntfr_qlfr AS intrchng_sndr_idntfr_qlfr,
    ptr.intrchng_rcvr_idntfr_qlfr AS intrchng_rcvr_idntfr_qlfr,
    ptr.intrchng_cntrl_stndrds_idntfr AS intrchng_cntrl_stndrds_idntfr,
    ptr.intrchng_cntrl_vrsn_nmbr AS intrchng_cntrl_vrsn_nmbr,
    ptr.intrchng_cntrl_nmbr AS intrchng_cntrl_nmbr,
    ptr.acknwldgmnt_rqstd_indctr AS acknwldgmnt_rqstd_indctr,
    ptr.cmpnt_elmnt_sprtr AS cmpnt_elmnt_sprtr,
    ptr.fnctnl_idntfr_code AS fnctnl_idntfr_code,
    ptr.grp_cntrl_nmbr AS grp_cntrl_nmbr,
    ptr.rspnsbl_agncy_code AS rspnsbl_agncy_code,
    ptr.vrsn_rls_indstry_idntfr_code AS vrsn_rls_indstry_idntfr_code
    FROM pa_request pr, pa_transaction_request ptr, org_unit ou
    WHERE ptr.pa_trnsctn_rqst_sid = pr.pa_trnsctn_rqst_sid
    AND pr.org_unit_sid = ou.org_unit_sid
    AND pr.oprtnl_flag = 'A'
    AND ptr.oprtnl_flag = 'A'
    AND ou.oprtnl_flag = 'A'
    AND pr.pa_mode_type_lkpcd = 'BT'
    AND (pr.status_cid = 86 OR pr.status_cid IN
    (20, 70, 30, 80, 25, 101, 96)
    AND pr.pa_rqst_sid = 75006271
    ORDER BY pr.pa_rqst_sid;
    Hi,
    Its very difficult to analyse the query without any data being provided. So I suggest you to debug the above query by keeping basic join condition intact and comment out all the other where conditions for initial run.
    FROM pa_request pr, pa_transaction_request ptr, org_unit ou
    WHERE ptr.pa_trnsctn_rqst_sid = pr.pa_trnsctn_rqst_sid
    --AND pr.org_unit_sid = ou.org_unit_sid
    --AND pr.oprtnl_flag = 'A'
    --AND ptr.oprtnl_flag = 'A'
    --AND ou.oprtnl_flag = 'A'
    --AND pr.pa_mode_type_lkpcd = 'BT'
    --AND (pr.status_cid = 86 OR pr.status_cid IN
    (20, 70, 30, 80, 25, 101, 96)
    --AND pr.pa_rqst_sid = 75006271If if you have given join conditions proper and if data exists ,you can see set of rows displayed.
    Next step is to keep on uncommenting each of the where condition
    AND pr.oprtnl_flag = 'A'Like this you 'll come to the condition which does not match your requirement
    Hope this helps
    Regards,
    Achyut

  • Is the order in which a UNION ALL query returns rows guaranteed?

    Guys
    I'm doing a kind of query where I want to return matching rows in a priority order and take the first one. THink of it as getting the most specific error message for a particular context.
    SELECT * FROM (
    SELECT msg FROM errormessages WHERE device = 'x'
    UNION ALL
    SELECT msg FROM errormessages WHERE client = 'y'
    UNION ALL
    SELECT msg FROM (SELECT msg from errormessages WHERE class LIKE 'generic_' ORDER BY class)
    UNION ALL
    SELECT 'missing error message' FROM dual
    WHERE ROWNUM =1
    If UNION ALL is guaranteed to return rows in this order, great. If not, would it be better to have:
    SELECT * FROM ( SELECT * FROM(
    SELECT 1 as ord, msg FROM errormessages WHERE device = 'x'
    UNION ALL
    SELECT 2, msg FROM errormessages WHERE client = 'y'
    UNION ALL
    SELECT 4+SUBSTR(class, 7, 1), msg FROM errormessages WHERE class LIKE 'generic_'
    UNION ALL
    SELECT 9999, 'missing error message' FROM dual
    ) ORDER BY ord )
    WHERE ROWNUM =1Or, another option:
    SELECT msg FROM(
    SELECT
      CASE
        WHEN device = 'x' THEN 1
        WHEN client = 'y' THEN 2
        WHEN class LIKE 'generic_' THEN 4+SUBSTR(class, 7, 1)
      END as ord, msg
    FROM (
      SELECT * FROM errormessages WHERE device = 'x' OR  client = 'y' OR class LIKE 'generic_'
      UNION ALL
      SELECT 999, 'missing error' FROM dual
    ) ORDER BY ord
    )WHERE ROWNUM =1As you can see there is a complication in the generic; devices may advertise that they accept 1,2,3 or 4 lines of info, so I want to use the advertised capabiltiy to pick the most relevant message from the generic set if no specifics exist for the device or the client
    Which was would you go?
    Cheers
    Edited by: charred on Feb 11, 2009 4:56 AM - code tags

    charred wrote:
    So tell me guys, do I go for:
    4 queries unioned together
    or
    1 query with 4 ORs in the where clause and a case when to determine priority?It will depend on your conditions, but if you look at your explain plans you should get an idea for which is the better one; typically I would expect this to be the OR method...
    SQL> select * from emp where deptno = 20
      2  union all
      3  select * from emp where job = 'CLERK'
      4  union all
      5  select * from emp where sal > 2500;
    Execution Plan
    Plan hash value: 3153085224
    | Id  | Operation                    | Name     | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT             |          |    14 |   546 |     8  (75)| 00:00:01 |
    |   1 |  UNION-ALL                   |          |       |       |            |          |
    |   2 |   TABLE ACCESS BY INDEX ROWID| EMP      |     5 |   195 |     2   (0)| 00:00:01 |
    |*  3 |    INDEX RANGE SCAN          | DEPT_IDX |     5 |       |     1   (0)| 00:00:01 |
    |*  4 |   TABLE ACCESS FULL          | EMP      |     4 |   156 |     3   (0)| 00:00:01 |
    |*  5 |   TABLE ACCESS FULL          | EMP      |     5 |   195 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       3 - access("DEPTNO"=20)
       4 - filter("JOB"='CLERK')
       5 - filter("SAL">2500)
    Statistics
              1  recursive calls
              0  db block gets
             18  consistent gets
              1  physical reads
              0  redo size
           1328  bytes sent via SQL*Net to client
            396  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
             14  rows processed
    SQL> select * from emp
      2  where deptno = 20 or job = 'CLERK' or sal > 2500;
    Execution Plan
    Plan hash value: 3956160932
    | Id  | Operation         | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT  |      |    10 |   390 |     3   (0)| 00:00:01 |
    |*  1 |  TABLE ACCESS FULL| EMP  |    10 |   390 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - filter("DEPTNO"=20 OR "SAL">2500 OR "JOB"='CLERK')
    Statistics
              1  recursive calls
              0  db block gets
              8  consistent gets
              0  physical reads
              0  redo size
           1146  bytes sent via SQL*Net to client
            396  bytes received via SQL*Net from client
              2  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
              9  rows processed
    SQL>

  • Query not returning rows (nvl)

    Hi all, I was wondering if anyone could help
    I have a query :
    select a, b, c, d, e from table_t
    where a=nvl(:para, a)
    and b=nvl(:parb,b)
    and c=nvl(:parc,c)
    the problem is is one the rows contain a null, then that row is not returned. I would like to return all rows along with the null values.
    for example:
    row 1 has b= null then row 1 is not displayed but only the rest of the rows where b is not null are displayed
    DB version 11.1.0.6.0 g
    All help will be appreciated.
    Kind regards,
    Cleopatra

    Hi, Cleo,
    Cleopatra wrote:
    Hi Frank ,
    thanks for the reply
    I get all the rows displayed now, but the filters do not seem to work for para, parb and parc.
    Any ideas how I could get that?Before moving on to other ideas, let's try the ideas I already mentioned:
    Frank Kulash wrote:
    ... post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data. Make sure the data shows special situations you care about, for example, if a is NULL, but :para is not NULL.
    Explain, using specific examples, how you get those results from that data.
    In problems like this, it often helps to know if there are impossible values for any of the columns. For example, if a is a DATE, it could be helpful to know if all dates stored in the table are after the year 1000, or, if b is a NUMBER, that it is always in the range -100 to +100.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ {message:id=9360002}If the problem includes parameters (such as :para and :parb), then post a few sets of parameters and the results you want from the same sample data for each set.
    Simplify the problem if you can. For example, instead of comparing 3 columns to 3 paramaeters, could you illustrate the problem just as well with 2 columns and 2 parameters, or even 1 column and 1 parameter?

Maybe you are looking for