SUBSTR function working only in SQL developper?

Hello,
I type the following query based on what I am learning in terms of Single-row Functions and it seems to work in SQL developer but for some reason not in SQL Plus ? Can anyone tell me where i am going wrong?
Select Job_title,
SUBSTR(Job_title, 1, 10)
SUBSTR(Job_Title, 11)
from jobs;
This is just to test the function's abilities and to see what it does but I was wondering as to why it doesn't work on the SQL plus prompt. Any help would be greatly appreciated.
Thank you

Vlakarmis wrote:
Hello,
I type the following query based on what I am learning in terms of Single-row Functions and it seems to work in SQL developer but for some reason not in SQL Plus ? Can anyone tell me where i am going wrong?
Select Job_title,
SUBSTR(Job_title, 1, 10)
SUBSTR(Job_Title, 11)
from jobs;
This is just to test the function's abilities and to see what it does but I was wondering as to why it doesn't work on the SQL plus prompt. Any help would be greatly appreciated.
Thank you"Doesn't work" is not an actionable error message.
Please use copy and paste - copy your entire sqlplus session - full sqlstatement and full response, and post back here. If it returns many rows, we don't need to see all of them, just a representative sample.

Similar Messages

  • I have loaded Lion on my MacBook and the new trackpad functions work only on one ordinary account or user and not on the admin account. The trackpad preferences are well set. What can I do?

    I have loaded Lion on my MacBook and the new trackpad functions work only on one ordinary account or user and not on the admin account. The trackpad preferences are well set. What can I do?

    iCloud should still help you reduce some hard drive space. Just select "optimize" in the icloud tab in Mac Photo App preferences.
    Granted, not the same as completely offloading your library to a back-up drive at your location.
    Good Luck!

  • Substr function in CTL file of sqlloader

    Hi gurus,
    I am using sql loader to load the data from text file to oracle table.
    I have 2 columns in the input data, which are of more size than their corresponding destination table column sizes.
    I am using substr() function in the control file, but it is failing for some records in 2 scenarios, details given below.
    First scenario:
    destination table column size is 250 characters.
    substr() function works fine when the source data is less than 255 characters, but when it is more than 255 characters, the record is getting rejected as bad record.
    eg: if the source data is of 254 characters, only 250 chars are inserted in the table, but if the size is 256, record is not inserted in the table.
    Here is the syntax i am using
    ENQUIRY "SUBSTR(:ENQUIRY, 0, 250)",
    Second scenario:
    destination table column size is 2000 characters.
    substr() function works fine when the source data is upto 2000 characters, but when it is more than 2000 characters, the record is getting rejected as bad record.
    Here is the syntax i am using
    ANSWER CHAR(2000) "SUBSTR(:ANSWER, 0, 2000)",
    Please suggest.
    Thanks,

    odie_63 wrote:
    Hi,
    Try with specifying a larger size limit for both columns :
    ENQUIRY CHAR(4000) "SUBSTR(:ENQUIRY, 0, 250)",        
    ANSWER  CHAR(4000) "SUBSTR(:ANSWER, 0, 2000)"
    Will the substr work with a starting offset of 0 ? Doesn't substr uses 1 as the first character position? or it is different with sqlloader?
    Okay I checked, It works just like if the offset is given as one. Perfect.
    SQL> select substr('ABCDEF',0,3) from dual;
    SUB
    ABCThanks odie_63. :)
    Edited by: zahid79 on Jul 23, 2010 5:20 PM
    Edited by: zahid79 on Jul 23, 2010 5:22 PM

  • Substr function not working in coldfusion sql

    Hi all,
    I am using coldfusion 7.0.2 with oracle 10g. I've the
    following simple query
    select substr(colname,1,3) from tablename
    this query works fine if i run it using TOAD or SQLPLUS but
    when i run this query in coldfusion script i get the following
    error
    [Table (rows 9 columns SUBSTR(colname,1,3)):
    [SUBSTR(colname,1,3): coldfusion.sql.QueryColumn@fc7be7] ] is not
    indexable by SUBSTR(colname
    can anybody tell me why it doesn't work in coldfusion but
    works fine in sqlplus?
    thank you

    There's no such thing as "coldfusion sql" (sic). Everything
    between the
    <cfquery> tags is simply resolved (ie: CF runtime
    statements between
    pound-signs) and passed straight to the DB drivers, and
    thence to the DB
    itself. CF does no SQL processing at all.
    Your error kind of suggests a syntac error AFTER the query
    has been
    executed though.
    Could you post some code, and point out which precise line is
    erroring?
    Adam

  • Substring Function is not working

    Hi All
    I am using substring function like below
    SUBSTRING("Year"."Quarter" FROM 3 FOR 7) and its working,
    but when I add any computed column like aany measure column from fact then it will show the error.
    My datasoyrce is Essbse
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    +State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 42043] An external aggregate is found in an outer query block. (HY000)+
    SQL Issued: SELECT SUBSTRING("Year"."Quarter" FROM 3 FOR 7) saw_0, Market.State saw_1, CCoA.Assets saw_2 FROM localhost ORDER BY saw_0, saw_1_
    Thanks to all for reply for previous questions
    Hitesh
    Edited by: user13805575 on Feb 24, 2011 10:47 AM

    Hi,
    try this.
    SUBSTRING(cast(measure as char) FROM 3 FOR 7)Please ignore........

  • Authentication function not working in APEX but works in pl/sql

    Greetings, Jim here.
    I have written a very simple authentication funtion which uses the dbms_ldap package to authenticate using the userid and password from the login page.
    I've tested this function thru pl/sql and it returns true and false accordingly.
    I've created a custom authentication schema and in the authentication function I have return myfunction;
    The problem is, when called thru APEX, it appears to always return true and lets the login proceed, even if the password is correct. I know its using the function due to the fact that if I enter a bogus function as the authentication function, APEX spits up a message saying so.
    So, I know the function works, but I don't know why it does not work with APEX. Posting function below.
    CREATE OR REPLACE FUNCTION ODBS.CUSTAPEXLOGIN (p_username IN VARCHAR2,p_password IN VARCHAR2)
    RETURN BOOLEAN AS
    retval PLS_INTEGER;
    emp_session DBMS_LDAP.session;
    ldap_host VARCHAR2(256);
    ldap_port VARCHAR2(256);
    ldap_user VARCHAR2(256);
    ldap_passwd VARCHAR2(256);
    ldap_base VARCHAR2(256);
    BEGIN
    ldap_host := 'oraldap';
    ldap_port := '389';
    ldap_user := p_username;
    ldap_passwd := p_password;
    ldap_base := 'cn=users,dc=company,dc=com';
    emp_session := DBMS_LDAP.init(ldap_host,ldap_port);
    retval := DBMS_LDAP.simple_bind_s(emp_session,('cn=' || ldap_user || ',' || ldap_base),ldap_passwd);
    if retval = 0 then
    return true;
    else
    return false;
    end if;
    EXCEPTION
    WHEN OTHERS THEN
    begin
    if sqlcode = -31202 then
    return false;
    end if;
    end;
    END;
    /

    Hi Jim,
    Can you clarify this -
    The problem is, when called thru APEX, it appears to always return true and lets the login >proceed, even if the password is correctThat implies you're saying your authentication function ALWAYS returns true? Is that correct? Also 'even if the password is correct' doesn't read correctly to me, did you mean 'even if the password is incorrect'?
    You then say -
    now the function works, but I don't know why it does not work with APEX.So by 'does not work' you mean in APEX it is always returning true therefore allowing you to login regardless of the username/password you use? Is that correct?

  • Function Module working only in debug mode

    Hi all,
    The following Function Module works only in debug mode. The purpose of this FM is to create a notification and to put it in progress status. If I put a breakpoint before "CALL FUNCTION 'BAPI_ALM_NOTIF_PUTINPROGRESS'" it works. If I execute this FM without putting a breakpoint at that place it creates the notification but doesnt put it in progress status.
    In other words, the last BAPI call doesnot work if I dont put a breakpoint before.
    Can somebody help me to find out where is the problem?
    Thanks,
    Younes
    FUNCTION ZFM_CREATE_NOTIF_IN_PROCESS.
    ""Local interface:
    *"  IMPORTING
    *"     VALUE(NOTIFTYP) TYPE  CHAR2
    *"     VALUE(NOTIFHEADER) TYPE  BAPI2080_NOTHDRI
    *"  EXPORTING
    *"     VALUE(NOTIFNUMBER) TYPE  CHAR12
    *"     VALUE(NOTIFCURSTATUS) TYPE  CHAR40
    DATA: gs_bapi2080_nothdre TYPE bapi2080_nothdre,
          gt_return TYPE TABLE OF bapiret2.
    The notification is created with a temporary number
    CALL FUNCTION 'BAPI_ALM_NOTIF_CREATE'
      EXPORTING
        notif_type         = NOTIFTYP
        notifheader        = NOTIFHEADER
      IMPORTING
        notifheader_export = gs_bapi2080_nothdre
      TABLES
        return             = gt_return.
    READ TABLE gt_return TRANSPORTING NO FIELDS WITH KEY type = 'E'.
    CHECK sy-subrc IS NOT INITIAL.
    *The notication will be saved with a number which isnt temporary
    CALL FUNCTION 'BAPI_ALM_NOTIF_SAVE'
      EXPORTING
        number      = gs_bapi2080_nothdre-notif_no
      IMPORTING
        notifheader = gs_bapi2080_nothdre
      TABLES
        return      = gt_return.
    READ TABLE gt_return TRANSPORTING NO FIELDS WITH KEY type = 'E'.
    CHECK sy-subrc IS NOT INITIAL.
    CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'.
    The Notif is already created, it will be put in progress status
    NOTIFNUMBER = gs_bapi2080_nothdre-notif_no.
       CALL FUNCTION 'BAPI_ALM_NOTIF_PUTINPROGRESS'
            EXPORTING
              NUMBER             = NOTIFNUMBER
              LANGU              = SY-LANGU
           IMPORTING
             SYSTEMSTATUS       = NOTIFCURSTATUS
           TABLES
             RETURN             = gt_return.

    Hi Emmanuel,
    Now I get your problem: you want to wait to have the commit finished! The call to BAPI_TRANSACTION_COMMIT has an optional parameter 'WAIT' which is space by default which causes only a commit. When you set this parameter to 'X' it will do a commit work and wait.
    This should solve your problem!
    Regards,
    John.

  • Convert substring function from SQL Server to Oracle

    I am converting a large application written for SQL Server to Oracle and have encountered a difference in how the substring function is called between the two database systems.
    In SQL Server:
    select substring('xyz'1,2)
    In Oracle:
    select substr('xyz',1,2)
    Is there a way to establish a user-defined operator to map the substring call to a substr call so I don't have to change the application code?
    Is the user-defined function a way to do this?
    Which is better?

    If you want to be able to use the code that has substring in it, without modifying it, and have it do the same thing as substr, then try running the script below. It will create a user-defined function named substring that will cause substring to act like substr.
    CREATE OR REPLACE FUNCTION substring
    (p_string IN VARCHAR2,
    p_start IN VARCHAR2,
    p_end IN VARCHAR2 DEFAULT NULL)
    RETURN VARCHAR2
    IS
    v_string VARCHAR2 (100);
    BEGIN
    IF p_end IS NULL
    THEN
    SELECT SUBSTR (p_string, p_start)
    INTO v_string
    FROM DUAL;
    ELSE
    SELECT SUBSTR (p_string, p_start, p_end)
    INTO v_string
    FROM DUAL;
    END IF;
    RETURN v_string;
    END substring;
    null

  • Only some functions work with new CS5 install

    I just installed CS5 and was checking to see what had changed from the CS3 I used to use. So I opened a new document, drew a rectangle, and tried to change the stroke. When I use the Stroke pallet I cannot access either the weight or the type adjustments...either the up/down arrows, the pull-downs, or my typing in the box. Same for the toolbar buttons.
    I can create a text box like normal but I can only change type characteristics using shortcut keys, not the buttons on the toolbars.
    These are pretty basic IND functions.
    Has anyone else suffered a similar install where only about half of the functions work?

    I dunno if I qualify for "geezer" but I sure would like some larger fonts so I can get a better look at my large fonts:
    The worst part is that yes, this is legible Chinese text, technically speaking. But a fix for ye olde Aero bug would save me a great deal of eyestrain.

  • Substring function not working in Analytical view

    Dear All,
    I am trying to use substring function in my analytical view .It says valid expression during syntax check but getting activation error.
    thanks
    Sourav

    Hi Krishna,
    This is Kiran, I am trying to restrict a (string) filed value by removing the spaces and wring to calculated column field in an Analytical view for position 6 - 10.
    Example: Field name XYZ (Values showing as: ASDFG GETVALUENW  2345) --> (data type :22 VARCHAR)
    Output Value must be : GETVALUENW (which is 10 characters, from position 6 after trimming)
    Please advice which function use and how to apply the syntax
    Your inputs are highly appreciated.
    Thanks
    Kiran.

  • SUBSTR function in the where clause

    HI
    I want to get a number of 15 digits from a column where the user only know the last 10 digits.
    So that when the user enter a number with 10 digits, only the record of that specific number should be displayed.
    And then when the user did not enter any number all the records in the table should be displayed.(this part works fine)
    The problem is: when the user enters any last digits( last, second last, thirth last and so on) the records which satisfy this are retrieved, which is not supose to be the case.
    I' am trying to use the substr function in the where clause but I'm not sure if it's working or not becasue the result of the query is just the same as before i used the substr.
    Thanks

    better to pad with '*' me thinks in case u have a number ending with 0's:
      1  select empno,ename
      2  from emp
      3* where empno like '%'||lpad('&1',2,'*')
    SQL> /
    Enter value for 1: 0
    old   3: where empno like '%'||lpad('&1',2,'*')
    new   3: where empno like '%'||lpad('0',2,'*')
    no rows selected
    SQL> /
    Enter value for 1: 00
    old   3: where empno like '%'||lpad('&1',2,'*')
    new   3: where empno like '%'||lpad('00',2,'*')
         EMPNO ENAME
          7900 JAMES
    SQL> /
    Enter value for 1:
    old   3: where empno like '%'||lpad('&1',2,'*')
    new   3: where empno like '%'||lpad('',2,'*')
         EMPNO ENAME
          7369 SMITH
          7499 ALLEN
          7521 WARD
          7566 JONES
          7654 MARTIN
          7698 BLAKE
          7782 CLARK
          7788 SCOTT
          7839 KING
          7844 TURNER
          7876 ADAMS
         EMPNO ENAME
          7900 JAMES
          7902 FORD
          7934 MILLER
    14 rows selected.

  • Substring, comparasion operatins usng PL/SQL

    i just need to know how to operate substring functions using PL/SQL. For instance, assume that i have strings such as 1000YTL, 200YTL, 3000YTL. What i need to cut the letters(YTL) ang get the numeric values and select mix and max of the numeric values. Here is my procedure
    create or replace procedure Ihale_GettheMaxOrMin(v_ihlkodu in ihale_katilimcilar.ihlkodu%TYPE, outminval out number)
    is
    cursor cur is
    select statement;
    begin
    OPEN cur;
    LOOP
    FETCH cur INTO maybe_an_array;
    EXIT WHEN cur%NOTFOUND;
    //substring and comparasion operations to get the mix or max and assign it to the out parameter...
    END LOOP;
    CLOSE cur;
    end Ihale_GettheMaxOrMin;

    like this ?
    SQL> select replace('1000YTL', 'YTL') from dual;
    REPL
    1000
    Hi there,
    That will only work if you know that there are always going to be 3 chars and you know what the characters are. You would be safer to use the TRANSLATE function to remove all possible characters you do not need e.g.
    SQL> SELECT '>>'||TRANSLATE( UPPER ('1000YTL'), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',' ')||'<<'
    2 from dual
    3 ;
    '>>'||TR
    1000<<SQL>
    I've added the >> and << to show that you get just the number and nothing else.
    This will remove all the letters of the alphabet so you don't care what those letters are. If there may be other characters in the string then simply add them to the list of those to translate to ''
    Mark

  • How to test a simple PL SQL function from another PL SQL script

    Hi,
    I have created a function. Now i need to test that whether it is returning the correct values or not.
    For that, i have written anothe pl sql script and trying to call this function. Im passing all the IN parameters in that function. I assume here that OUT parameters will provide me the result. Im trying to display the OUT parameter one by one to see my result.
    I'm using toad as sql client here connected with oracle.
    pl sql script:-
    DECLARE
    BEGIN
         DBMS_OUTPUT.PUT_LINE('$$$$$$$ VINOD KUMAR NAIR $$$$$$$');
         FETCH_ORDER_PRODUCT_DATA(320171302, 1006, 6999,
    ODNumber OUT VARCHAR2, Line_Number OUT VARCHAR2,
    ServiceID OUT VARCHAR2, BilltoNumber OUT VARCHAR2,
    AnnualPrice OUT NUMBER, CoverageCode OUT VARCHAR2)
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | ODNumber );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | Line_Number );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | ServiceID );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | BilltoNumber );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | AnnualPrice );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | CoverageCode );
    END;
    Function:-
    Program Name : SPOT_Order_Product_Data_For_CFS.sql
    Description : Function to Validate parameters from CFS
    By : Vinod Kumar
    Date : 08/19/2011
    Modification History
    By When TAR Description
    CREATE OR REPLACE FUNCTION FETCH_ORDER_PRODUCT_DATA(orderNumber IN VARCHAR2, customerNumber IN VARCHAR2,
    productLine IN VARCHAR2, ODNumber OUT VARCHAR2,
    Line_Number OUT VARCHAR2, ServiceID OUT VARCHAR2,
    BilltoNumber OUT VARCHAR2, AnnualPrice OUT NUMBER,
    CoverageCode OUT VARCHAR2)
    RETURN VARCHAR2 IS
    lv_err_msg VARCHAR2(100) := '';
    lv_bucket_id VARCHAR2(14);
    lv_bill_number VARCHAR2(30);
    lv_anual_price NUMBER;
    lv_coverage_code VARCHAR2(8);
    lv_quote_num NUMBER(10) := NULL;
    lv_line_num NUMBER(5) := 0;
    lv_customer_number VARCHAR2(30) := customerNumber;
    lv_product_id VARCHAR2(14) := productLine;
    lv_count_quote NUMBER := 0;
    lv_quote_status VARCHAR2(5);
    lv_quote_version NUMBER(2):=0;
    BEGIN
    IF INSTR(orderNumber, '-') = 0 THEN
    lv_quote_num := orderNumber;
    ELSE
    lv_quote_num := SPT_Delimiter(orderNumber, 1, '-');
    lv_line_num := SPT_Delimiter(orderNumber, 2, '-');
    END IF;
    --Check status of the quote COM, APP
    SELECT COUNT(*) INTO lv_count_quote FROM sot_order_header WHERE ORDER_NUMBER=lv_quote_num
    AND ORDER_STATUS IN ('APP', 'COM') AND CUSTOMER_NUMBER = lv_customer_number;
    IF lv_count_quote = 0 THEN
    lv_err_msg := 'Invalid Order number';
    RETURN lv_err_msg;
    END IF;
    -- Fetch the latest version on SPOT quote
    SELECT MAX(VERSION_NUMBER) INTO lv_quote_version FROM SPT_QUOTE_HEADER WHERE QUOTE_NUMBER = lv_quote_num
    AND CUSTOMER_NUMBER = lv_customer_number;
    -- If quote is valid fetch the data in OUT parameters
    IF lv_line_num = 0 THEN
    BEGIN
    SELECT a.CUSTOMER_BILLTO_NUMBER,
    b.LINE_NUMBER, b.BUCKET_ID,
    b.ANNUAL_REF_RATE_USD, b.COVERAGE_CODE
    INTO lv_bill_number,lv_line_num,lv_bucket_id,lv_anual_price,lv_coverage_code
    FROM SPT_QUOTE_HEADER a, SPT_QUOTE_LINE b
    WHERE a.QUOTE_NUMBER = lv_quote_num
    AND a.CUSTOMER_NUMBER = lv_customer_number
    AND a.VERSION_NUMBER = lv_quote_version
    AND a.QUOTE_NUMBER = b.QUOTE_NUMBER
    AND a.VERSION_NUMBER = b.VERSION_NUMBER
    AND b.PRODUCT_ID = lv_product_id;
    ODNumber := lv_quote_num;
    BilltoNumber := lv_bill_number;
    Line_Number := lv_line_num;
    ServiceID := lv_bucket_id;
    AnnualPrice := lv_anual_price;
    CoverageCode := lv_coverage_code;
    RETURN '';
    EXCEPTION WHEN OTHERS THEN
    lv_err_msg := 'Multiple PIDs existing in the SPOT order, please provide the SPOT order + line number as input data';
    RETURN lv_err_msg;
    END;
    ELSE
    BEGIN
    SELECT a.CUSTOMER_BILLTO_NUMBER,
    b.BUCKET_ID, b.ANNUAL_REF_RATE_USD,
    b.COVERAGE_CODE
    INTO lv_bill_number,lv_bucket_id,lv_anual_price,lv_coverage_code
    FROM SPT_QUOTE_HEADER a, SPT_QUOTE_LINE b
    WHERE a.QUOTE_NUMBER = lv_quote_num
    AND a.CUSTOMER_NUMBER = lv_customer_number
    AND a.VERSION_NUMBER = lv_quote_version
    AND a.QUOTE_NUMBER = b.QUOTE_NUMBER
    AND a.VERSION_NUMBER = b.VERSION_NUMBER
    AND b.PRODUCT_ID = lv_product_id
    AND b.LINE_NUMBER = lv_line_num;
    ODNumber := lv_quote_num;
    BilltoNumber := lv_bill_number;
    Line_Number := lv_line_num;
    ServiceID := lv_bucket_id;
    AnnualPrice := lv_anual_price;
    CoverageCode := lv_coverage_code;
    RETURN '';
    EXCEPTION WHEN OTHERS THEN
              lv_err_msg := 'Multiple SPOT lines exist with same parameter';
              RETURN lv_err_msg;
    END;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    lv_err_msg := '@@@ EXCEPTION THROWN @@@ '|| SUBSTR(SQLERRM,1,120);
    RETURN lv_err_msg ;
    END;
    Don't look at the function, it might have errors but my primary concern is how to test this function. Once I start doing its testing then only i can understand any bugs(if any).
    My pl sql is not so good. Im still learning. I don't understand IN and OUT parameters are.
    I just know that IN parameters r those whick we pass in to the function wen we call it and OUT parameters are those through which we get the result.
    Thanks in advance
    Vinod Kumar Nair

    20100511 wrote:
    I wondered how I could test the output of the function from within TOAD?I usually create the following function in my developer schema:
    create or replace function BoolToChar( b boolean ) return varchar2 is
    begin
      if b then
        return( 'TRUE' );
      else
        return( 'FALSE' );
      end if;
    end;To test a function like yours, the following will do in SQL*Plus/TOAD/etc:
    begin
      DBMS_OUTPUT.put_line(
        BoolToChar( XCCC_PO_APPROVALLIST_S1.does_cpa_exist(1017934)  )
    end;
    I'm probably doing 101 things wrong here, but thought I'd ask anyway and risk being shouted at.Shout at? You reckon? I thought people risked being beaten with a lead pipe, or pelted with beer cans and stale pretzels - which makes being shouted at a really safe and viable alternative. {noformat};-){noformat}

  • OR condition not working correctly in SQL

    I am adding the folling condition to a sql statement and
    AND (status_code IS NULL or status_code <> 'T'
    or (status_code IN ('A','B','C','D') and TRIM(order_type) NOT LIKE '%9999')
    or (status_code IN ('A','B','C','D') and order_type IS NOT NULL)
    or (status_code NOT IN ('A','B','C','D')))
    but the or condition work...
    if i change it too
    AND ( (status_code IN ('A','B','C','D') and order_type IS NOT NULL) )
    then this portion of the OR condition work but when I use the OR condition something weird is happening that the condition not working... and i dont see a record that meets that condition...

    Hi,
    It's not the "trim" that implies "not null", but rather the fact that:
    - "not like" operator works only on non-null values and
    - "not like" operator disregards null values.
    Consider this:
    test@ORA92>
    test@ORA92>
    test@ORA92> l
      1  with x as (
      2    select null as y from dual union all
      3    select 'a9999' from dual union all
      4    select 'bxx' from dual
      5  )
      6  select * from x
      7* where y not like '%9999'
    test@ORA92>
    test@ORA92> /
    Y
    bxx
    1 row selected.
    test@ORA92>
    test@ORA92>Here, trim function was not used, but still the first row (that had null for y) was not returned. That's because Oracle disregarded the first row for comparison and out of the next two rows, it returned the third row because it satisfied the condition.
    As for your query, do the following conditions hold true:
    1. if status_code is null      - show the row regardless of order_type
    2. if status_code <> 'T'       - show the row regardless of order_type
    3. if status_code in (a,b,c,d) and order_type is not null and order_type ends with something other than 9999 - show the row
    4. if status_code in (a,b,c,d) and order_type is null                           - do not show the row
    5. if status_code in (a,b,c,d) and order_type is not null and it ends with 9999 - do not show the row
    6. if status_code is anything other than (a,b,c,d)                              - do not show the rowpratz

  • Substr function? extracting just the records with 4 digits?

    have a column like this in a table
    SZSCAPD_SEC_SCHOOL_CEEB
    364775
    460460
    460240
    2562
    164625
    460240
    230969I need to be able to retrieve just the values with 4 digits like 2562 and add 00 at the front, so it will ended like 002562
    I am thinking in the substr function, but it won't work, because I will be extracting the first 4 digits of each number.
    How I will do this? I want to only retrieve the numbers with 4 digits Then I will concatenate the 00 in front.
    Thank you

    Hi,
    peace4all wrote:
    ... How I will do this? I want to only retrieve the numbers with 4 digits One way to do that is
    WHERE   TRANSLATE ( szscapd_sec_school_ceeb
                , '123456789'
                , '000000000'
                ) = '0000'
    Then I will concatenate the 00 in front.
    '00' || szscapd_sec_school_ceebThis assumes that szscapd_sec_school_ceeb is a string.
    If szscapd_sec_school_ceeb is a positive number, and you want to ignore any fractional part, use
    WHERE   szscapd_sec_school_ceeb     >=  1000
    AND     szscapd_sec_school_ceeb <  10000to find the numbers and
    TO_CHAR (szscapd_sec_school_ceeb, 'FM000000')to display them as 6 digits, with leading 0's.
    Edited by: Frank Kulash on Aug 20, 2010 11:01 AM
    Added NUMBER alternative.

Maybe you are looking for

  • Hp photosmart d110 printer issues - connectivity

    More often than not, I go to print wirelessly to this printer from one of our laptops and it will not print. Whenever this happens and I run a wireless test, the printer is always fine. The printer shows up in my devices window and appears to be fine

  • Mac keeps restarting randomly

    My mac keeps randomly restarting. I have a brand new harddrive installed into it ( bc the other one got fried) so I dont understand why its still doing this. What do I do ? this is the error code Anonymous UUID:       36D018CE-543F-CD16-C75B-73BCA971

  • Not hard coding the iexplorer path

    Hi I was looking around and saw this piece of code posted by Cotton.m: public class IETest{   public final static String browserPath ="C:\\Program Files\\Internet Explorer\\iexplore.exe";   public static void main(String args[])throws Exception{    

  • I lost the password to my iMac desktop profile

    2 months ago our imac was stolen from our house and only yesterday it was recovered by the police but in the mean time they restarted the computer and made a profile that we do not know the password to. Is there anyway we can restart the computer wit

  • Problems using IMPORT method

    Hello, We have just upgraded from 4.6c to ECC6. In several programs we used Import method with the following syntax in 4.6c: import (tname) to &1 from database zzhilan(zz) id zkey1(16) . However in ECC6 , since it didn't compile we changed it to :