Board index » delphi » Oracle and multiple statement TQuery

Oracle and multiple statement TQuery

I'm trying to execute more than one SQL statement in a single TQuery
component (example, two insert statement in two different tables).
MS-SQL let us do that without problem but oracle don't let us do through
BDE. We are trying to build a program that can run sql scripts. Is it
possible to do this with delphi and Oracle?

 

Re:Oracle and multiple statement TQuery


You have two choices.  Use a stored procedure or modify the SQL property
of the TQuery and ExecSQL twice.  The latter would seem the easiest.
Same applies to all SQL databases via the BDE. (Actually, a third option
is to create a subclass of TQuery that handles multiple queries, but I
think somebody already has done that.  Check out the third-party Delphi
tools sites.)

Quote
Eric Giguere wrote:

> I'm trying to execute more than one SQL statement in a single TQuery
> component (example, two insert statement in two different tables).
> MS-SQL let us do that without problem but oracle don't let us do through
> BDE. We are trying to build a program that can run sql scripts. Is it
> possible to do this with delphi and Oracle?

Re:Oracle and multiple statement TQuery


You can use a TQuery to execute PL/SQL blocks against Oracle by surrounding
the statements in a begin/end pair and using ExecSQL.  Since this is
pass-thru SQL, don't forget to use appropriate punctuation conformant with
PL/SQL rules.  For example:

begin
  insert into customer (last_name) values ('Smith');
  insert into vendor (company_name) values ('Borland');
end;

Note that if you use the "declare" portion of the PL/SQL block, you need an
extra begin/end pair (don't know why), and that you can perform PL/SQL
exception handling also (including raising application-defined exceptions).

begin
declare
  first_name varchar2(30);
begin
  /* code goes here */
except
  /* exception handler goes here */
end;
end;

Eric Giguere <eric.gigu...@dimalt.com> wrote in article
<350FF5FD.56B7C...@dimalt.com>...

Quote
> I'm trying to execute more than one SQL statement in a single TQuery
> component (example, two insert statement in two different tables).
> MS-SQL let us do that without problem but oracle don't let us do through
> BDE. We are trying to build a program that can run sql scripts. Is it
> possible to do this with delphi and Oracle?

Other Threads