Subject | Re: Dinamic SQL in Firebird ! - inside :P |
---|---|
Author | grndeveloper |
Post date | 2005-04-18T10:32:01Z |
Thanks for the information!
I never cross for my mind that i'll recive it so quickly !
Well, now i know that i could have code like this? :
my_var = 'SELECT FROM T1 WHERE F1 = \'3\' '||
'and C1 = 9' ||
'and USER_ID = ' || my_user_id;
EXECUTE STATEMENT my_var;
That simplifies a lot the code maintenance... becouse i could have a
procedure like this :
create procedure ....
as ...
begin
my_var = "SELECT FROM T1 WHERE F1 = '3' and USER_ID = " || my_user_id;
<blocs>
EXECUTE STATEMENT my_var;
<blocs>
end
- NO?¿ . - That's great!
But, could I introduce, in a select done, a only expression (sub
statment) like that?
<blocs>
sub_s1 = 'and P = ' || my_user_id
select c1,c2,c3
from t1
where c1 = 1 and c5 = \'Peret\' and EXECUTE STATMENT sub_s1 and c7 = 9
<blocs>
I supose that no... but nobodynows.... ;)
Thanks for all!!
--- In firebird-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@u...> wrote:
I never cross for my mind that i'll recive it so quickly !
Well, now i know that i could have code like this? :
my_var = 'SELECT FROM T1 WHERE F1 = \'3\' '||
'and C1 = 9' ||
'and USER_ID = ' || my_user_id;
EXECUTE STATEMENT my_var;
That simplifies a lot the code maintenance... becouse i could have a
procedure like this :
create procedure ....
as ...
begin
my_var = "SELECT FROM T1 WHERE F1 = '3' and USER_ID = " || my_user_id;
<blocs>
EXECUTE STATEMENT my_var;
<blocs>
end
- NO?¿ . - That's great!
But, could I introduce, in a select done, a only expression (sub
statment) like that?
<blocs>
sub_s1 = 'and P = ' || my_user_id
select c1,c2,c3
from t1
where c1 = 1 and c5 = \'Peret\' and EXECUTE STATMENT sub_s1 and c7 = 9
<blocs>
I supose that no... but nobodynows.... ;)
Thanks for all!!
--- In firebird-support@yahoogroups.com, "Martijn Tonies"
<m.tonies@u...> wrote:
> Hello,MS SQL
>
> > Nobody knows a way to insert a dynamic SQL in a procedure?
>
> I do, I do :-)
>
> > We want to change the number of restrictions in a query, in function
> > of an input parameter.
> >
> > The solutions that we done is change the query contraints with delphi
> > or duplicate the code in firebird's procedure, but this is a ugly
> > solution and its more difficult to maintain the code...
> >
> > Has firebird resources to solve this problem by himself?
>
> Firebird 1.5 has - take a look at EXECUTE STATEMENT in
> the Release Notes.
>
> For versions before 1.5, you're out of luck.
>
> With regards,
>
> Martijn Tonies
> Database Workbench - developer tool for InterBase, Firebird, MySQL &
> Server
> Upscene Productions
> http://www.upscene.com