A procedure to Reverse a String in PL/SQL

后端 未结 6 854
猫巷女王i
猫巷女王i 2020-12-22 03:11

I just started learning PL/SQL and I\'m not sure how to create a procedure. The logic seems about right but I think there\'s some syntactical mistake in the first line. Here

6条回答
  •  北海茫月
    2020-12-22 03:46

    Two things - you shouldn't specify the datatype size in procedure's/function's parameter list and you do not need the DECLARE keyword. Try this:

    CREATE OR REPLACE PROCEDURE ReverseOf(input IN varchar2) IS
            rev varchar2(50):='';
    BEGIN
            FOR i in reverse 1..length(input) LOOP
                    rev := rev||substr(input, i, 1);
            END LOOP;
            dbms_output.put_line(rev);
    END;
    

提交回复
热议问题