Ignore additional useless parameters at execute statement
---------------------------------------------------------

                 Key: CORE-4736
                 URL: http://tracker.firebirdsql.org/browse/CORE-4736
             Project: Firebird Core
          Issue Type: Improvement
            Reporter: Omacht AndrĂ¡s
            Priority: Minor


It would be easier to create and mantain dynamic (build up with changing 
parameters) execute statements if the engine ignores the actually useless 
paramteres.

Example:
select * from people_by_gender_and_age('F', 16, 30)    -- works fine

select * from people_by_gender_and_age(null, 16, 30)   -- dies with error: 
"input parameter mismatch' - also this should work too

Business logic:
CREATE TABLE PEOPLE (
    GENDER  VARCHAR(1) NOT NULL,
    AGE     INTEGER NOT NULL
);
commit;


INSERT INTO PEOPLE (GENDER, AGE) VALUES ('F', 15);
INSERT INTO PEOPLE (GENDER, AGE) VALUES ('F', 20);
INSERT INTO PEOPLE (GENDER, AGE) VALUES ('M', 17);
INSERT INTO PEOPLE (GENDER, AGE) VALUES ('M', 19);
commit;


create or alter procedure people_by_gender_and_age (
filter_gender type of column people.gender,
filter_min_age type of column people.age,
filter_max_age type of column people.age)
returns (gender type of column people.gender,
age type of column people.age)
as
begin
  filter_min_age = coalesce(filter_min_age, 0);
  filter_max_age = coalesce(filter_max_age, 200);
  for execute statement
    ('select gender, age
        from people
        where age between :filter_min_age and :filter_max_age ' ||
-- Here is the dynamic part
    iif(:filter_gender in ('F', 'M'), ' and gender = :filter_gender', ''))
    (filter_gender := :filter_gender,      -- sometimes this parameter is 
useless depends on the dynamic part
     filter_min_age := :filter_min_age,
     filter_max_age := :filter_max_age)
  into :gender,
       :age do
    begin
      suspend;
    end
end



Thanks!


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://tracker.firebirdsql.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to