SlideShare a Scribd company logo
IJAPRR Page 12
International Journal of Allied Practice, Research and Review
Website: www.ijaprr.com (ISSN 2350-1294)
Database Programming Skills
Junaida Shafi
M.Tech Student, Ganpati Institute of Management & Technology, Krukshetra University, India
littlechapjuni@gmail.com
Abstract— Databases play a very important role in application development and from decades we are using
different database technologies to manage data efficiently like relational database technology. From the
development perspective there are number of programming skills required to design a very efficient database for
data management.
Keywords— Database; RDBMS; SQL; Batches; Go; Constructs
I. INTRODUCTION
Database plays a vital role in day to day life .where ever the concept of data came, the
database word emerges. Whenever we want to store the data dynamically the concept of database is
used. Various data warehouses are being used to store the enormous amount of data and various
algorithms have been used in mining out the data from data warehouses especially when we talk
about the concept of programming in database. Various programming skills are being used which
make it easier to handle the data. The various programming skills like use of variables, conditional
constructs, iterative constructs, exceptions and have been used in SQL server to make the data
handling easy. Retrieval of data is a prime operation in database from database administrator’s
point of view.
II. BATCHES
Batches are group of statements send to SQL server for execution. The SQL server executes this
group of statement as a single executable unit called Execution Plan.
GO keyword is used to end the group of statements. We use PRINT keyword also to
display the user defined messages in case of batches. Like
<T-SQL Statements>
<T-SQL Statements>
<T-SQL Statements>
IJAPRR Page 13
….
GO
Insert into student values (1,’junaid’,’mohammad shafi’,’m-tech’)
Insert into student values (2,’farzana’,’peerzada mehraj-ud-din,’b-tech’)
Insert into student values (3,’saniya’,’zahoor Ahmed,’m-tech’)
GO
When a batch is submitted to SQL Server it is compiled to create an execution plan. The
execution plan is not created if a compilation error occurs such as syntax error it means none of the
statements will be executed.
III.USING VARIABLES
While using Batches you need to store some values temporarily during the
execution time for that purpose we use Variables. Variables are used to hold the value.
Variables are declared by using the keyword DECLARE. The name of variable is prefixed
by@ sign, and followed by the data type. Batches also allow us to perform particular
actions based on multiple conditions like.
DECLARE @variable_name data type...
Like declare @num int.
SELECT @num=SELECT sum (marks) from student.
PRINT @num.
GO
IV.CONSTRUCTS
SQL Server allows you to use programming constructs in batches for conditional
execution of statements. Whenever you need data or an output based on some particular
condition we use constructs to deal with them. We use following types of constructs in
SQL Server like:
IF…ELSE statement
CASE statement
WHILE statement
IF...ELSE is the basic type of conditional construct which is executed on the basis of a
condition. If the condition is true it is followed by group of statements .if the condition is
not true, it will be followed by the else block statements. It means if else statements always
works on Boolean expression. The syntax is:
IJAPRR Page 14
IFBoolean_expression {SQL_statement |statement_block}
ELSE
{SQL_statement |statement_block}
FOR EXAMPLE:
DECALRE @Marks int
SELECT@Marks=Marks from student where reg_id=12
IF@Marks<25
PRINT‘Review of the Marks is required’
ELSE
BEGIN
PRINT’Marks is not required to review’
PRINT @Marks
END
GO
V.USING CASE STATEMENT
We use case statements where we have to evaluate multiple conditions
simultaneously. The case statements check multiple conditions and return the one of the
possible output. If all the conditions that needed to be checked are false then the control
directly follows the default conditions. The syntax of case statement is;
CASE input_expression
WHEN when_expression THEN result_expression
[WHEN when_expression THEN result_expression] [……]
ELSE
Else_result_expression
END
Consider the following situation where a CASE construct is concluded in the
SELECT statement to display the grades of student in class.
SELECT Reg_id, Name,’Grade of Student’=case Marks
When Marks >45 then ‘Distinction’
When Marks >35 then ‘grade A’
When Marks> 25 then ‘Grade B’
ELSE ‘failed’
END
From Student
GO
IJAPRR Page 15
VI. USING WHILE STATEMENTS
While statement is a type of iterative construct where a set of SQL statements are to
be executed repeatedly as long as a given condition holds true. The syntax of while
statement is as
While boolean_expression
{SQL_statement | block_statement}
[BREAK]
{SQL_statement | block_statement}
CONTINUE
SQL Server provides the BREAK and CONTINUE statements to control the
statements within the while loop .The BREAK statements causes an exit from the while
loop .The CONTINUE statements cause the while loop to restart skipping any statement
after this statement inside the loop.
WHILE (SELECTAVG (Marks) from Student) <40
BEGIN
UPDATE Student set Marks=Marks+10 from Student
If SELECT (MAX (Marks) FromStudent)>40
Break
ELSE
CONTINUE
END
VII. ERRORS AND EXCEPTIONS
Exceptions are run time errors that can be handled in programming as well as in
database. Unlike syntax errors and logical errors when we execute a query, it is parsed for
syntactical errors before execution .if the syntax is correct, it is compiled and executed. For
example, there is a primary key constraint applied on reg. id attribute of the Student table.
When you try to insert a reg. id which already exists in the table, the error occurs while
executing the insert statement. Exceptions can be handled in SQL server in following ways:
A. By using the TRY….CATCH statement.
B. By using the RAISEERROR statement.
1) USING TRY CATCH
A TRY…CATCH construct includes a TRY block followed by a CATCH block.
A TRY block is a group of SQL statements enclosed in a batch, stored procedure, a trigger
and a function. If an error occurs in a statement of the TRY block, the control is passed on
to the block of statement followed by it called CATCH block. A CATCH block contains
SQL statement that performs action when an error occurs.
TRY
IJAPRR Page 16
<SQL statement>
…..
CATCH
<SQL statements>
…..
END CATCH
The TRY …CATCH construct can be nested. Either a TRY block or a CATCH
block can contain nested TRY…..CATCH statements.
BEGIN TRY
INSERT INTO STUDENT VALUES (1,’JUNAID SHAFI’,’NAID KADAL’,
GETDATE (), 49)
INSERT INTO STUDENT VALUES (1,’NASEER GANIE,’CHADOORA,
GETDATE (), 49)
END TRY
BEGIN CATCH
SELECT ‘THERE WAS AN ERROR ’
END CATCH
GO
2) USING RAISE ERROR
A RAISE ERROR Statement is used to return messages to the business applications
when executing the SQL statements. This statement uses the same format as the system
error or warning messages generated by database engine of the SQL server component.
Consider an application that is executing the BATCH. While executing the BATCHE an
error message will be generated and send to the application.
You can return user-defined messages by using the RAISEERROR statement .the syntax of
RAISE ERROR statement is
RAISEERROR (‘Message’, Severity, State)
Where
Message is the text you want to display.
Severity is the user defined severity level associated with the message. It represents how
severe the error is. Severity level can range from 0 to 25.the levels from 0 to 18 can be
specified by any user.
State is an integer value from 0 to 255.
For example,
BEGIN TRY
DECLARE @Start datetime
DECLARE End datetime
DECALARE @Date_diff
SELECT @Start=’1987-04-10 04:05:32:00’, @End=GETDATE ()
SELECT @Date_diff=datediff (hh, @Start, @End)
IF (@Date_diff! =8)
RAISEERROR (‘ERROR RAISED’, 16, 1)
IJAPRR Page 17
ELSE
BEGIN
UPDATE HumanResources.Shift
Set StartTime=@Start,EndTime=@End where ShiftID=3
END
END TRY
BEGIN CATCH
PRINT ‘the difference between the start and end time should be 8 hours ’
END CATCH
END
GO
VIII . ACKNOWLEDGMENT
I wish to acknowledge all the people who have worked in Database Technology and whose
work inspired me to write this research paper in Database programming. I also would like to
acknowledge my parents and my colleagues who supported me to write my first research paper and
put my ideas and research on paper as a contribution to coming generation.
IX. REFERENCES
[1]Leonard G.Lobel, Andrew J.Brust “Programming SQL Server 2012”.
[2] Grant Fritchey “SQL Server Execution Plans”.
[3]Ross Mistry, Stacia Misner “Introducing MS SQL SERVER 2012”.
[4] Patrick Leblane” MS SQL server 2012 step by step”.
[5]Paul Atkinson, Robert Vieira” Beginning MS SQL Server 2102 Programming”.
[6] Grega jerkic, Matija Lah, Dejon Sarka” Implementing a Data Warehouse with SQL Server 2012”.
[7]Brian knights, Devin Knight, Davis Wayne “KNIGH’S MICROSOFT SQL SERVER 2012 INTEGRATION
SERVICE 24_HOUR TRAINER”.
[8] Itzik Ben_Gan”Microsoft SQL Server 2012 High Performance T-Sql”.
[9] William R Stanek”Microsoft SQL Server 2012 Pocket Consultant”

More Related Content

Similar to 21 ijaprr vol1-3-12-17juni

JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
Information Technology
 
Ch3- Java Script.pdf
Ch3- Java Script.pdfCh3- Java Script.pdf
Ch3- Java Script.pdf
HASENSEID
 
Structured Query Language for Data Management 2 Sructu.docx
Structured Query Language for Data Management      2 Sructu.docxStructured Query Language for Data Management      2 Sructu.docx
Structured Query Language for Data Management 2 Sructu.docx
johniemcm5zt
 
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxCharles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
christinemaritza
 
Dot Net Accenture
Dot Net AccentureDot Net Accenture
Dot Net Accenture
Sri K
 
Assignment#08
Assignment#08Assignment#08
Assignment#08
Sunita Milind Dol
 
Linq
LinqLinq
SQL interview questions jeetendra mandal - part 5
SQL interview questions jeetendra mandal - part 5SQL interview questions jeetendra mandal - part 5
SQL interview questions jeetendra mandal - part 5
jeetendra mandal
 
Sql injection
Sql injectionSql injection
Sql injection
Mehul Boghra
 
Ebook7
Ebook7Ebook7
Ebook7
kaashiv1
 
Sql interview question part 7
Sql interview question part 7Sql interview question part 7
Sql interview question part 7
kaashiv1
 
LEARN C#
LEARN C#LEARN C#
LEARN C#
adroitinfogen
 
Iwt note(module 2)
Iwt note(module 2)Iwt note(module 2)
Iwt note(module 2)
SANTOSH RATH
 
Ebook11
Ebook11Ebook11
Ebook11
kaashiv1
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
ch samaram
 
CP Handout#10
CP Handout#10CP Handout#10
CP Handout#10
trupti1976
 
PLSQL
PLSQLPLSQL
Using triggers in my sql database
Using triggers in my sql databaseUsing triggers in my sql database
Using triggers in my sql database
Mbarara University of Science and technology
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
kenatmxm
 
Module04
Module04Module04
Module04
Sridhar P
 

Similar to 21 ijaprr vol1-3-12-17juni (20)

JDBC – Java Database Connectivity
JDBC – Java Database ConnectivityJDBC – Java Database Connectivity
JDBC – Java Database Connectivity
 
Ch3- Java Script.pdf
Ch3- Java Script.pdfCh3- Java Script.pdf
Ch3- Java Script.pdf
 
Structured Query Language for Data Management 2 Sructu.docx
Structured Query Language for Data Management      2 Sructu.docxStructured Query Language for Data Management      2 Sructu.docx
Structured Query Language for Data Management 2 Sructu.docx
 
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docxCharles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
Charles WilliamsCS362Unit 3 Discussion BoardStructured Query Langu.docx
 
Dot Net Accenture
Dot Net AccentureDot Net Accenture
Dot Net Accenture
 
Assignment#08
Assignment#08Assignment#08
Assignment#08
 
Linq
LinqLinq
Linq
 
SQL interview questions jeetendra mandal - part 5
SQL interview questions jeetendra mandal - part 5SQL interview questions jeetendra mandal - part 5
SQL interview questions jeetendra mandal - part 5
 
Sql injection
Sql injectionSql injection
Sql injection
 
Ebook7
Ebook7Ebook7
Ebook7
 
Sql interview question part 7
Sql interview question part 7Sql interview question part 7
Sql interview question part 7
 
LEARN C#
LEARN C#LEARN C#
LEARN C#
 
Iwt note(module 2)
Iwt note(module 2)Iwt note(module 2)
Iwt note(module 2)
 
Ebook11
Ebook11Ebook11
Ebook11
 
Javascript sivasoft
Javascript sivasoftJavascript sivasoft
Javascript sivasoft
 
CP Handout#10
CP Handout#10CP Handout#10
CP Handout#10
 
PLSQL
PLSQLPLSQL
PLSQL
 
Using triggers in my sql database
Using triggers in my sql databaseUsing triggers in my sql database
Using triggers in my sql database
 
Intro to iOS Development • Made by Many
Intro to iOS Development • Made by ManyIntro to iOS Development • Made by Many
Intro to iOS Development • Made by Many
 
Module04
Module04Module04
Module04
 

More from ijaprr_editor

32 ijaprr vol1-4-36-42ramesh
32 ijaprr vol1-4-36-42ramesh32 ijaprr vol1-4-36-42ramesh
32 ijaprr vol1-4-36-42ramesh
ijaprr_editor
 
31 ijaprr vol1-4-29-35harmeet
31 ijaprr vol1-4-29-35harmeet31 ijaprr vol1-4-29-35harmeet
31 ijaprr vol1-4-29-35harmeet
ijaprr_editor
 
30 ijaprr vol1-4-24-28syed
30 ijaprr vol1-4-24-28syed30 ijaprr vol1-4-24-28syed
30 ijaprr vol1-4-24-28syed
ijaprr_editor
 
29 ijaprr vol1-4-14-23kishor
29 ijaprr vol1-4-14-23kishor29 ijaprr vol1-4-14-23kishor
29 ijaprr vol1-4-14-23kishor
ijaprr_editor
 
28 ijaprr vol1-4-01-13ritaaabi
28 ijaprr vol1-4-01-13ritaaabi28 ijaprr vol1-4-01-13ritaaabi
28 ijaprr vol1-4-01-13ritaaabi
ijaprr_editor
 
27 ijaprr vol1-3-47-53dharam
27 ijaprr vol1-3-47-53dharam27 ijaprr vol1-3-47-53dharam
27 ijaprr vol1-3-47-53dharam
ijaprr_editor
 
26 ijaprr vol1-3-42-46praveen
26 ijaprr vol1-3-42-46praveen26 ijaprr vol1-3-42-46praveen
26 ijaprr vol1-3-42-46praveen
ijaprr_editor
 
25 ijaprr vol1-3-38-41nagaveni
25 ijaprr vol1-3-38-41nagaveni25 ijaprr vol1-3-38-41nagaveni
25 ijaprr vol1-3-38-41nagaveni
ijaprr_editor
 
24 ijaprr vol1-3-32-37nasir
24 ijaprr vol1-3-32-37nasir24 ijaprr vol1-3-32-37nasir
24 ijaprr vol1-3-32-37nasir
ijaprr_editor
 
23 ijaprr vol1-3-25-31iqra
23 ijaprr vol1-3-25-31iqra23 ijaprr vol1-3-25-31iqra
23 ijaprr vol1-3-25-31iqra
ijaprr_editor
 
22 ijaprr vol1-3-18-24babita
22 ijaprr vol1-3-18-24babita22 ijaprr vol1-3-18-24babita
22 ijaprr vol1-3-18-24babita
ijaprr_editor
 
20 ijaprr vol1-3-7-11tushar
20 ijaprr vol1-3-7-11tushar20 ijaprr vol1-3-7-11tushar
20 ijaprr vol1-3-7-11tushar
ijaprr_editor
 
19 ijaprr vol1-3-1-6dkpandey
19 ijaprr vol1-3-1-6dkpandey19 ijaprr vol1-3-1-6dkpandey
19 ijaprr vol1-3-1-6dkpandey
ijaprr_editor
 
Ijaprr vol1-2-18-92-96laxmiv1
Ijaprr vol1-2-18-92-96laxmiv1Ijaprr vol1-2-18-92-96laxmiv1
Ijaprr vol1-2-18-92-96laxmiv1
ijaprr_editor
 
Ijaprr vol1-2-17-85-91shailesh
Ijaprr vol1-2-17-85-91shaileshIjaprr vol1-2-17-85-91shailesh
Ijaprr vol1-2-17-85-91shailesh
ijaprr_editor
 
Ijaprr vol1-2-16-80-84laxmi
Ijaprr vol1-2-16-80-84laxmiIjaprr vol1-2-16-80-84laxmi
Ijaprr vol1-2-16-80-84laxmi
ijaprr_editor
 
Ijaprr vol1-2-15-74-79rajeshshiv
Ijaprr vol1-2-15-74-79rajeshshivIjaprr vol1-2-15-74-79rajeshshiv
Ijaprr vol1-2-15-74-79rajeshshiv
ijaprr_editor
 
Ijaprr vol1-2-14-65-73rmpawar
Ijaprr vol1-2-14-65-73rmpawarIjaprr vol1-2-14-65-73rmpawar
Ijaprr vol1-2-14-65-73rmpawar
ijaprr_editor
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
ijaprr_editor
 
Ijaprr vol1-2-12-47-59ajizahmad
Ijaprr vol1-2-12-47-59ajizahmadIjaprr vol1-2-12-47-59ajizahmad
Ijaprr vol1-2-12-47-59ajizahmad
ijaprr_editor
 

More from ijaprr_editor (20)

32 ijaprr vol1-4-36-42ramesh
32 ijaprr vol1-4-36-42ramesh32 ijaprr vol1-4-36-42ramesh
32 ijaprr vol1-4-36-42ramesh
 
31 ijaprr vol1-4-29-35harmeet
31 ijaprr vol1-4-29-35harmeet31 ijaprr vol1-4-29-35harmeet
31 ijaprr vol1-4-29-35harmeet
 
30 ijaprr vol1-4-24-28syed
30 ijaprr vol1-4-24-28syed30 ijaprr vol1-4-24-28syed
30 ijaprr vol1-4-24-28syed
 
29 ijaprr vol1-4-14-23kishor
29 ijaprr vol1-4-14-23kishor29 ijaprr vol1-4-14-23kishor
29 ijaprr vol1-4-14-23kishor
 
28 ijaprr vol1-4-01-13ritaaabi
28 ijaprr vol1-4-01-13ritaaabi28 ijaprr vol1-4-01-13ritaaabi
28 ijaprr vol1-4-01-13ritaaabi
 
27 ijaprr vol1-3-47-53dharam
27 ijaprr vol1-3-47-53dharam27 ijaprr vol1-3-47-53dharam
27 ijaprr vol1-3-47-53dharam
 
26 ijaprr vol1-3-42-46praveen
26 ijaprr vol1-3-42-46praveen26 ijaprr vol1-3-42-46praveen
26 ijaprr vol1-3-42-46praveen
 
25 ijaprr vol1-3-38-41nagaveni
25 ijaprr vol1-3-38-41nagaveni25 ijaprr vol1-3-38-41nagaveni
25 ijaprr vol1-3-38-41nagaveni
 
24 ijaprr vol1-3-32-37nasir
24 ijaprr vol1-3-32-37nasir24 ijaprr vol1-3-32-37nasir
24 ijaprr vol1-3-32-37nasir
 
23 ijaprr vol1-3-25-31iqra
23 ijaprr vol1-3-25-31iqra23 ijaprr vol1-3-25-31iqra
23 ijaprr vol1-3-25-31iqra
 
22 ijaprr vol1-3-18-24babita
22 ijaprr vol1-3-18-24babita22 ijaprr vol1-3-18-24babita
22 ijaprr vol1-3-18-24babita
 
20 ijaprr vol1-3-7-11tushar
20 ijaprr vol1-3-7-11tushar20 ijaprr vol1-3-7-11tushar
20 ijaprr vol1-3-7-11tushar
 
19 ijaprr vol1-3-1-6dkpandey
19 ijaprr vol1-3-1-6dkpandey19 ijaprr vol1-3-1-6dkpandey
19 ijaprr vol1-3-1-6dkpandey
 
Ijaprr vol1-2-18-92-96laxmiv1
Ijaprr vol1-2-18-92-96laxmiv1Ijaprr vol1-2-18-92-96laxmiv1
Ijaprr vol1-2-18-92-96laxmiv1
 
Ijaprr vol1-2-17-85-91shailesh
Ijaprr vol1-2-17-85-91shaileshIjaprr vol1-2-17-85-91shailesh
Ijaprr vol1-2-17-85-91shailesh
 
Ijaprr vol1-2-16-80-84laxmi
Ijaprr vol1-2-16-80-84laxmiIjaprr vol1-2-16-80-84laxmi
Ijaprr vol1-2-16-80-84laxmi
 
Ijaprr vol1-2-15-74-79rajeshshiv
Ijaprr vol1-2-15-74-79rajeshshivIjaprr vol1-2-15-74-79rajeshshiv
Ijaprr vol1-2-15-74-79rajeshshiv
 
Ijaprr vol1-2-14-65-73rmpawar
Ijaprr vol1-2-14-65-73rmpawarIjaprr vol1-2-14-65-73rmpawar
Ijaprr vol1-2-14-65-73rmpawar
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
 
Ijaprr vol1-2-12-47-59ajizahmad
Ijaprr vol1-2-12-47-59ajizahmadIjaprr vol1-2-12-47-59ajizahmad
Ijaprr vol1-2-12-47-59ajizahmad
 

Recently uploaded

Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
PriyankaKilaniya
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
Prakhyath Rai
 
Object Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOADObject Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOAD
PreethaV16
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
MadhavJungKarki
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
nedcocy
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
Gino153088
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
Kamal Acharya
 
AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
mahaffeycheryld
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
IJECEIAES
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
ijaia
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
harshapolam10
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
ycwu0509
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
Prakhyath Rai
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
VANDANAMOHANGOUDA
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 

Recently uploaded (20)

Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
Prediction of Electrical Energy Efficiency Using Information on Consumer's Ac...
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
 
Object Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOADObject Oriented Analysis and Design - OOAD
Object Oriented Analysis and Design - OOAD
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
一比一原版(爱大毕业证书)爱荷华大学毕业证如何办理
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
4. Mosca vol I -Fisica-Tipler-5ta-Edicion-Vol-1.pdf
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
 
AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
 
Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...Advanced control scheme of doubly fed induction generator for wind turbine us...
Advanced control scheme of doubly fed induction generator for wind turbine us...
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
SCALING OF MOS CIRCUITS m .pptx
SCALING OF MOS CIRCUITS m                 .pptxSCALING OF MOS CIRCUITS m                 .pptx
SCALING OF MOS CIRCUITS m .pptx
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 

21 ijaprr vol1-3-12-17juni

  • 1. IJAPRR Page 12 International Journal of Allied Practice, Research and Review Website: www.ijaprr.com (ISSN 2350-1294) Database Programming Skills Junaida Shafi M.Tech Student, Ganpati Institute of Management & Technology, Krukshetra University, India littlechapjuni@gmail.com Abstract— Databases play a very important role in application development and from decades we are using different database technologies to manage data efficiently like relational database technology. From the development perspective there are number of programming skills required to design a very efficient database for data management. Keywords— Database; RDBMS; SQL; Batches; Go; Constructs I. INTRODUCTION Database plays a vital role in day to day life .where ever the concept of data came, the database word emerges. Whenever we want to store the data dynamically the concept of database is used. Various data warehouses are being used to store the enormous amount of data and various algorithms have been used in mining out the data from data warehouses especially when we talk about the concept of programming in database. Various programming skills are being used which make it easier to handle the data. The various programming skills like use of variables, conditional constructs, iterative constructs, exceptions and have been used in SQL server to make the data handling easy. Retrieval of data is a prime operation in database from database administrator’s point of view. II. BATCHES Batches are group of statements send to SQL server for execution. The SQL server executes this group of statement as a single executable unit called Execution Plan. GO keyword is used to end the group of statements. We use PRINT keyword also to display the user defined messages in case of batches. Like <T-SQL Statements> <T-SQL Statements> <T-SQL Statements>
  • 2. IJAPRR Page 13 …. GO Insert into student values (1,’junaid’,’mohammad shafi’,’m-tech’) Insert into student values (2,’farzana’,’peerzada mehraj-ud-din,’b-tech’) Insert into student values (3,’saniya’,’zahoor Ahmed,’m-tech’) GO When a batch is submitted to SQL Server it is compiled to create an execution plan. The execution plan is not created if a compilation error occurs such as syntax error it means none of the statements will be executed. III.USING VARIABLES While using Batches you need to store some values temporarily during the execution time for that purpose we use Variables. Variables are used to hold the value. Variables are declared by using the keyword DECLARE. The name of variable is prefixed by@ sign, and followed by the data type. Batches also allow us to perform particular actions based on multiple conditions like. DECLARE @variable_name data type... Like declare @num int. SELECT @num=SELECT sum (marks) from student. PRINT @num. GO IV.CONSTRUCTS SQL Server allows you to use programming constructs in batches for conditional execution of statements. Whenever you need data or an output based on some particular condition we use constructs to deal with them. We use following types of constructs in SQL Server like: IF…ELSE statement CASE statement WHILE statement IF...ELSE is the basic type of conditional construct which is executed on the basis of a condition. If the condition is true it is followed by group of statements .if the condition is not true, it will be followed by the else block statements. It means if else statements always works on Boolean expression. The syntax is:
  • 3. IJAPRR Page 14 IFBoolean_expression {SQL_statement |statement_block} ELSE {SQL_statement |statement_block} FOR EXAMPLE: DECALRE @Marks int SELECT@Marks=Marks from student where reg_id=12 IF@Marks<25 PRINT‘Review of the Marks is required’ ELSE BEGIN PRINT’Marks is not required to review’ PRINT @Marks END GO V.USING CASE STATEMENT We use case statements where we have to evaluate multiple conditions simultaneously. The case statements check multiple conditions and return the one of the possible output. If all the conditions that needed to be checked are false then the control directly follows the default conditions. The syntax of case statement is; CASE input_expression WHEN when_expression THEN result_expression [WHEN when_expression THEN result_expression] [……] ELSE Else_result_expression END Consider the following situation where a CASE construct is concluded in the SELECT statement to display the grades of student in class. SELECT Reg_id, Name,’Grade of Student’=case Marks When Marks >45 then ‘Distinction’ When Marks >35 then ‘grade A’ When Marks> 25 then ‘Grade B’ ELSE ‘failed’ END From Student GO
  • 4. IJAPRR Page 15 VI. USING WHILE STATEMENTS While statement is a type of iterative construct where a set of SQL statements are to be executed repeatedly as long as a given condition holds true. The syntax of while statement is as While boolean_expression {SQL_statement | block_statement} [BREAK] {SQL_statement | block_statement} CONTINUE SQL Server provides the BREAK and CONTINUE statements to control the statements within the while loop .The BREAK statements causes an exit from the while loop .The CONTINUE statements cause the while loop to restart skipping any statement after this statement inside the loop. WHILE (SELECTAVG (Marks) from Student) <40 BEGIN UPDATE Student set Marks=Marks+10 from Student If SELECT (MAX (Marks) FromStudent)>40 Break ELSE CONTINUE END VII. ERRORS AND EXCEPTIONS Exceptions are run time errors that can be handled in programming as well as in database. Unlike syntax errors and logical errors when we execute a query, it is parsed for syntactical errors before execution .if the syntax is correct, it is compiled and executed. For example, there is a primary key constraint applied on reg. id attribute of the Student table. When you try to insert a reg. id which already exists in the table, the error occurs while executing the insert statement. Exceptions can be handled in SQL server in following ways: A. By using the TRY….CATCH statement. B. By using the RAISEERROR statement. 1) USING TRY CATCH A TRY…CATCH construct includes a TRY block followed by a CATCH block. A TRY block is a group of SQL statements enclosed in a batch, stored procedure, a trigger and a function. If an error occurs in a statement of the TRY block, the control is passed on to the block of statement followed by it called CATCH block. A CATCH block contains SQL statement that performs action when an error occurs. TRY
  • 5. IJAPRR Page 16 <SQL statement> ….. CATCH <SQL statements> ….. END CATCH The TRY …CATCH construct can be nested. Either a TRY block or a CATCH block can contain nested TRY…..CATCH statements. BEGIN TRY INSERT INTO STUDENT VALUES (1,’JUNAID SHAFI’,’NAID KADAL’, GETDATE (), 49) INSERT INTO STUDENT VALUES (1,’NASEER GANIE,’CHADOORA, GETDATE (), 49) END TRY BEGIN CATCH SELECT ‘THERE WAS AN ERROR ’ END CATCH GO 2) USING RAISE ERROR A RAISE ERROR Statement is used to return messages to the business applications when executing the SQL statements. This statement uses the same format as the system error or warning messages generated by database engine of the SQL server component. Consider an application that is executing the BATCH. While executing the BATCHE an error message will be generated and send to the application. You can return user-defined messages by using the RAISEERROR statement .the syntax of RAISE ERROR statement is RAISEERROR (‘Message’, Severity, State) Where Message is the text you want to display. Severity is the user defined severity level associated with the message. It represents how severe the error is. Severity level can range from 0 to 25.the levels from 0 to 18 can be specified by any user. State is an integer value from 0 to 255. For example, BEGIN TRY DECLARE @Start datetime DECLARE End datetime DECALARE @Date_diff SELECT @Start=’1987-04-10 04:05:32:00’, @End=GETDATE () SELECT @Date_diff=datediff (hh, @Start, @End) IF (@Date_diff! =8) RAISEERROR (‘ERROR RAISED’, 16, 1)
  • 6. IJAPRR Page 17 ELSE BEGIN UPDATE HumanResources.Shift Set StartTime=@Start,EndTime=@End where ShiftID=3 END END TRY BEGIN CATCH PRINT ‘the difference between the start and end time should be 8 hours ’ END CATCH END GO VIII . ACKNOWLEDGMENT I wish to acknowledge all the people who have worked in Database Technology and whose work inspired me to write this research paper in Database programming. I also would like to acknowledge my parents and my colleagues who supported me to write my first research paper and put my ideas and research on paper as a contribution to coming generation. IX. REFERENCES [1]Leonard G.Lobel, Andrew J.Brust “Programming SQL Server 2012”. [2] Grant Fritchey “SQL Server Execution Plans”. [3]Ross Mistry, Stacia Misner “Introducing MS SQL SERVER 2012”. [4] Patrick Leblane” MS SQL server 2012 step by step”. [5]Paul Atkinson, Robert Vieira” Beginning MS SQL Server 2102 Programming”. [6] Grega jerkic, Matija Lah, Dejon Sarka” Implementing a Data Warehouse with SQL Server 2012”. [7]Brian knights, Devin Knight, Davis Wayne “KNIGH’S MICROSOFT SQL SERVER 2012 INTEGRATION SERVICE 24_HOUR TRAINER”. [8] Itzik Ben_Gan”Microsoft SQL Server 2012 High Performance T-Sql”. [9] William R Stanek”Microsoft SQL Server 2012 Pocket Consultant”