Tuesday, 28 October 2014

How can fetch Top N Records from database. ?

Q) How can fetch Top N Records from database. ?
Ans :- Returning only the first N records in a SQL query differs quite a bit between database platforms. Here's some samples:
  
Microsoft SQL Server
    SELECT TOP 10 column FROM Table-name 
PostgreSQL and MySQL
    SELECT column FROM Table-name LIMIT 10
Oracle
SELECT column FROM Table-name WHERE ROWNUM <= 10
Firebird
SELECT FIRST 10 column FROM table
InterBase 
SELECT * FROM Table-name rows 10

Thursday, 15 May 2014

Q :) How to create table in firebird database ?
Ans :-  create table teacher(
 uid int not null,
 pid int,
 Fname varchar(50),
 Lname varchar(50),
 Qualification char(10),
 dob date,
 Address varchar(150),
 pincode char(10),
 dist varchar(50),
 state varchar(50),
 officePhNo varchar(50),
 phno varchar(50),
 mobile varchar(50),
 emailID varchar(50),
 lastupdation timestamp,
 modby varchar(50));

 alter table teacher add constraint pk_TeacherUID primary key (uid)

 create generator gn_TeacherUID

 create trigger tggBI_TeacherUID for teacher
 active before insert position 0
 as
 begin
   if (new.UID is null) then
   begin
    new.uid = gen_id(gn_teacheruid,1);
   end
 end;

Thursday, 17 April 2014

Q) How to create TStringList in delphi ?
Ans) procedure GoodTStringListUsing;
    var
      X: TStringList;
      i: Integer;
    begin
      X := TStringList.Create;
      try
        X.Add('Animals');
        X.Add('Flowers');
        X.Add('Cars');
        X.Sort; { Find will only work on sorted lists! }

        Memo1.Clear;
      for i:=0 to X.Count-1 do begin
         Memo1.Lines.Add(X.Strings[i]);
   end;
     finally
       X.Free;
   end;
end;


Sunday, 2 February 2014

Q) Explain about Delphi`s VCL?
Ans. Delphi is easier to use rather than the API`s. It has strong windows connection and Borland has made things possible for portability on windows. It has a strong library and it maps windows 32. It supports API`s for properties and events. Borland is taking enough measures for back portability for windows.
Q) What is project file in delphi?
Ans. File with .dpr extension is the project file. It comprises all the unit names used in the application along with their path in the hard disk (and the form name if the unit is associated with a .dfm file). It also instantiates the auto-create forms. We can also write code for application initialisation in begin..end blocks in .dpr file.
Q) Explain about event handler?
Ans. Use for event handlers for make sure that the transactions and operations confirm to the business code of ethic. They can significantly affect the data packets which are being sent out to the server for update. Data packets are very useful in giving critical updates at runtime.
Q ) Explain about DPR ?


Ans.Apart from two important files (PAS and DFM) there is a third file known as (DPR) or Delphi project file. Delphi project file is automatically built by the compiler. There are two ways to edit the file one is through manually and the other is through Delphi project manager. The source file which you will be seeing is a Pascal source file. 
Q) What is the use of UDL files in Delphi?
Ans. If you want to store the server connection information outside the application which can be retrieved later during connecting time. This is very useful in creating UDL files which are very helpful where hard coded connection string is not acceptable. Also try to save the documents in the form of .udl which will help you to connect databases easily.

Q) What is the procedure to access the database from Delphi ?

Ans. - To access the database the BDE needs to be configured as it defines an alias for the database that has to be connected. 

- The configuration allows the avoidance of coding the directory path and it just takes the referring of the alias. 

- The creation of three objects is required to access the database and that includes: Query or table object that in synchronization with the alias and it also fetches some data. 

- Data source object that allows the linking between the data and the controls used to connect the database. 

- Setting the active property on the table or query to TRUE will open the database and allow the accessing to be done.