Click here to Skip to main content
16,016,744 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Frnds,
I have three tables with city,State,Country.In one Stored Procedure i need to insert,update ,select three table values.For that i need nested if Stored Procedure Flow.
for eg.: i am passing all my values from C# pages to stored procedure...
id,name,type(city,state,country),process(insert,select,update)
if i pass value as City.First i need to check whether that city name is already exist or not.after that if not exist i need to save,other wise i need to pass value to C# page as "Already Exist"...Same thing have to be do for State,Country
Posted
Comments
Patel Shailendra 3-Dec-12 10:51am    
how many columns in your table id and name or more what's the purpose of city,state,country if is cascading then use separate table for city,state and country

or

you have to store in this table your client info then also create three table and make cascading relationship between them and store id of city,state,country in user table
itsureshuk 4-Dec-12 0:06am    
i have three tables(city state country)...I need one stored procedure ,if i am going to insert city details, i have to check, whether same city name is already exist, if not exist have to insert,otherwise if exist have to return a value 10 or anything...so that i can show message as already exist in User form

1 solution

HI,

Tou can try like this.

SQL
IF EXISTS(select * from city where Name = 'abc')
{
     return "already exists";
}
ELSE
{
    IF(status = "update")
    { //write your update code here...}
    ELSE IF(status = "insert")
    {  //Write your insert query here...}
    ELSE
    { //select query...}

}


Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900