Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Sql Server Programming

String comparison in SP


In the following SP, the @value from settingsCursor never gets set.
The default values are always returned. I have checked the values in
the table and it is indeed as in the SP.

My string comparison is not working. Am I missing something really
simple?

Riyaz

create procedure Get_GrandMarine_Mail_Settings
    @from varchar(64) out,
    @smtp varchar(64) out
as

    set @from = 'riyaz.mans@gmail.com'    -- default email-from
address
    set @smtp = 'mail.dhivehinet.net.mv'     -- default email-smtp
address

    declare @key varchar(64), @value varchar(64)

    declare settingsCursor cursor for select S_Key, S_Value from
T_Settings where S_Key LIKE 'email.%'
    open settingsCursor

    fetch next from settingsCursor into @key, @value
    while (@@FETCH_STATUS = 0)
    begin
        if @key = 'email.from' set @from = @value    -- extract email-
from address
        if @key = 'email.smtp' set @smtp = @value    -- extract email-
smtp address
        fetch next from settingsCursor
    end

    close settingsCursor
    deallocate settingsCursor

    print 'system email from address :: ' + @from
    print 'system email smtp address :: ' + @smtp

go

Hi
I tried testing but was unsure what do you  want to get out? Can you run
this script and see if it helps you?

create table T_Settings (S_Key varchar(50), S_Value varchar(50))

insert into T_Settings values ('email.from','@hotmail.com')
insert into T_Settings values ('email.from','@gmail.com')

insert into T_Settings values ('email.smtp','mail1000.dhivehinet.net.com')
insert into T_Settings values ('email.smtp','mail2000.dhivehinet.net.au')

alter procedure Get_GrandMarine_Mail_Settings
    @from varchar(64) out,
    @smtp varchar(64) out
as
 set nocount on
    set @from = 'riyaz.mans@gmail.com'    -- default email-fromaddress
    set @smtp = 'mail.dhivehinet.net.mv'     -- default email-smtpaddress

    declare @key varchar(64), @value varchar(64)

    declare settingsCursor cursor for select S_Key, S_Value from T_Settings
where S_Key LIKE 'email.%'
    open settingsCursor

    fetch next from settingsCursor into @key, @value
    while (@@FETCH_STATUS = 0)
    begin
        if @key = 'email.from' set @from = @value    -- extract email-from
address
        if @key = 'email.smtp' set @smtp = @value    -- extract email-smtp
address
        fetch next from settingsCursor
    end

    close settingsCursor
    deallocate settingsCursor

    print 'system email from address :: ' + @from
    print 'system email smtp address :: ' + @smtp

go
declare @from_o varchar(64),@smtp_o varchar(64)
exec Get_GrandMarine_Mail_Settings @from=@from_o out ,@smtp=@smtp_o out

select @from_o,@smtp_o

<riyaz.mans@gmail.com> wrote in message

news:1180344688.446680.205800@u30g2000hsc.googlegroups.com...

On 5 28 , 5 31 , "riyaz.mans@gmail.com" <riyaz.mans@gmail.com>
wrote:

while (@@FETCH_STATUS = 0)
begin
if @key = 'email.from' set @from = @value    -- extract email-rom
address
if @key = 'email.smtp' set @smtp = @value    -- extract email- smtp
address
 fetch next from settingsCursor  into @key, @value --here you lose
something :)
end
Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc