Approaches to the database programming

Approaches to the Database Programming

Table of Contents

The interactive interface is convenient for the schema and also to create constraint or to write ad hoc queries sometimes. The primary of the database interactions will be executed through the programs which will have carefully designed and been tested. 

These programs will be generally known as the application programs or the database applications, which are used as canned transactions by the end users.

We can also combine the Structured Query Language into the high level languages so that it will be easy to perform the logic parts of the analysis and some of the languages where we can combine the structured query language is 

  1. C++ language
  2. Java programming language 
  3. Python programming language and etc

Another use of the database programming is to take the database through an application program which will implement a Web interface.

Consider an example, when we are making airline reservations or online purchases. Here the Web electronic commerce applications includes some of the database access commands.

1.Embedding database commands:

In this the database declaration will be embedded into the host programming language which will be recognised  by the special prefix.

Lets Consider the example: prefix for the embedded SQL which will be the string EXEC SQL which heads all the Structured Query Language commands in the host programming language program.

Precompiler or we can say that the preprocessor which will scan the source program code will identify the database statements and extracts them for the processing by the database management system.

They will be replaced in the program by the function calls database management system generated code and this technique will be referred by the embedded SQL

2.Using library database function:

Library of the function which has been accessible to the host programming language for the table in the database calls. Lets consider an example: there will be function to connect to the database, to execute the query, execute update, and so on.

The Actual database query and the update commands and other necessary information will be included as parameters in the function calls and this approach will provide what is best known as an application programming interface where we can access the database from the application programs

3.Designing brand new language:

Database programming language will be designed from starting to be compatible with the database model and query language.

Programming structure like loops and conditional statements will be added to the database language which will convert it into full programming language.

Connecting to the database

SQL command will be established connection to the database which has form:

CONNECT  TO   THE <  server  name  >  AS   <  connection   name   >

AUTHORIZATION  OF  <  user account name  and  password  >  ;

  1. Int loop;
  1. EXEC SQL BEGIN DECLARE SECTION;
  1. Varchar dname, fname, lname, address;
  1. Char ssn, bdate, sex, minit;
  1. Float salary, raise;
  1. Int dno, dnumber;
  1. int SQLCODE; char SQLSTATE;
  1. EXEC SQL END DECLARE SECTION;

User or the program will access the database servers, several connections will be established but only one active at any point will be in time.

Programmer will use <  connection name > so that they can change from currently active connection to the different using commands like:

SET CONNECTION < connection name >;

Once connection will be no longer needed it will be terminated by command:

DISCONNECT < connection name>;

Communicating between program and database management system using SQL code will have special communication variable which are used by the database management system to communicate exception or may be error conditions to the program which are SQL CODE.

SQLCA which is SQL communicating area will be referred as the SQLCA. SQLCODE where this will be used by the command:

EXEC SQL include SQLCA ;

Later version of the SQL variable will be known as the SQL STATE which was added and which has five characters. 

In the SQL state if the value is 0000 then it indicates no error or exception

Questions

  1. Which are the approaches of database?
  1. How can you connect to the data base write command?
  2. Write a program how to connect to database

4 Responses

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share this article
Subscribe
By pressing the Subscribe button, you confirm that you have read our Privacy Policy.
Need a Free Demo Class?
Join H2K Infosys IT Online Training
Enroll Free demo class