0

In the desired structure, the function will take 2 string parameters.

  • If 2nd String is found in 1st String; The 1.string in the 2.string will be removed and added to the end of the 2.string.
  • If it is not found, the error 'NOT FOUND' will be given.

The desired structure should be as follows.

1 Answer 1

2

Here's one option:

SQL> create or replace function f_test (par_1 in varchar2, par_2 in varchar2)
  2    return varchar2
  3  is
  4    retval varchar2(20);
  5  begin
  6    if instr(par_1, par_2) > 0 then
  7       retval := replace(par_1, par_2) || par_2;
  8    else
  9       retval := 'Not found';
 10    end if;
 11
 12    return retval;
 13  end;
 14  /

Function created.

SQL>
SQL> select f_test('topualiat', 'ali' ) result_1,
  2         f_test('little'   , 'foot') result_2
  3  from dual;

RESULT_1        RESULT_2
--------------- ---------------
topuatali       Not found

SQL>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.