A procedure to Reverse a String in PL/SQL

后端 未结 6 771
猫巷女王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:55

        create or replace procedure ap_reverse_number(input_no VARCHAR2) as
          output_no VARCHAR2(100);
    
        begin
    
          for i in 1 .. length(input_no) loop
            output_no := output_no || '' ||
                         substr(input_no, (length(input_no) - i + 1), 1);
          end loop;
    
          dbms_output.put_line('Input no. is :' || input_no);
          dbms_output.put_line('Output no. is:' || output_no);
    
        end;
    

    This should do the job correctly.

提交回复
热议问题