How to give restriction on through Upload Date??

  • Sir,

    I have a table called project, in this table i have 2 columns date(datetime) and project(text). Now I want to give restriction in such a way that if I give a certain date to upload the project, then after that date is over, noone can further input anything in the project column.

    Hope I can make you understand my problem.

    I don't know how to do this, please help me!

    ----------------------------------------
    Daipayan
    A Beginner to the World of DBMS!
    ----------------------------------------
  • Hi,

    Your condition (ie the certain date to upload the project) with in the table column or in the separate table or thro parameters.

    ARUN SAS

  • The condition should be in another table column where only date will be provided.

    ----------------------------------------
    Daipayan
    A Beginner to the World of DBMS!
    ----------------------------------------
  • Hi,

    try this trigger

    CREATE TRIGGER Main_TABLE_TRG

    ON MAIN_TABLE

    FOR INSERT

    AS

    BEGIN

    declare

    @date datetime,

    @proj varchar(100)

    select @date1 = date,@proj = project

    FROM INSERTED

    If not exists (select 1 from second_table

    where proj = @proj

    and getdate()/*or @date1*/ between valid_from and valid_to)

    begin

    RAISERROR ('Project updating/ inserting expiries', 16, 1)

    return

    end

    END

    MAIN_TABLE

    (

    date datetime,

    project varchar(100)

    )

    second_table

    (

    proj varchar(100),

    valid_from datetime,

    valid_to datetime

    )

    ARUN SAS

  • Thanks for replying.

    I'll check the T-SQL and reply you back soon.

    Thanks again!

    ----------------------------------------
    Daipayan
    A Beginner to the World of DBMS!
    ----------------------------------------
  • Sir,

    In second_table, i inserted following data:

    ----------------------------

    proj | valid_from | valid_to

    ----------------------------

    ABCD 1/7/2009 7/7/2009

    ----------------------------

    and in MAIN_TABLE:

    --------------------

    date | project

    --------------------

    5/7/2009 ABCD

    7/7/2009 ABCD

    8/7/2009 ABCD

    --------------------

    MAIN_TABLE taking the project on 8/7/2009 without giving the alert.

    and am not understanding where is the problem in TRIGGER!

    please help!

    ----------------------------------------
    Daipayan
    A Beginner to the World of DBMS!
    ----------------------------------------

Viewing 6 posts - 1 through 5 (of 5 total)

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