Mombu the Microsoft Forum sponsored links

Go Back   Mombu the Microsoft Forum > Microsoft > Stored procedure for full text search
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 30th December 23:18
sajid
External User
 
Posts: 1
Default Stored procedure for full text search



Hi,

I've the FTS in a stored procedure and i am calling the
stored procedure from ASP program. Here is the stored
procedure :

-- =============================================
-- Create procedure basic template
-- =============================================
-- creating the store procedure


CREATE PROC dbo.spWebSearch
(
@PriceID int,
@SearchTxt nvarchar(100),
@StoreID char(2)
)
AS

-- Code for Beavercreek
if @StoreID = 'BC'
Begin
select S.[KEY], S.RANK, PQ.ProductName,
PQ.Description, P.UnitPrice, PQ.ProductID, P.UnitPrice *
100 as list_price FROM (Products AS P INNER JOIN
Product_Quantity AS PQ ON P.ProductID=PQ.ProductID) INNER
JOIN ContainsTable(Product_Quantity,*,@SearchTxt) AS S ON
PQ.ProductID = S.[KEY] Order by S.Rank Desc;
End
GO

This is how i am calling it from the ASP page

PriceID = 1
StoreID = "BC"
str = "floppy"

spStr = "exec spWebSearch " & PriceID & "," & "'" &
newstring & "'" & "," & "'" & StoreID & "'"
rsProducts.Open spStr, MSCS ' Here MSCS is the connection
string.

I get the following error :
Microsoft OLE DB Provider for ODBC Drivers
error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]A variable
cannot be used to specify a search condition in a fulltext
predicate when accessed through a cursor.

/result.asp, line 173

Can't we pass the search criteria as a variable to a FTS
stored procedure? Also please note that i am using
clientside recordset cursor. If i execute the same stored
procedure from query ****yzer it works great. Any help is
appreciated.

TIA

Sajid
  Reply With Quote


  sponsored links


2 30th December 23:18
john kane
External User
 
Posts: 1
Default Stored procedure for full text search



Sajid,
What is the SQL Server version (7.0 or 2000) and on what OS platform is it
installed? Could you post the full output of:

select @@version

Depending upon the exact version info, you may of hit a bug in SQL Server
that *might* be fixable via a SP upgrade, but this depends upon the SQL
Server version that you are currently using.

Regards,
John
  Reply With Quote
3 30th December 23:18
hilary cotter
External User
 
Posts: 1
Default Stored procedure for full text search


First of all, this is a horribly inefficient way of
calling an sp. It should be called using the command
object.

Secondly you are essentially expecting SQL Server to do
interpolation (or filling in the value of the variable)
which is something that it does not do.

You should try something like this.

create PROC dbo.spWebSearch --1, 'search text', 'bc'
(
@PriceID int,
@SearchTxt nvarchar(100),
@StoreID char(2)
)
AS
declare @strSearch as char(500)
-- Code for Beavercreek
if (@StoreID = 'BC')
Begin
set @strSearch='select S.[KEY], S.RANK, PQ.ProductName,
PQ.Description, P.UnitPrice, PQ.ProductID, P.UnitPrice *
100 as list_price FROM ProductQuantity as PQ, Products AS
P,ContainsTable(ProductQuantity,*,' + char(39)+ char(34)
set @strSearch=rtrim(@strSearch) + rtrim(@SearchTxt) +char
(34) +char(39) +') as S where P.ProductID=PQ.ProductID
and s.[KEY]=PQ.ProductID '
print @strSearch
end
exec sp_sqlexec @strSearch

fulltext
  Reply With Quote
4 30th December 23:18
john kane
External User
 
Posts: 1
Default Stored procedure for full text search


Sajid,
The use of variables in a search condition for FTS when used with a cursor
is a bug in SQL Server 2000 (Shiloh bug# 233886) that *might* or might NOT
be fixed in the next release of SQL Server. So, as Hilary suggests it's best
to re-write this proc and remove the cursor.

Regards,
John
  Reply With Quote
5 30th December 23:18
hilary cotter
External User
 
Posts: 1
Default Stored procedure for full text search


But, I don't believe a cursor is involved in this query.

Please correct me if I am wrong.

used with a cursor

*might* or might NOT

suggests it's best
  Reply With Quote
6 30th December 23:19
sajid
External User
 
Posts: 1
Default Stored procedure for full text search


Hi,

There are no cursor's involved. Also i would like to thank
you for helping out with this problem. The solution you
gave me worked.

Regards,

SAjid

Hilary
  Reply With Quote
7 30th December 23:19
john kane
External User
 
Posts: 1
Default Stored procedure for full text search


Hilary & Sajid,
I was responding to the below ODBC error and question:

"[Microsoft][ODBC SQL Server Driver][SQL Server]A variable
cannot be used to specify a search condition in a fulltext
predicate when accessed through a cursor. "

"Can't we pass the search criteria as a variable to a FTS
stored procedure? Also please note that i am using
clientside recordset cursor"


Regards,
John
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666