How to code for already exist date message in my porcedure?

  • Hai friends ,

    i m creating web application behind using sql server 2000

    these is my table structure:

    create table journey

    (

    joureny_id int identity,

    user_id varchar(100) fk references users(user_id),

    departuredate datetime,

    from varchar(100),

    to char(100),

    is_draft varchar(100)

    )

    create table users

    (

    user_id varchar(100) PK,

    username varchar(50),

    password varchar(50)

    )

    in users table:

    ===========

    insert into users values('002258','ram','rama@123')

    in travel_request

    ============

    insert into travel_request(user_id , departuredate,from,to,is_draft)('002258','01-jul-2013','A','B',' ')

    insert into travel_request(user_id , departuredate,from,to,is_draft)('002258','02-jul-2013','c','D',' ')

    now My requirement is:

    ================

    1)when the same user_id is trying to insert date for already exist date means want to show error mesaage whe n i press the button of draft?

    2)if is it new date means update colmun depends on request_id

    " is_draft='Y' " (i.e allow to draft)

    how to do that?

  • raghuldrag (7/25/2013)


    now My requirement is:

    ================

    1)when the same user_id is trying to insert date for already exist date means want to show error mesaage whe n i press the button of draft?

    2)if is it new date means update colmun depends on request_id

    " is_draft='Y' " (i.e allow to draft)

    how to do that?

    This really is NOT a sql question. You are asking how to do this in an application. It is really straight forward.

    Your button click event would be something like this:

    if (the date already exists for the current user with the date specified)

    {

    throw exception "Some message about date exists"

    }

    else

    {

    Execute sql to update the date.

    }

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply