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
Solved

programming in plsql

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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can i Import Access Table Into Oracle Using Toad 36 218
Oracle - SQL Where clause causing Invalid Number Error 4 44
Oracle Listener Not Starting 11 51
Row_number in SQL 6 33
This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

792 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