Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 27th, 2006, 02:43 PM
Antaros Antaros is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2006
Posts: 1 Antaros User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 46 sec
Reputation Power: 0
Like query problems

Hi, Im new in the forum and new using Firebird too.

I hope someone can help me

how do I use the statement "like", Im been looking in the web but can't find anything.

I try to do something like
select
from
where [Attribute] like ' % :NAME % '

Assuming that the parameter :NAME is the input value.

Im using a Store Procedure as follow:
SET TERM ^ ;
PROCEDURE CONSULTAR_ARTISTAS_NACIONALES
(
NOMBRE_ARTISTA Varchar(150),
RESIDENCIA Varchar(100)

)
RETURNS
(
NOMBRE Varchar(150),
RESIDEN Varchar(100),
AS
BEGIN
FOR
SELECT NOMBRE_ARTISTA, LUGAR_RESIDENCIA
FROM ARTISTAS_NACIONALES
WHERE LUGAR_RESIDENCIA like '%:RESIDENCIA%'
INTO :NOMBRE, :RESIDEN
DO SUSPEND;
END^
SET TERM ; ^

But it seems that the variable between '%%' is not get it by the firebird instead take it like a common string but with : , is there something Im missing?

Please help and sorry for my english

Reply With Quote
  #2  
Old October 27th, 2006, 04:43 PM
clivew clivew is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2006
Location: Carlsbad, CA
Posts: 807 clivew User rank is Sergeant (500 - 2000 Reputation Level)clivew User rank is Sergeant (500 - 2000 Reputation Level)clivew User rank is Sergeant (500 - 2000 Reputation Level)clivew User rank is Sergeant (500 - 2000 Reputation Level)clivew User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 4 Days 5 h 10 m
Reputation Power: 19
Quote:
WHERE LUGAR_RESIDENCIA like '%:RESIDENCIA%'


WHERE LUGAR_RESIDENCIA like :RESIDENCIA

Note:
1. No quotes round the parameter.
2. Pass in the % sign as part of your parameter value.

Also, you do not need to pass in NOMBRE_ARTISTA, you are not using it in your where clause.

Code:
SELECT NOMBER, RESIDEN 
FROM CONSULTAR_ARTISTAS_NACIONALES('%RESIDENCIA%') 


Also, passing in the % as part of the parameter allows you to determine whether you will put it at the start, the end or both.

Clive

Last edited by clivew : October 27th, 2006 at 04:45 PM.

Reply With Quote
  #3  
Old October 28th, 2006, 04:18 AM
nagysz nagysz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2006
Posts: 46 nagysz User rank is Corporal (100 - 500 Reputation Level)nagysz User rank is Corporal (100 - 500 Reputation Level)nagysz User rank is Corporal (100 - 500 Reputation Level)nagysz User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 10 h 4 m 43 sec
Reputation Power: 4
you should not put the :NAME between quotation marks

make the select like:

Quote:
SELECT * FROM my_table WHERE my_field LIKE attern


and in the parameter send your string " '%whatever%' ". and that is all.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Like query problems


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway