Wednesday 9 January 2013

Basic Sql Queries


Here we provide some basic sql queries-DDL,DML
DDL-Data Definition Language
DML-Data Manipulation Language
Data Definition Language:
  • Create-Used to create the table.
  • Alter-used to change the structure of the table.
  • Drop-Used to delete the data and structure of the table.
  • Truncate-Used to remove all record from the table, but not the table structure.
  • Rename-used to change or rename the table name.
Creating a Table :
create table emp(empno number(4),ename varchar2(25),job varchar2(10),sal number(7),hiredate date);
Altering  a  Table :
alter table emp add(address varchar2(25));
Dropping a Table :
drop table emp;
Truncate :
truncate table emp;
Renaming a Table :
rename emp to emp;
Data Manipulation Language:

  • Selectretrieving data from the a table.
  • Insert - insert the data into a table.
  • Update - updates the existing data within a table.
  • Delete - deletes all records from a table, the space for the records remain same.
Select Query:
select * from emp;
Insert query:
inserti nto emp values (101,'PRASATH','ENGINEER',6000, '01_jan_07' );
Inserting a value by interface:
insert into emp values (&empno,'&ename','&job',&sal,&hiredate);
Enter value for empno: 101
Enter value for ename: Dhinesh
Enter value for job: Manager
Enter value for hiredate:23_apr_09
Enter value for sal: 10000
Update query:
update emp set sal=1000 where sal=500;
Delete query:
delete from emp where empno=7499;

Sunday 16 December 2012

Coding Standards:(c#)

 Introduction

     In this session we are going to be see the Naming Conventions, Coding Style, Language Usage, and Object Model Design.The goal is to define guidelines to enforce consistent style and formatting and help developers avoid common pitfalls and mistakes.

Camel Case 
  • A word with the first letter lowercase, and the first letter of each subsequent word-part capitalized.  
 Example: customerName


Pascal Case 
  • A word with the first letter capitalized, and the first letter of each subsequent word-part capitalized.  
Example: CustomerName

General Guidelines

  1. Always use Camel Case or Pascal Case names.
  2. Avoid ALL CAPS and all lowercase names. Single lowercase words or letters are acceptable.
  3. Do not create declarations of the same type (namespace, class, method, property, field, or parameter) and access modifier (protected, public, private) that vary only by capitalization.
  4. Do not use names that begin with a numeric character.
  5. Always choose meaningful and specific names.
  6. Avoid naming conflicts with existing .NET Framework namespaces, or types.
  7. Avoid adding redundant or meaningless prefixes and suffixes to identifiers

Name Usage & Syntax

Source File

Pascal Case.
  • Always match Class name and file name.
Example:
MyClass.cs  =>  public class MyClass  {…}


Method

Pascal Case.
Example:
public void Execute()  {…}


Variable

Camel Case.
  • Avoid using single characters like “x” or“y” except in FOR loops.  
  • Avoid enumerating variable names like text1, text2, text3 etc

Parameter

Camel Case.

Example:public void Execute(string commandText, int iterations)  {…}

Coding Style- Format ting

  1. Never declare more than 1 namespace per file.
  2. Avoid putting multiple classes in a single file.
  3. Always place curly braces ({ and }) on a new line.
  4. Always use curly braces ({ and }) in conditional statements.
  5. Always use a Tab & Indention size of 4.
  6. Declare each variable independently – not in the same statement



Coding Style- Commenting

  • All comments should be written in the same language, be grammatically correct, and contain appropriate punctuation.
  •  Use // or /// but never /* … */
Example:
    // ***************************************
   // Comment block
    // ***************************************

Coding Style- Flow Control

  • Only use switch/case statements for simple operations with parallel conditional logic.
  •  Prefer nested if/else over switch/case for short conditional sequences and complex conditions.
  •  Prefer polymorphism over switch/case to encapsulate and delegate complex operations. 
  • Do not use try/catch blocks for flow-control.
  •  Only catch exceptions that you can handle.
  • Never declare an empty catch block.
  • Avoid nesting a try/catch within a catch block.
  • Always catch the most derived exception via exception filters

Coding Style - exception

  • If re-throwing an exception, preserve the original call stack by omitting the exception argument from the throw statement.
Example:
// Not good
catch(Exception ex)
{
 Log(ex);
throw ex;
}
// Good!
catch(Exception)
{
 Log(ex);
throw;
}