-----------------------------------------------------------
New Message on BDOTNET
-----------------------------------------------------------
From: BalajiKrishnan
Message 1 in Discussion
Dear Srinivas, The cursor fails when i try to insert '22,33'. The value 22,33
already exist in the table but it says 'Pattern does not exist and can be inserted'
How can i slove it...... DECLARE myCursor CURSOR FOR SELECT field_1, field_2 FROM
tbl_chk
DECLARE @field_1 VARCHAR(3), @field_2 VARCHAR(11), @delimiter VARCHAR(1), @searchFor
VARCHAR(11), @searchString VARCHAR(10), @tempSearchFor VARCHAR(11)
DECLARE @found INT
BEGIN
SET NOCOUNT ON
SELECT @searchFor = '22,33,44,55', @tempSearchFor = @searchFor, @found = 0,
@delimiter = 1 OPEN myCursor
FETCH NEXT FROM myCursor INTO @field_1, @field_2
WHILE (@@FETCH_STATUS = 0)
BEGIN
WHILE (@delimiter > 0)
BEGIN
SET @delimiter = CHARINDEX (',', @tempsearchFor)
IF (@delimiter <> 0)
BEGIN
SET @searchString = SUBSTRING (@tempSearchFor, 1, @delimiter-1)
SET @tempSearchFor = SUBSTRING (@tempSearchFor, @delimiter+1, LEN
(@tempSearchFor)[EMAIL PROTECTED])
END
ELSE
SET @searchString = @tempSearchFor IF (CHARINDEX (',' + @searchString + ',',
',' + @field_2 + ',') <> 0)
SET @found = @found + 1
ELSE
SET @found = @found - 1
END IF (@found = 4)
BREAK SELECT @tempSearchFor = @searchFor, @found = 0, @delimiter = 1
FETCH NEXT FROM myCursor INTO @field_1, @field_2
END
CLOSE myCursor
DEALLOCATE myCursor IF (@found = 4)
SELECT 'Pattern already exists. Cannot insert the given value'
ELSE
SELECT 'Pattern does not exist and can be inserted' SET NOCOUNT OFF
END
-----------------------------------------------------------
To stop getting this e-mail, or change how often it arrives, go to your E-mail
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw
Need help? If you've forgotten your password, please go to Passport Member Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help
For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact
If you do not want to receive future e-mail from this MSN group, or if you received
this message by mistake, please click the "Remove" link below. On the pre-addressed
e-mail message that opens, simply click "Send". Your e-mail address will be deleted
from this group's mailing list.
mailto:[EMAIL PROTECTED]