Subject | Re: [firebird-support] Dynamic ORDER BY in SP |
---|---|
Author | Martijn Tonies |
Post date | 2007-01-10T19:54:10Z |
Hi Vlad,
In the first case, it acually reports the table and index used, while
in the second case, it cannot report anything, so it seems, besides
the procedure name. That is a bit weird as well.
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
> This is my current scenario.version):
>
> I have a SP that has the WHERE clause and looks something like(simplified
>' || :IN_ORDERBY
> PROCEDURE GET_DATA(IN_USERID INTEGER)
> RETURNS(
> OUT_NAME varchar(50),
> OUT_SIZE integer)
> AS
> BEGIN
> FOR
> SELECT
> NAME,
> SIZE
> FROM DIRS
> WHERE USER_ID = IN_USERID --USER_ID is a primary key
> INTO OUT_NAME, OUT_SIZE
> END
>
> I also have another SP that does ORDERing:
>
> PROCEDURE GET_DATA_WRAPPER(IN_USERID INTEGER, IN_ORDERBY varchar(32))
>
> RETURNS(
>
> OUT_NAME varchar(50),
>
> OUT_SIZE integer)
>
> AS
>
> BEGIN
>
> FOR
> EXECUTE STATEMENT 'SELECT * FROM GET_DATA(' || :IN_USERID || ') ORDER BY
> INTO OUT_NAME, OUT_SIZE(UNQ1_DIRS)).
>
> END
>
> When I run SELECT * FROM GET_DATA(1) optimizer picks PLAN (DIRS INDEX
>(GET_DATA_WRAPPER NATURAL)
> When I run SELECT * FROM GET_DATA_WRAPPER(1) optimizer picks PLAN
In the first case, it acually reports the table and index used, while
in the second case, it cannot report anything, so it seems, besides
the procedure name. That is a bit weird as well.
> Does the optimizer picks PLAN (DIRS INDEX (UNQ1_DIRS)) inside theGET_DATA() when I call SELECT * FROM GET_DATA_WRAPPER(1)?
>I think so, but not reporting it due to EXECUTE STATEMENT.
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com