?
Solved

programming in plsql

Posted on 2011-09-28
6
Medium Priority
?
262 Views
Last Modified: 2012-05-12
hi,

each value of 1 is representing an error that is now I have 3 errors and error number would be the position of the 1 in the binary number

1000000000000000000011

how to write a procedure that checks each position (1-31 since they have 31 errors) and if it’s a 1 in the position, then that’s the error.


so I should get result as
error number 1
error number 2  
error number 22

thanks very much in advance.


 

0
Comment
Question by:vsarma50
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 36718834
Try this:


create or replace procedure myproc(inStr in varchar2)
is
begin

	for i in 1..length(inStr) loop
		if substr(inStr,-i,1) = '1' then
			dbms_output.put_line('error number ' || i);
		end if;
	end loop;

end;
/
show errors

exec myproc('1000000000000000000011');

Open in new window

0
 

Author Comment

by:vsarma50
ID: 36718920
great thanks very much
0
 

Author Comment

by:vsarma50
ID: 36814528
I've requested that this question be closed as follows:

Accepted answer: 0 points for vsarma50's comment http:/Q_27346372.html#36718920

for the following reason:

i appreciated in my response comment
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36719070
Did you mean to accept your own post as the answer?
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36814529
You never responded to my question so I'll have to Object and involve a Moderator.
0

Featured Post

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question