Results 1 to 6 of 6
  1. #1
    Join Date
    Mar 2004
    Posts
    9

    Unanswered: string comparison function

    Hi.
    I am writing a function that compares two string and return 1=1
    if those two strings are match. if not match, return 1=0.
    Here is my function:

    create or replace package test as
    function test2_function( st1 in varchar2, st2 in varchar2) return varchar2;
    end;
    /

    create or replace package body test
    as
    test_pred varchar2(1024) default NULL;

    function test2_function( st1 in varchar2, st2 in varchar2) return varchar2
    is
    BEGIN
    if (st1 = st2)
    then
    test_pred := '1=1';
    else
    test_pred := '1=0';
    end if;
    return test_pred;
    end;
    /

    I am keep getting error messages as

    Warning: Package Body created with compilation errors.

    I checked code and could not find where I did wrong.
    Please take a look and tell me what I did wrong.
    many thanks.

    p.s. is there any way i can get more information other than
    "Warning: Package Body created with compilation errors."
    while I am trying to compile the function?

  2. #2
    Join Date
    Mar 2004
    Posts
    17

    Re: string comparison function

    Hi

    This works for me.
    For getting more information on the compilation type show errors

    Cyberbob

  3. #3
    Join Date
    Mar 2004
    Posts
    23

    Re: string comparison function

    Where is the 'end;' of the package body?

  4. #4
    Join Date
    Mar 2004
    Posts
    17

    Re: string comparison function

    My mistake here ... I did put an end for the package body

  5. #5
    Join Date
    Mar 2004
    Posts
    23

    Re: string comparison function

    I took your code and saved to a file, c:\test.sql

    SQL> @c:\test

    Package created.


    Warning: Package Body created with compilation errors.

    Errors for PACKAGE BODY TEST:

    LINE/COL ERROR
    -------- ---------------------------------------------------------------
    16/0 PLS-00103: Encountered the symbol "end-of-file" when expecting
    one of the following:
    begin end function package pragma procedure form

    This error was because didn't have package body 'end;'
    I added it.

    SQL> @c:\test

    Package created.


    Package body created.

    No errors.

    SQL> desc test
    FUNCTION TEST2_FUNCTION RETURNS VARCHAR2
    Argument Name Type In/Out Default?
    ------------------------------ ----------------------- ------ --------
    ST1 VARCHAR2 IN
    ST2 VARCHAR2 IN

    SQL> select test.test2_function ('a','b') from dual;

    TEST.TEST2_FUNCTION('A','B')
    ------------------------------------------------------------------------
    1=0

    Looks good, so, sorry, don't see any problem with the code as
    you have presented to us.

  6. #6
    Join Date
    Mar 2004
    Posts
    9
    it worked.
    Thank you so much!!!!!

Posting Permissions

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