Forum Stats

  • 3,838,712 Users
  • 2,262,395 Discussions
  • 7,900,739 Comments

Discussions

How to iterate and print indexes of a binary string input as varchar2 type in Oracle ?

User_50A23
User_50A23 Member Posts: 3 Employee
edited Apr 6, 2022 1:01PM in SQL Developer
declare

str varchar2(2000) := :inputstr;
v_len number;
currChar CHAR(1);

begin
                v_len := length(str);
                for i in 1..v_len
                Loop
                        currChar  := substr(str,i,1);
                        if currChar = 1 then
              dbms_output.put_line('curr index' || i);
                        end if;
                End loop;
end;

When I pass '000111000' as input to IN_STRING variable , it trims the left zeros from string.I am expecting output as 4,5,6 from above operation.

Answers