Subject | Re: Declare and use array datatype in stored procedures |
---|---|
Author | jb303@ymail.com |
Post date | 2012-12-30T22:57:52Z |
Thanks for the fast response.
That could be an option, unfortunately GTTs were added only in 2.1 (I'm running on 2.0.6):
SQL> CREATE GLOBAL TEMPORARY TABLE SESSION_VARS
CON> (
CON> USER_UNIQUENUM integer NOT NULL,
CON> TICKET_UNIQUENUM integer NOT NULL
CON> )
CON> ON COMMIT PRESERVE ROWS;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, column 8
-GLOBAL
SQL>
However, also if I could use GTTs, that would still require me to create the table definition (metadata), and if I'd like to use many similar tables in a procedure (like multiple variables), I'd have to create so many permanent definitions. What I'm looking for is a way to have everything in memory - the reason I'm emphasizing this is because I have to calculate some values in a tight loop (which can't be done entirely in pure SQL) and storing the values in-memory would be the fastest solution. Anything that gets written to disk (although it might be cached) is probably much slower (e.g. FB has probably to check for locks; transaction management, etc.) in comparison to writing to a plain in-memory variable/array.
Regards
That could be an option, unfortunately GTTs were added only in 2.1 (I'm running on 2.0.6):
SQL> CREATE GLOBAL TEMPORARY TABLE SESSION_VARS
CON> (
CON> USER_UNIQUENUM integer NOT NULL,
CON> TICKET_UNIQUENUM integer NOT NULL
CON> )
CON> ON COMMIT PRESERVE ROWS;
Statement failed, SQLCODE = -104
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, column 8
-GLOBAL
SQL>
However, also if I could use GTTs, that would still require me to create the table definition (metadata), and if I'd like to use many similar tables in a procedure (like multiple variables), I'd have to create so many permanent definitions. What I'm looking for is a way to have everything in memory - the reason I'm emphasizing this is because I have to calculate some values in a tight loop (which can't be done entirely in pure SQL) and storing the values in-memory would be the fastest solution. Anything that gets written to disk (although it might be cached) is probably much slower (e.g. FB has probably to check for locks; transaction management, etc.) in comparison to writing to a plain in-memory variable/array.
Regards
--- In firebird-support@yahoogroups.com, "Hans" <hhoogstraat@...> wrote:
>
> Maybe a Temporary table will do it. Something like:
>
> CREATE GLOBAL TEMPORARY TABLE SESSION_VARS
> (
> USER_UNIQUENUM integer NOT NULL,
> TICKET_UNIQUENUM integer NOT NULL
> )
> ON COMMIT PRESERVE ROWS; (More options available here)
>
> It is unique for each connection and lasts as long as the connection lasts.
> Information can be used/updated/inserted by all procedures and triggers,
> alike a memory table but residing on the server.
>