Home > Archive > Oracle Databases > August 2005 > IN and REPLACE functions (SQL)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author IN and REPLACE functions (SQL)
Iscream

2005-08-16, 12:59 pm

I’m new to ASP-SQL-Oracle. Working on a really simple (for you guys) database application. Users can select multiple items from a list menu and it’s supposed to display the information accordingly. For example, I have a column called Skill (type VARCHAR2) and it has 4 possible values: Accessing, Processing, Communicating, and Applying.

I have something like this:
SQL = "SELECT * FROM TableName WHERE Skill IN (REPLACE('''" & Replace(Request.QueryString("Skill"), "'", "''") & "''', ', ', ''','''))"
objRS.Open SQL, objConn, 0, 1

What am I trying to do?
Say a user selected Accessing and Processing from the menu, Replace(Request.QueryString("Skill"), "'", "''") will give me Accessing, Processing. With the SQL’s REPLACE function, I tried to change it to ‘Accessing’,’Process
ing’, and so I can check if Skill is IN (‘Accessing’,’Proces
sing’) or not. But what I have is not giving any data.

SELECT REPLACE ('''Accessing, Processing''', ', ' , ''',''') FROM DUAL gives me ‘Accessing’,’Process
ing’. And SELECT * FROM TableName WHERE SKILL IN ('Accessing','Proces
sing') gives me all the data. However, when I tried to combine these two parts together, it fails.

I’m probably doing something really stupid ;(. Any thoughts? Many thanks for helping!!!
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com