oracle - The use of double vertical bars in pl/sql -


i want find reverse string program. there many examples have found none explain happens inside loop:

declare ln_rev_input varchar2(50); ln_input varchar2(50):= '&input';  begin      in reverse 1..length(ln_input) loop          ln_rev_input := ln_rev_input||substr(ln_input, i, 1);      end loop;      dbms_output.put_line(ln_rev_input); end; 

i don't understand line, use of '||' in program:

ln_rev_input := ln_rev_input||substr(ln_input, i, 1); 

i know '||' used concatenate strings don't understand how ln_rev_input being assigned.

thanks

the oracle/plsql || operator allows concatenate 2 or more strings together.

what above code is reversing input string. lets pass string named oracle, starts end of string oracle, takes 1 character @ time using function substr(ln_input, i, 1) , concatenates character whatever value there in ln_rev_input variable.

when starts, ln_rev_input null , result of ln_rev_input := ln_rev_input||substr(ln_input, i, 1); e.

when goes next iteration, character l concatenated whatever value there inside variable ln_rev_input, e - piece of code like

ln_rev_input := 'e' || 'l'; 

which result in value of ln_rev_input changed el. goes on 6 times, length of string - found using length(ln_input) - , in end, value of ln_rev_input elcaro.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -