Friday, August 31, 2012

Wednesday, August 22, 2012

Trigger

In a DBMS, a trigger is a SQL procedure that initiates an action (i.e., fires an action) when an event (INSERT, DELETE or UPDATE) occurs. Since triggers are event-driven specialized procedures, they are stored in and managed by the DBMS. A trigger cannot be called or executed; the DBMS automatically fires the trigger as a result of a data modification to the associated table. Triggers are used to maintain the referential integrity of data by changing the data in a systematic fashion.
Each trigger is attached to a single, specified table in the database.
Triggers can be viewed as similar to stored procedures in that both consist of procedural logic that is stored at the database level. Stored procedures, however, are not event-drive and are not attached to a specific table as triggers are. Stored procedures are explicitly executed by invoking a CALL to the procedure while triggers are implicitly executed. In addition, triggers can also execute stored procedures.


CREATE TRIGGER [dbo].[TrTermCondition] ON [dbo].[TermCondition]
FOR INSERT, UPDATE, DELETE
AS

DECLARE @VendorID AS INT

    IF EXISTS (SELECT 1 FROM INSERTED)
    BEGIN
        SELECT  @VendorID = VendorID                  
        FROM    INSERTED       
           
        UPDATE    BUYER
        SET        IsSalesTermsAccepted = 0,
                ModifiedDt = getDate(),
                ModifiedUserID = 55   
        FROM    Buyer B               
            INNER JOIN VendorBuyers VB ON VB.BuyerID = B.ID   
           
        WHERE    VB.VendorID = @VendorID                       
    END


Two special tables are used in trigger statements: the deleted table and the inserted table. Microsoft® SQL Server automatically creates and manages these tables. You can use these temporary, memory-resident tables to test the effects of certain data modifications and to set conditions for trigger actions; however, you cannot alter the data in the tables directly.
The inserted and deleted tables are used primarily in triggers to:
  • Extend referential integrity between tables.
  • Insert or update data in base tables underlying a view.
  • Check for errors and take action based on the error.
  • Find the difference between the state of a table before and after a data modification and take action(s) based on that difference.







Friday, August 17, 2012

Infosys launches unified cloud management solution



Infosys Technologies today launched a new solution -- Infosys Cloud Ecosystem Hub -- which will help companies manage their cloud applications and infrastructure through a single platform.

Cloud computing allows storage of data and access to software on a pay-per-use model, helping companies to cut costs as they do not have to invest in infrastructure.

"After 5-7 years, 60 per cent of the IT workload is expected to be on the cloud, which is a mix of public and private cloud. The solution is aimed to help companies manage fragmented IT environment, providing a unified platform and seamless experience," Infosys vice president and global head (cloud), Vishnu Bhat said.

Using the solution, businesses can accelerate time-to-market of cloud services by up to 40 per cent, improve productivity by up to 20 per cent and achieve cost-savings of up to 30 per cent, he added.


Read more

Wednesday, August 1, 2012

Piramid printing...

One of my friend asked me to do a homework 4 him, ie to display alphabets in a piramid mode like



I ve made a console application with the following codes.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgramContest
{
    class Program
    {
        static void Main(string[] args)
        {
            Program p = new Program();
            p.printFn();
        }

        private void printFn()
        {
            string[] ar = new string[] {"A","B","C","D","E","F" };

            int len = ar.Length - 1;
            while (!string.IsNullOrEmpty(ar[0]))
            {               
                foreach (string s in ar)
                {
                    Console.Write(s != string.Empty ? s : " ");
                }

                for (int i = ar.Length - 2; i >= 0; i--)
                {
                    Console.Write(ar[i] != string.Empty ? ar[i] : " ");
                }

                Console.Write(Environment.NewLine);
                ar[len] = string.Empty;
                len--;
            }

            Console.Write(Environment.NewLine);
            Console.Write(Environment.NewLine);
            Console.WriteLine("press any key to exit");
            ConsoleKeyInfo k= Console.ReadKey();
            if (k.ToString()!=string.Empty)
            {
                Environment.Exit(0);
            }
        }
    }
}