Je viens de réussir à activer la recherche en texte intégral pour faciliter la recherche de produits dans mon système. Cependant, j'utilise un sp qui a été construit par quelqu'un d'autre et il ne retourne aucun résultat pour "Duty Call". En fait, je suis à la recherche de "Call of Duty", un produit dans le système. Si je tape "Call of Duty" renvoie un résultat, mais supprimer un mot et retourner les mots restants ne donne pas de résultats. Le code est le suivant:procédure stockée ne donne aucun résultat, mais requête
USE [storeboard]
GO
/****** Object: StoredProcedure [sbuser].[sp_ProductSearch] Script Date: 08/26/2010 05:57:20 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [sbuser].[sp_ProductSearch]
@StoreItemID bigint = null,
@StoreMemberID bigint = null,
@ProductName varchar(50) = null,
@ProductDesc varchar(1000) = null,
@ItemPrice float = null,
@Active bit = null,
@Deleted bit = null,
@CreateDate datetime = null,
@ShipWeight float = null,
@TaxExempt bit = null,
@ShipCost float = null,
@Keywords varchar(1000) = null,
@PG int = 1,
@ROWCT numeric(18,2) = 1,
@COLCT numeric(18,2) = 1,
@MODE varchar(50),
@StoreItemCatID bigint = null,
@SearchStr varchar(100) = null
AS
IF @MODE = 'S1'
BEGIN
SELECT
StoreItemID,
ProductName,
ItemPrice,
PG,
MAXPG,
TOTALRECS,
CoverImg,
StoreItemCatID,
Active
FROM sbuser.tf_ProductSearch(@PG,@ROWCT,@COLCT,@StoreItemCatID,@SearchStr)
END
Le code fait référence à la tf_productSearch qui est la suivante:
USE [storeboard]
GO
/****** Object: UserDefinedFunction [sbuser].[tf_ProductSearch] Script Date: 08/26/2010 05:46:36 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [sbuser].[tf_ProductSearch] (
@PG int,
@ROWCT numeric(18,2),
@COLCT numeric(18,2),
@StoreItemCatID bigint,
@SearchStr varchar(100) = null)
RETURNS @OUT TABLE (
StoreItemID bigint,
ProductName varchar(50),
ProductDesc varchar(1000),
ItemPrice float,
Active bit,
CreateDate datetime,
ShipWeight float,
TaxExempt bit,
ShipCost float,
Keywords varchar(1000),
PG int,
MAXPG INT,
TOTALRECS INT,
CoverImg varchar(50),
StoreItemCatID bigint)
AS
BEGIN
DECLARE @START numeric(18,2);
DECLARE @END numeric(18,2);
DECLARE @SIZE numeric(18,2);
DECLARE @MAXPG numeric(18,2);
DECLARE @TOTALRECS numeric(18,2);
DECLARE @TOTALRECS_INT int;
DECLARE @MAXPG_INT int;
DECLARE @TOTALRECS_REMAINDER numeric(18,2);
SET @SIZE = @ROWCT * @COLCT
SET @Start = (((@PG - 1) * @Size) + 1)
SET @END = (@START + @SIZE - 1)
DECLARE @TMP1 TABLE (
TmpID bigint identity(1,1) primary key,
StoreItemID bigint,
ProductName varchar(50),
ProductDesc varchar(1000),
ItemPrice float,
Active bit,
CreateDate datetime,
ShipWeight float,
TaxExempt bit,
ShipCost float,
Keywords varchar(1000),
CoverImg varchar(50),
StoreItemCatID bigint)
IF @StoreItemCatID IS NULL
BEGIN
INSERT INTO @TMP1
SELECT
a.StoreItemID,
a.ProductName,
a.ProductDesc,
a.ItemPrice,
a.Active,
a.CreateDate,
a.ShipWeight,
a.TaxExempt,
a.ShipCost,
a.Keywords,
sbuser.sf_StoreItemCoverImg(a.StoreItemID) AS CoverImg,
a.StoreItemCatID
FROM sbuser.StoreItem a
WHERE FREETEXT (a.ProductName, @SearchStr)
AND Deleted = 0
AND Active = 1
ORDER BY a.ProductName
END
ELSE
BEGIN
INSERT INTO @TMP1
SELECT
a.StoreItemID,
a.ProductName,
a.ProductDesc,
a.ItemPrice,
a.Active,
a.CreateDate,
a.ShipWeight,
a.TaxExempt,
a.ShipCost,
a.Keywords,
sbuser.sf_StoreItemCoverImg(a.StoreItemID) AS CoverImg,
a.StoreItemCatID
FROM sbuser.StoreItem a
WHERE FREETEXT (a.ProductName, @SearchStr)
AND a.StoreItemCatID = @StoreItemCatID
AND a.Deleted = 0
AND a.Active = 1
OR a.StoreItemCatID IN (SELECT StoreItemCatID FROM StoreItemCat WHERE ParentID = @StoreItemCatID)
AND FREETEXT (a.ProductName, @SearchStr)
AND a.Deleted = 0
AND a.Active = 1
ORDER BY a.ProductName
END
SELECT @TOTALRECS = MAX(TMPID) FROM @TMP1
SELECT @MAXPG = @TOTALRECS/@SIZE
SET @TOTALRECS_REMAINDER = @TOTALRECS % @SIZE
SET @MAXPG_INT = CAST(@MAXPG AS INT)
SET @TOTALRECS_INT = CAST(@TOTALRECS AS INT)
IF @TOTALRECS_REMAINDER > 0
BEGIN
SET @MAXPG_INT = @MAXPG_INT + 1
END
INSERT INTO @OUT
SELECT
StoreItemID,
ProductName,
ProductDesc,
ItemPrice,
Active,
CreateDate,
ShipWeight,
TaxExempt,
ShipCost,
Keywords,
@PG,
@MAXPG_INT,
@TOTALRECS_INT,
CoverImg,
StoreItemCatID
FROM @TMP1
WHERE (TmpID >= @Start) AND (TmpID <= @END)
RETURN
END
Cet appel à l'intérieur d'une page Web ASP classique avec le code suivant:
Dim ProductCat
Dim paryProducts
Dim ProdMaxPG
Dim pstrProductList
Const C_PRODUCTS_FE_PRODUCTROWCOUNT = 4
Const C_PRODUCTS_FE_PRODUCTCOLCOUNT = 5
SearchStr = "duty call"
StoreItemCatID = ""
cData.SQL = "sp_ProductSearch " _
& cData.ProcFld("MODE","S1",2,True) _
& cData.ProcFld("PG",PG,0,True) _
& cData.ProcFld("ROWCT",C_PRODUCTS_FE_PRODUCTROWCOUNT,0,True) _
& cData.ProcFld("COLCT",C_PRODUCTS_FE_PRODUCTCOLCOUNT,0,True) _
& cData.ProcFld("SearchStr",SearchStr,2,True) _
& cData.ProcFld("StoreItemCatID",StoreItemCatID,0,False)
paryProducts = cData.RSArray()
Ces scripts ne retournent cependant aucun résultat. Cependant, en tapant le code suivant directement dans la fenêtre de requête du sql-server:
USE storeboard
GO
DECLARE @SearchStr varchar(50)
SET @SearchStr = 'duty call';
SELECT
a.StoreItemID,
a.ProductName,
a.ProductDesc,
a.ItemPrice,
a.Active,
a.CreateDate,
a.ShipWeight,
a.TaxExempt,
a.ShipCost,
a.Keywords,
a.StoreItemCatID
FROM sbuser.StoreItem a
WHERE FREETEXT (a.ProductName, @SearchStr)
AND a.Deleted = 0
AND a.Active = 1
ORDER BY a.ProductName
-t retourne un résultat. Je suis hors de ma ligue ici et je me demandais si l'un d'entre vous des programmeurs expérimentés peut voir quelque chose de manifestement faux ici. Toute aide que vous ou vos filles pourriez fournir serait grandement appréciée.
Merci beaucoup,
Paul
Pourriez-vous essayer de réduire cela à un plus petit exemple - il y a beaucoup de choses à lire ici, et je ne pense pas que beaucoup persévéreront. –
Je ne suis pas sûr de pouvoir le réduire en taille car tout ce code est pertinent. – neojakey