Board index » delphi » update a stored procedure

update a stored procedure


2005-09-30 07:22:39 PM
delphi50
Hello
I´m using dbexpress. and I`ve in a sqlquery an sored procedure. How can
update the table in the field name of stored procedure is diferent the in
the table?
I use OnGetTableName to set the table name, but filed name?. I`m using orign
of TField but donsen´t work.
Thanks
 
 

Re:update a stored procedure

Felix,
Quote
I´m using dbexpress. and I`ve in a sqlquery an sored procedure. How can
update the table in the field name of stored procedure is diferent the in
the table?
I use OnGetTableName to set the table name, but filed name?. I`m using
orign
of TField but donsen´t work.
Please re-read your own question and imagine you have no idea
what your project is about or how it works. Would you understand
the question?
--
With regards,
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
www.upscene.com
Database development questions? Check the forum!
www.databasedevelopmentforum.com
 

Re:update a stored procedure

The easy solution is to change the stored procedure to return the
actual field name from the table. The only alternative is to write a
BeforeUpdateRecord event handler and generate the SQL yourself.
--
Bill Todd (TeamB)
 

Re:update a stored procedure

Sorry.
I´m using Delphi 7 and Firebird 1.5. In my DB I`ve a sored procedure that select
row from a table:somthing like :
create procedure pp
returns(C1 varchar(100))
as
begin
for select Campo1
from table
into:C1
do
suspend;
end
the name of field in table it´s "Campo1" and the procedure returns "C1"
in my delphi progrma I`ve a SQLquery (select * from procedure) with a
DatasetProvider and a ClientDataSet When I applyUpdates I get an error
beceause C1 not exist´s on Table.
How can update the table using this DataSetProvider?
Thanks
"Martijn Tonies" <XXXX@XXXXX.COM>escribi?en el
mensaje news:433d310d$XXXX@XXXXX.COM...
Quote
Felix,

>I´m using dbexpress. and I`ve in a sqlquery an sored procedure. How can
>update the table in the field name of stored procedure is diferent the in
>the table?
>I use OnGetTableName to set the table name, but filed name?. I`m using
orign
>of TField but donsen´t work.

Please re-read your own question and imagine you have no idea
what your project is about or how it works. Would you understand
the question?


--
With regards,

Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
www.upscene.com
Database development questions? Check the forum!
www.databasedevelopmentforum.com


 

Re:update a stored procedure

Hello Felix,
Quote
I´m using Delphi 7 and Firebird 1.5. In my DB I`ve a sored procedure that select
row from a table:somthing like :

create procedure pp
returns(C1 varchar(100))
as
begin
for select Campo1
from table
into:C1
do
suspend;
end

the name of field in table it´s "Campo1" and the procedure returns "C1"

in my delphi progrma I`ve a SQLquery (select * from procedure) with a
DatasetProvider and a ClientDataSet When I applyUpdates I get an error
beceause C1 not exist´s on Table.
How can update the table using this DataSetProvider?
Start with Bills answer.
In addition to that -- you have to understand the following:
The result of a selectable procedure does not HAVE to come
from a table, it can be lots of things, or even no table at all.
For example:
create procedure one_two_three returns ( i integer )
as begin
i = 1;
suspend;
i = 2;
suspend;
i = 3;
suspend;
end
This will return a resultset just fine.
The reason why I am telling this? Simple. If you insist on letting
the Delphi components generate the SQL that is being executed,
you should understand that these components assume you're
selecting from a table. In this case, you are not, which complicates
things for auto-generated SQL, as you have found out.
You might have to "help" it, or even use a different approach to
updating the data, like creating the SQL yourself.
--
With regards,
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, Oracle & MS SQL
Server
Upscene Productions
www.upscene.com
Database development questions? Check the forum!
www.databasedevelopmentforum.com
 

Re:update a stored procedure

Why don't you use a View?... for selecting single columns or values from
different tables: with parameters and/or updatable view
Martijn Tonies writes:
Quote
Hello Felix,


>I´m using Delphi 7 and Firebird 1.5. In my DB I`ve a sored procedure that select
>row from a table:somthing like :
>
>create procedure pp
>returns(C1 varchar(100))
>as
>begin
>for select Campo1
>from table
>into:C1
>do
>suspend;
>end
>
>the name of field in table it´s "Campo1" and the procedure returns "C1"
>
>in my delphi progrma I`ve a SQLquery (select * from procedure) with a
>DatasetProvider and a ClientDataSet When I applyUpdates I get an error
>beceause C1 not exist´s on Table.
>How can update the table using this DataSetProvider?


Start with Bills answer.

In addition to that -- you have to understand the following:
The result of a selectable procedure does not HAVE to come
from a table, it can be lots of things, or even no table at all.

For example:
create procedure one_two_three returns ( i integer )
as begin
i = 1;
suspend;
i = 2;
suspend;
i = 3;
suspend;
end

This will return a resultset just fine.

The reason why I am telling this? Simple. If you insist on letting
the Delphi components generate the SQL that is being executed,
you should understand that these components assume you're
selecting from a table. In this case, you are not, which complicates
things for auto-generated SQL, as you have found out.

You might have to "help" it, or even use a different approach to
updating the data, like creating the SQL yourself.