473,243 Members | 1,645 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,243 software developers and data experts.

How to return records where the value in column is less than 4 digits using cursor

Hi!

I need to right write a query for a cursor that will return records where the value in a certain column is less than 4 digits.

eg if the value is 0001 or 1234 it will be ignored
but in case the value is 01 or 123 the record will be returned or stored as per the query.

please guide me with this.

thanks in advance

radhekrsna
Jul 31 '12 #1

✓ answered by Rabbit

Cursors are only needed if you need to work between records. If you only need to work within a record, there's no need to use a cursor. Cursors are performance killers, they should be avoided whenever possible. In your case, you've said nothing to indicate that your goal is to work between records so you don't need a cursor.

You also said nothing before about there being non-numeric data. What you want, in this case, is to use the REGEXP_LIKE operator to look only for 4 consecutive digits.

5 2309
Rabbit
12,516 Expert Mod 8TB
There's no need for a cursor. Just use the length function to return how long the string is.
Jul 31 '12 #2
Hi Rabbit!
Thank you so much for your reply!

actually multiple records need to be checked for this condition, so i figured that use of cursor would be required.

is it possible to acheive this without cursor.

also i am cofused how can i differentiate between a purely numeric string from one that is alphanumeric? could you please help?

eg 1234 is fine
but 12ab or ab12 is returned etc

thanks in advance!

radhekrsna
Aug 1 '12 #3
Rabbit
12,516 Expert Mod 8TB
Cursors are only needed if you need to work between records. If you only need to work within a record, there's no need to use a cursor. Cursors are performance killers, they should be avoided whenever possible. In your case, you've said nothing to indicate that your goal is to work between records so you don't need a cursor.

You also said nothing before about there being non-numeric data. What you want, in this case, is to use the REGEXP_LIKE operator to look only for 4 consecutive digits.
Aug 1 '12 #4
hmm ... let me specify my goal
I want to perform separate actions on the table when the values in a certain column fall in the following criteria:
  1. when the value is purely alphabetic
  2. when the value is purely numeric and upto 4 digits
  3. when the value is less than 4 digits/characters
  4. when the value is longer than 4 digits/characters

pls guide me on the best approach to achieve this if not via cursors.

radhekrsna
Aug 2 '12 #5
Rabbit
12,516 Expert Mod 8TB
The answer is in my previous post.
Aug 2 '12 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Corrine | last post by:
I am trying to pass a temporary BLOB that I've created in Java, to a PLSQL function that modifies it, and then to retrieve this modified value back to Java, all using JDBC. I can't figure out...
11
by: David | last post by:
I am learning plsql. I would like to run a stored procedure to calculate my bank account value by predicted 10% annual growth rate. Below is my plsql that is having problems. Your help is highly...
3
by: robert | last post by:
Mr. Kyte's article doesn't use cursors, while Mr. Feuerstein's book examples do. my recollection of conventional wisdom is to avoid using cursors. is this difference merely a question of style,...
2
by: A.M | last post by:
Hi, I am having hard time to find a sample that shows me how to return an OUT REF CURSOR from my oracle stored procedure to my python program. The technique is explained here for Java...
2
kiss07
by: kiss07 | last post by:
Hi, What is difference between dynamic cursor and static cursor? what is plsql table? Waiting for reply.. Thanks, Arun..
2
kiss07
by: kiss07 | last post by:
Dear friends, I write a program using oracle version 9i. in cursor .How can i find out is a cursor is open or not? after that what is bind variable ? what is the use of Bind variable in...
1
amitpatel66
by: amitpatel66 | last post by:
Hi, Is PLSQL Anonymous block allowed in CASE WHEN statement when CASE is used in SELECT statement. Check below code which executes but does not return anything: SELECT job, CASE WHEN job =...
0
by: anuptosh | last post by:
Hi, I have been trying to run the below example to get a Oracle Array as an output from a Java code. This is an example I have found on the web. But, the expected result is that the code should...
0
by: sybrandb | last post by:
"Jorge Pinto" <jorgep@sympatico.cawrote in message news:<L2HQa.3116$104.264170@news20.bellglobal.com>... utl_smtp is only a wrapper for a java procedure. Need I say more. And oh yes, you may need...
1
by: atp2k3 | last post by:
Hello all, I am new to convert PLSQL to TSQL. Any expertise in SQL, please help me to do convert the belowed PLSQL procedure to SP in SQL server. I really appreciate your time. Thanks in advance....
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.