Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Pl/sql Like

  • 07-12-2007 7:30pm
    #1
    Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭


    i have a piece of pl/sql that looks like this:
    DECLARE
        dest    Location.description%TYPE:=&dest;
        result    Location.description%TYPE;
        
    BEGIN
        SELECT description INTO result FROM Location WHERE description LIKE '%' || dest || '%' ;    
           
        IF result LIKE dest
        THEN
            DBMS_OUTPUT.PUT_LINE('we have holidays based in ' || dest || ' contact a agent to arrange today.');
        END IF;
        
        
        EXCEPTION
                    WHEN NO_DATA_FOUND THEN
                        DBMS_OUTPUT.PUT_LINE('cannot find ' || dest || ' in the database.');
                    WHEN OTHERS THEN
                        DBMS_OUTPUT.PUT_LINE('Unexpected error occurred.');    
    END;
    
    


    what i want it to do is enter in a destination eg. 'new york' and check it to see if it's like the result. the problem arises with the description in the Locations table is capitalised so when i enter in 'New York' it does the output line, but i want it to execute this if someone types in something like new york eg 'new yokr'. i thought the LIKE command would do this.


Comments

  • Registered Users, Registered Users 2 Posts: 995 ✭✭✭cousin_borat


    Usually in pl/sql when comparing string you make both strings uppercase so use the pl/sql upper function
    DECLARE
        dest    Location.description%TYPE:=&dest;
        result    Location.description%TYPE;
        
    BEGIN
        SELECT description INTO result FROM Location [B]WHERE UPPER([/B]description[B])[/B] LIKE '%' || [B]UPPER([/B]dest[B])[/B] || '%' ;    
           
       and so on...
    

    Hope this helps.

    Also watch out for NULLvalues in your WHERE clauses as this will generate PL/SQL exceptions


  • Registered Users, Registered Users 2 Posts: 26,584 ✭✭✭✭Creamy Goodness


    thank you kind sir.


Advertisement