473,657 Members | 2,700 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 2169
syminder
4 New Member
Hi, I get the answer already.

I used the REGEXP_LIKE(fie ld, '^[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
2741
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 ========================================== We can see that the same assembly code is generated for * foo2 (char& )
8
2240
by: pembed2003 | last post by:
Hi coders, I have the following: void f1(char* &s){ *s = 'a'; } void f2(char* s){ *s = 'b'; }
3
14351
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
21663
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 can see are some digits, instead of appropriate characters.
11
3502
by: pembed2003 | last post by:
Hi coders, I have the following: void f1(char* &s){ *s = 'a'; } void f2(char* s){ *s = 'b'; }
1
2989
by: Grey | last post by:
Can I use RegularExpressionValidator to validate the user is input number or not? how to do that???
3
20825
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
1747
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 determined by JavaScript. So far, I can determine what list_item has been selected, but how do I determine what image button was selected? The current PHP Script & JavaScript are below. <form method="post" action="operation_request_navigation.php"...
0
1350
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), Salary number(10,2),......) Now, there is an index on the Empno field. Now, inside a stored procedure, I am executing a statement select Name=Ename from Emp where Empno=@eno This @eno is varchar(25). So, SQL Server would do the implicit...
8
6630
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
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8739
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5638
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.