Tuesday, 28 January 2014

DATABASE CONCEPTS USED IN PRO *C/C++

 


COMMIT:

EXEC SQL COMMIT WORK RELEASE;
COMMIT and COMMIT WORK are one and same. No difference in it. It is made for standards. Release is to release all the resources hold by your program.
We can also comment on commit statement using the COMMENT clause followed by soft coded literals

EXEC SQL COMMIT COMMENT ‘SAVED EMP SALARY’;
Comment clause is depreciated in the future release of oracle and transaction based on the name is introduced.

SET TRANSACTION
EXEC SQL SET TRANSACTION READ ONLY
The above code makes the transaction to the read only state. In order to exit from the read only state we have to Commit/Rollback the work.

Inline precompiler option:
EXEC ORACLE (option=value);

Naming Files:
The filenames should not contain spaces for proc. For Eg some of the filenames or directory names will contain space in windows.
Placing inside the program:

For embedding the sql statemet in PRO *C/C++:

For embedding the sql statemet in PRO *C/C++
EXEC SQL /* SQL STATEMENT GOES HERE */ ;
For embedding the PL/SQL statement.
EXec sql execute /* pl sql block goes here */ end-exec

Comments lines:
/**/ Multiline comment
You can also use the ANSI-Style comments such as (--…)
datatype equivalencing:
Giving the flexibility of using the both oracle datatype and c datatype as same type.

Shared & Private sql areas:
When two users execute the same type of  query then the oracle will execute in the shared sql area. But they will have a separate sql statement in the sql private areas. In Pro *C/C++ Cursor will name the sql statement and to some extent it  controls the sql statement.

Cursor
used for handling result of more than one dataset.  The set of rows returned is called as an active set. There are two types of cursors
1.      Implicit cursor
2.      Explicit cursor
The Explicit cursor are used to find which row is currently processing.

Transaction:
The changes that are made at two or more than two end points due to some activity. Endpoints may be the bank accounts and the changes may be the amount.

Line continuation:
If you want to  continue the same sql statement in next line then use a backslash. Maximum line length is 1299.
exec sql insert into marks values(‘vino\
th’,100,12,4\
5);


Maxliterals:
Constant used to restrict the precompiler for Maximum literal length to be allowed for the string because the C compiler may be restricted to certain length.
conditional precompilation:

Conditional precompilation statement will include
STATEMENT
DEFINITION
EXEC ORACLE DEFINE
DEFINES THE STATEMENT
EXEC ORACLE IFDEF
IF DEFINITION WAS FOUND
EXEC ORACLE IFNDEF
IF DEF NOT FOUND
EXEC ORACLE ELSE
ELSE CONDITION



Cursor in modular programming:

Pro c allows for the modular programming. Where the programs can be built in different areas and we can link them together. Cursor should be defined in  each modules because the precompiler will convert the all cursor declaration to a C statements.


Explicit lock:

EXEC SQL LOCK TABLE EMP IN ROW SHARE MODE NOWAIT;