Solved

programming in plsql

Posted on 2011-09-28
6
251 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
  • 3
  • 2
6 Comments
 
LVL 76

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
Comment Utility
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
Comment Utility
great thanks very much
0
 

Author Comment

by:vsarma50
Comment Utility
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 76

Expert Comment

by:slightwv (䄆 Netminder)
Comment Utility
Did you mean to accept your own post as the answer?
0
 
LVL 76

Expert Comment

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

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

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…
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now