473,503 Members | 12,103 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validate pattern of field in combination of char & int

4 New Member
Is the SQL possible to validate a table field which is combination of char and int? e.g. MIS0014?

I want the SQL return data which specific field first 3 character is alphabets and last 4 character is numeric values.
Sep 14 '10 #1
2 2157
syminder
4 New Member
Hi, I get the answer already.

I used the REGEXP_LIKE(field, '^[a-z]{3}[0-9]{4}$') to solve my question, please ignore this thread.
Sep 14 '10 #2
amitpatel66
2,367 Recognized Expert Top Contributor
Prior 10g,

Expand|Select|Wrap|Line Numbers
  1. SQL> ed
  2. Wrote file afiedt.buf
  3.  
  4.   1  with t as (select 'MIS0014' col1 from dual
  5.   2  union select 'ABC1234' from dual
  6.   3  union select '1234ABC' from dual
  7.   4  union select 'CDV1234' FROM dual
  8.   5  union select 'CDVF123' FROM dual)
  9.   6  SELECT col1 FROM
  10.   7  (SELECT col1,translate(SUBSTR(col1,1,3),'4567890123',' ') str1,
  11.   8               TRANSLATE(SUBSTR(col1,4,4),'ABCDEFGHIJKLMNOPQRSTUVWXYZ',' ') str2 FROM t)
  12.   9  WHERE length(str1) = 3
  13.  10* AND length(str2) = 4
  14. SQL> /
  15.  
  16. COL1
  17. -------
  18. ABC1234
  19. CDV1234
  20. MIS0014
  21.  
  22. SQL> 
  23.  
Sep 14 '10 #3

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

Similar topics

7
2735
by: Alex Vinokur | last post by:
========================================== Windows 2000 Professional CYGWIN_NT-5.0 1.5.4(0.94/3/2) GNU g++ version 3.2 20020927 (prerelease) GNU objdump 2.14.90 20030901...
8
2233
by: pembed2003 | last post by:
Hi coders, I have the following: void f1(char* &s){ *s = 'a'; } void f2(char* s){ *s = 'b'; }
3
14280
by: Marcin Kalicinski | last post by:
void f(const char *&text); Is this a const reference to char * or a reference to const char *? And how to write both of them? thank you, Marcin
5
21598
by: Ernez Catovic | last post by:
Please help me. I can see the content of field type CHAR(n) FOR BIT DATA of DB2 database, but when I try to see the content of mentioned field type by using SQL query (ODBC connection) only I...
11
3480
by: pembed2003 | last post by:
Hi coders, I have the following: void f1(char* &s){ *s = 'a'; } void f2(char* s){ *s = 'b'; }
1
2982
by: Grey | last post by:
Can I use RegularExpressionValidator to validate the user is input number or not? how to do that???
3
20789
by: gevadas | last post by:
sample program #include <iostream> #include <vector> using namespace std; int find(char*& value,char** arr,int size) { for(int i = 0;i < size;i++)
1
1739
by: automation | last post by:
I have a web-page consisting of a listbox & image buttons. I want to post to the appropriate PHP script based on which list_item and image button combination is selected, where the logic is...
0
1341
by: Medhatithi | last post by:
I have a table whose indexed column is a char(16) field. I am giving the schema. CREATE TABLE Emp(Empno char(16), Ename varchar(25), ...
8
6624
idsanjeev
by: idsanjeev | last post by:
I try to validate inpute field for weight that accept only numeric value like 65.12 not allow any special character or character but allow '.' . thanks jha
0
7212
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7296
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5604
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
405
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.