Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2010

    Question Unanswered: Removing Data From Tables Automatically

    Good morning everyone!

    Good staff, to needing a little help from you.

    I have two tables I need to remove data automatically.
    To add data, even I would add, just need something that removes the data so that win 30 days.

    'm Doing at the moment as follows.
    A user makes a donation of a certain sum of money and get a VIP account on my site and will have certain rights for 30 days.
    Alas, I note in a notebook the day he will win the VIP user, I manually in sql server 2008 r2 standard and add the data manually and when they complete these 30 days, I have to go back and delete data .


    Name of the 1st table: user_dir
    Columns: user_id, nome_user, nick_user, level;
    Actions: suppose there is already a registered user on my site: user_id = '1', name_user =' Charles ', nick_user =' Carlito ', level = '1';
    Then I add the prefix [VIP] nick_user the number 30 and the level of the user eg nick_user = '[VIP]Carlito', level = '30 ';

    Name of 2nd table: user_direitos
    Columns: user_id, direito_id, direito_nivel, date;
    Action: Add the following data tables: user_id = '1 ', direito_id = '8', direito_nivel = '30 ', date = '22/11/2010 12:06:00' (date of registration as vip);

    Description of table columns: user_dir
    user_id: ID number of the registered user.
    nome_user: user login name.
    nick_user: Display name of the user on the site.
    Level: Level of knowledge.

    Description of table columns: user_direitos
    user_id: ID number of the registered user.
    direito_id: Identification of privilege.
    Example: direito_id = '1 '-> privilege of access to restricted areas of reading
    Example2: direito_id = '2 '-> access privileges to read and post access to restricted areas
    direito_nivel: privilege level -> Custom level of privilege.
    Date: The date that the privilege was added to the VIP user.

    Then, after having passed the 30 days from the date that I signed up as a VIP user, something that would automatically remove these data from two tables mentioned above, and the user back to being a normal user.

    Here is an example of what I would do the job:
    Run every day at 23:59:00
    Check the column in the table user_direitos date
    If the date on which the user was added as vip reached 30 days, then remove the following data in columns and tables below:

    Remove prefix [VIP] column of the table nick_user user_dir.
    Remove value 30 column in the table level and add value user_dir 1.
    Delete a value of user_id column in the table user_direitos.
    Delete the value 8 in table column direito_id user_direitos.
    Delete the value 30 in table column direito_nivel user_direitos.
    Delete date 10/22/2010 22:00:00 column in the table user_direitos date.

    Okay, now the user returns to a normal user.

    Is it possible? Is there a way, or something that removes the data automatically once the 30 days being completed?

    Can someone show me how to do this?

    Now, thank you everyone's attention.

  2. #2
    Join Date
    Feb 2010
    This is somewhat confusing. You manually change the VIP user's status at the beginning of the 30 days, and you want to automatically revert that status at the end of the 30 days. Is that oversimplifying the case?

    Would this work? Run a job automatically every day and check the direito_nivel field for each user. If the field is greater than zero, decrement it; you can now tell the user how many days he has left as a VIP. If the decrement gives a zero result, remove the VIP label and change the user's level back to 1.

  3. #3
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    I'd probably just store the date when the VIP expired instead of when it started, then code appropriately.

    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts