473,383 Members | 1,879 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,383 software developers and data experts.

VARCHAR variable in where clause

Hi NG

How do I have to use a VARCHAR2 variable in a where clause.
I could not find an example.

PART_NR VARCHAR2(20);
myPartId NUMBER()20;

PART_NR := '101 189';
select part_id into myPartId from part where part_nr = PART_NR; -- not working, hwo to do ?

How do I have to "escape" the PART_NR, that it will be:

where part_nr = '101 189'

Thanks
Peter

Jul 19 '05 #1
2 6748
Hi NG

I just found the problem.

PART_NR is the same as part_nr of course.

so renaming PART_NR into PART_NR_TO_SEARCH_FOR is solving the problem...

Peter
Peter Jenny<Pe*********@cedes.com> 20.11.2003 15:31:29 >>>


Hi NG

How do I have to use a VARCHAR2 variable in a where clause.
I could not find an example.

PART_NR VARCHAR2(20);
myPartId NUMBER()20;

PART_NR := '101 189';
select part_id into myPartId from part where part_nr = PART_NR; -- not working, hwo to do ?

How do I have to "escape" the PART_NR, that it will be:

where part_nr = '101 189'

Thanks
Peter

Jul 19 '05 #2
"Peter Jenny" <Pe*********@cedes.com> wrote in message news:<bp**********@rex.ip-plus.net>...
Hi NG

How do I have to use a VARCHAR2 variable in a where clause.
I could not find an example.

PART NR VARCHAR2(20);
myPartId NUMBER()20;

PART NR := '101 189';
select part id into myPartId from part where part nr = PART NR; -- not
working, hwo to do ?

How do I have to "escape" the PART NR, that it will be:

where part nr = '101 189'

Thanks
Peter

--


What makes you think that
PART NR
is a valid variable name?

(HINT: try PART_NR)
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Rodusa | last post by:
I am beggining to learn stored procedures and I am trying to concatenate the where clause below but I keep getting an error: declare @sqlwhere varchar(15) set @sqlwhere = 'parentid=2' ...
14
by: joshsackett | last post by:
I have a WHERE clause that could be an "=" or a "LIKE" depending upon if the passed variable is populated or not. I would like to know the best way to write the WHERE clause to make it dynamically...
7
by: Britney | last post by:
Original code: this.oleDbSelectCommand1.CommandText = "SELECT TOP 100 user_id, password, nick_name, sex, age, has_picture, city, state, " + "country FROM dbo.users WHERE (has_picture = ?) AND (sex...
2
by: MCOOP | last post by:
Is there a way to have a declare variable (@where) be used as the WHERE clause in a stored procedure? The reason I ask is that I'm trying to use one sql statement for several possible WHERE...
4
benchpolo
by: benchpolo | last post by:
I wrote a SQL script with a rxfilldate (mm/dd/yyyy format) parameter in WHERE clause. Is there way to automate the where clause to pick up the previous months data. For example: DATEPAID BETWEEN...
6
by: Jared | last post by:
Consider the following two functionally identical example queries: Query 1: DECLARE @Name VARCHAR(32) SET @Name = 'Bob' SELECT * FROM Employees WHERE = CASE WHEN @Name IS NULL THEN ELSE...
2
by: Peter Jenny | last post by:
Hi NG How do I have to use a VARCHAR2 variable in a where clause. I could not find an example. PART_NR VARCHAR2(20); myPartId NUMBER()20; PART_NR := '101 189'; select part_id into...
1
by: rahullko05 | last post by:
Hi, i am building a small forum site as my final year project & stuck in a very trivial problem. I have a table which are varchar type of data & i am trying to fetch data from table based on...
2
prn
by: prn | last post by:
Hi folks, This may sound odd, but I'm preparing a stored procedure that I want to handle a couple of different cases. However, unlike the standard sort of situation where what I want to...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.