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

Home Posts Topics Members FAQ

how to compare value of two varchar2 fields ?

3 New Member
Hi,

I have a below scenario:

Table name : ClientCode.
Fields are : startcode varchar2(20) & endcode varchar2(20);

The values in these two fields should not overlap.

For Ex:

#1. startcode = 50 & endcode = 110 - this is allowed
#2. startcode = 130 & endcode = 180 - this is allowed
#3. startcode = 90 & endcode = 100 - this should not allow, since the values are
overlapped.

I would highly appreciate if any one can post the query to resolve this issue.

Thnx in advance.
Nov 5 '07 #1
5 3658
pradeep kaltari
102 Recognized Expert New Member
Hi Moorthyvisu,
Could you please tell us what exactly do you mean by overlap?

In the 3rd case you have mentioned startcode=90 and endcode=100 are overlapped. Meaning??

Anyways, if this data should not be allowed in the table itself then you can create CHECK constraint on the table specifying your rule.

Hi,

I have a below scenario:

Table name : ClientCode.
Fields are : startcode varchar2(20) & endcode varchar2(20);

The values in these two fields should not overlap.

For Ex:

#1. startcode = 50 & endcode = 110 - this is allowed
#2. startcode = 130 & endcode = 180 - this is allowed
#3. startcode = 90 & endcode = 100 - this should not allow, since the values are
overlapped.

I would highly appreciate if any one can post the query to resolve this issue.

Thnx in advance.
Nov 6 '07 #2
amitpatel66
2,367 Recognized Expert Top Contributor
Hi,

I have a below scenario:

Table name : ClientCode.
Fields are : startcode varchar2(20) & endcode varchar2(20);

The values in these two fields should not overlap.

For Ex:

#1. startcode = 50 & endcode = 110 - this is allowed
#2. startcode = 130 & endcode = 180 - this is allowed
#3. startcode = 90 & endcode = 100 - this should not allow, since the values are
overlapped.

I would highly appreciate if any one can post the query to resolve this issue.

Thnx in advance.
Write a BEFORE INSERT trigger and check if the values are getting over lapped
then dont allow the user to insert a new record in to the table.

Eg:

If new.startcode => startcode AND new.endcode <= endcode THEN
<print error>
Nov 6 '07 #3
mwasif
802 Recognized Expert Contributor
To use amitpatel66's suggestion, you have to change the of startcode and endcode to INT.
Nov 6 '07 #4
moorthyvisu
3 New Member
Hi,

Actually what I mean is "Overlap"=> the new value of start & end code should not be in the range of the existing values.

For Ex:

#1. Start = 30 & End = 90

If I give start as 40 and end as 80 it should not return a row.

Its not only the number the column is alphanumeric. If the user is entering alphanumeric for these two fields then how can we change the query?
Nov 6 '07 #5
amitpatel66
2,367 Recognized Expert Top Contributor
Hi,

Actually what I mean is "Overlap"=> the new value of start & end code should not be in the range of the existing values.

For Ex:

#1. Start = 30 & End = 90

If I give start as 40 and end as 80 it should not return a row.

Its not only the number the column is alphanumeric. If the user is entering alphanumeric for these two fields then how can we change the query?
Your first point will satisfy with the logic tha I have given you to check for over lapping in case if it is just an integer.

But how about handling of alphamumeric?

Eg: sc = 100A and EC = 200B
So you want to restrict new data if it is between 100 and 200?
Nov 7 '07 #6

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

Similar topics

4
5111
by: Gleep | last post by:
Hey Guys, I've got a table called Outcomes. With 3 columns and 15 rows 1st col 2nd col 3rdcol outcome date price There are 15 rows...
1
13255
by: Mat Hess | last post by:
We are currently developing a new application. In this application, we have a table which will hold a large number of rows, where many text fields (one text field per row) will be stored. The users...
0
9821
by: Sven Mayer | last post by:
Assume a database (e.g. Oracle) field is declared as a) NUMBER (length=10) b) NUMBER (length=26) c) VARCHAR2 (length=1) d) VARCHAR2 (length=50) e) DATE How do I retrieve the contents from...
2
3656
by: Rachel Curran | last post by:
Please can anybody help me with the following: I have two separate excel spreadsheets that I have imported into access, each sheet holds the same fields. Both spreadsheets hold all information...
5
2648
by: Mitchell Thomas | last post by:
I am using Oracle as a backend and have a field set as Varchar2(2000). The problem i have is access interprets this as a memo field and allows the user to type more than 2000 characters but does...
5
10855
by: Megan | last post by:
Hi everybody- I'm helping a friend with a music database. She has an old one and is creating a new one. She wants to compare records and fields in the old database with records and fields in the...
14
10841
by: hilz | last post by:
Hi all, What is the equivalent of VARCHAR2 in access? thanks hilz
0
4491
by: dfs9 | last post by:
In the article "Delete Duplicate Records From Access Tables" By Danny Lesandrini writes the following: This final suggestion is the most flexible and accurate. Given any table, it generates a...
4
4970
by: dfs9 | last post by:
In the article "Delete Duplicate Records From Access Tables" By Danny Lesandrini writes the following: This final suggestion is the most flexible and accurate. Given any table, it generates a...
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,...
1
7017
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...
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,...
1
5026
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...
0
4696
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...
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
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 ...
1
751
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.