Jump to content

If..else In Sql Doubt


Recommended Posts

Posted

conditional sql using  if else blocks ela raayalo seppandi va konchem,,,,,,stored procedures lo dynamic sql asalu artham ayyi savadhu..easy ga artham ayyetattu seppandi va evarina....

Posted

PM me 

 

Nuvvu evaru raaja... naaku duplicate aa leka neney neeku duplicate aa.. gsb12.gif

Posted

Nuvvu evaru raaja... naaku duplicate aa leka neney neeku duplicate aa.. gsb12.gif

Gp
Posted

simple man...

 

if(Mustang didn't goku sneha = true) --> Your if condition

{

   he will prove paathivratyam  --- Use your sql logic here

}

else

{

he will get pisking as usual from db members.... --->if the above statement is not true or doesn't fall in that condition this will happen... if you don't have an else statement it will not do anything. it will look for the above condition, if it's true it will run or else just get to next level of statements...

}

 

current topic aitey baaga grasp chestaav ani.... gsb12.gif

 

Posted

asalu if elsr rayadaniki basic rules emanna unnaya ba.....and how it works if nested blocks are used ...eppudu e statement execute avuthundi ani  ela seppochu

simple man...

 

if(Mustang didn't goku sneha = true) --> Your if condition

{

   he will prove paathivratyam  --- Use your sql logic here

}

else

{

he will get pisking as usual from db members.... --->if the above statement is not true or doesn't fall in that condition this will happen... if you don't have an else statement it will not do anything. it will look for the above condition, if it's true it will run or else just get to next level of statements...

}

 

current topic aitey baaga grasp chestaav ani.... gsb12.gif

 

Posted

simple ee kada bhayya like all other prog langs

 

IF(CONDITION ) //condition true ayithey 

  BEGIN

      sql statments here

   END

ELSE //conditon false ayithey 

   BEGIN 

      sql statments here  

   END.

 

nested rayali ante ELSE lo malli inko IF vadali like below 

 

IF(CONDITION ) //condition true ayithey 

  BEGIN

      sql statments here

   END

ELSE //conditon false ayithey 

 BEGIN

    IF(CONDITION)

        BEGIN 

           sql statments here  

        END.

    ELSE

        BEGIN 

           sql statments here  

         END

  END

 

I am not sure if you are asking for something else. 

Posted

simple man...

 

if(Mustang didn't goku sneha = true) --> Your if condition

{

   he will prove paathivratyam  --- Use your sql logic here

}

else

{

he will get pisking as usual from db members.... --->if the above statement is not true or doesn't fall in that condition this will happen... if you don't have an else statement it will not do anything. it will look for the above condition, if it's true it will run or else just get to next level of statements...

}

 

current topic aitey baaga grasp chestaav ani.... 

 

Suneel%20%285%29.gif?1289984025

Posted

asalu if elsr rayadaniki basic rules emanna unnaya ba.....and how it works if nested blocks are used ...eppudu e statement execute avuthundi ani  ela seppochu

 

baaga amaykudu laaga unnav man...

 

lets say you have 3 customers... you want to update the data based on the input to your procedure.

 

CREATE PROC usp_updatedata

(@CountryName VARCHAR(10))

AS

BEGIN

 

IF(@CountryName = 'USA')

BEGIN

UPDATE Customer

SET ActiveFlag = 0

WHERE Country = @CountryName

END

ELSE

BEGIN

UPDATE Customer

SET ActiveFlag = 1

WHERE Country = @CountryName

END

 

END

 

If else statements are regularly used and can be used in procs and functions only since views can't handle logics...

Posted

Ne query post here..dhantlo em mistakes unayo chepoch..detail ga class chepaniki eeda profs evarana u tara

Posted

baaga amaykudu laaga unnav man...

lets say you have 3 customers... you want to update the data based on the input to your procedure.

CREATE PROC usp_updatedata
(@CountryName VARCHAR(10))
AS
BEGIN

IF(@CountryName = 'USA')
BEGIN
UPDATE Customer
SET ActiveFlag = 0
WHERE Country = @CountryName
END
ELSE
BEGIN
UPDATE Customer
SET ActiveFlag = 1
WHERE Country = @CountryName
END

END

If else statements are regularly used and can be used in procs and functions only since views can't handle logics...


Good one
Posted

baaga amaykudu laaga unnav man...

 

lets say you have 3 customers... you want to update the data based on the input to your procedure.

 

CREATE PROC usp_updatedata

(@CountryName VARCHAR(10))

AS

BEGIN

 

IF(@CountryName = 'USA')

BEGIN

UPDATE Customer

SET ActiveFlag = 0

WHERE Country = @CountryName

END

ELSE

BEGIN

UPDATE Customer

SET ActiveFlag = 1

WHERE Country = @CountryName

END

 

END

 

If else statements are regularly used and can be used in procs and functions only since views can't handle logics...

 

gp. 

 

bhayya endi ee madha osthalev. work busy aa?

 

sqlsaga.com lo kuda kotha articles rasthalev

Posted

gp. 

 

bhayya endi ee madha osthalev. work busy aa?

 

sqlsaga.com lo kuda kotha articles rasthalev

 

konni kolukoleni debbala madhyalooo irukkupoyaa man... ippudu malli shuru chestunna... india lo unna 4 months.... ippudippudey manishi laa avutunna.... mustang laa eppudu avtaanoooooooo gsb12.gif

Posted

konni kolukoleni debbala madhyalooo irukkupoyaa man... ippudu malli shuru chestunna... india lo unna 4 months.... ippudippudey manishi laa avutunna.... mustang laa eppudu avtaanoooooooo gsb12.gif

 

Good to have you back bhayya. Keep up the good work. 

Posted

Good to have you back bhayya. Keep up the good work. 

 

thanks man... I will reach your expectations... gsb12.gif

×
×
  • Create New...