Solved

programming in plsql

Posted on 2011-09-28
6
257 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
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 76

Expert Comment

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle DATE Column Space 11 78
Oracle - Create Procedure with Paramater 16 63
Select and Insert Query running slow 4 34
Oracle DBLINKS From 11g to 8i 3 32
Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

776 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