Firebird SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesFirebird SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old September 20th, 2004, 02:14 AM
lsteo lsteo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 7 lsteo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile Global variable in Firebird???

Hi:

Is there any way that I can declare a global variable and access it from few store procedures or triggers?

Thank you very much.

Regards,
Eric

Reply With Quote
  #2  
Old September 20th, 2004, 02:44 AM
fikret fikret is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Sarajevo, Bosnia
Posts: 111 fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 5 h 32 m 19 sec
Reputation Power: 8
I don't think so...

--
Best regards,
Fikret Hasovic http://fikret.fbtalk.net
TAMP R&D Team
FirebirdSQL Foundation member.
- Join today at http://www.firebirdsql.org/ff/foundation
JEDI VCS contributor
http://jedivcs.sourceforge.net/

Reply With Quote
  #3  
Old September 20th, 2004, 03:33 AM
lsteo lsteo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 7 lsteo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile Any workaround?

Hi:

Thank you for your reply.

Any workaround for this? For example in Sybase we could write

select set_appcontext("..","...","..")

any equivalent in Firebird?

Thank you.

Regards,
Eric

Reply With Quote
  #4  
Old September 21st, 2004, 02:51 AM
fikret fikret is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Sarajevo, Bosnia
Posts: 111 fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 5 h 32 m 19 sec
Reputation Power: 8
I don't know...
Maybe you should ask in firebird support list?
http://groups.yahoo.com/group/firebird-support


--
Best regards,
Fikret Hasovic http://fikret.fbtalk.net
TAMP R&D Team
FirebirdSQL Foundation member.
- Join today at http://www.firebirdsql.org/ff/foundation
JEDI VCS contributor
http://jedivcs.sourceforge.net/

Reply With Quote
  #5  
Old September 21st, 2004, 08:18 PM
lsteo lsteo is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 7 lsteo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi Fikret Hasovic,

Thank you very much for your infomation.

Regards,
lsteo

Quote:
Originally Posted by fikret
I don't know...
Maybe you should ask in firebird support list?
http://groups.yahoo.com/group/firebird-support


--
Best regards,
Fikret Hasovic http://fikret.fbtalk.net
TAMP R&D Team
FirebirdSQL Foundation member.
- Join today at http://www.firebirdsql.org/ff/foundation
JEDI VCS contributor
http://jedivcs.sourceforge.net/

Reply With Quote
  #6  
Old September 29th, 2004, 09:07 AM
hugo2 hugo2 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 20 hugo2 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 47 m 14 sec
Reputation Power: 0
Quote:
Originally Posted by lsteo
Is there any way that I can declare a global variable and access it from few store procedures or triggers?


To store global values you can use generator, or table, or stored procedure. e.g.
Create Procedure X Returns (a integer, b integer) As
Begin
a = 123;
b = 456;
End

Reply With Quote
  #7  
Old October 1st, 2004, 03:25 AM
fikret fikret is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Sarajevo, Bosnia
Posts: 111 fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 5 h 32 m 19 sec
Reputation Power: 8
Quote:
Originally Posted by hugo2
To store global values you can use generator, or table, or stored procedure. e.g.
Create Procedure X Returns (a integer, b integer) As
Begin
a = 123;
b = 456;
End


Interesting...


--
Best regards,
Fikret Hasovic http://fikret.fbtalk.net
TAMP R&D Team

FirebirdSQL Foundation member.
- Join today at http://www.firebirdsql.org/ff/foundation
JEDI VCS contributor
http://jedivcs.sourceforge.net/

Reply With Quote
  #8  
Old October 5th, 2004, 11:36 PM
skidder skidder is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Posts: 15 skidder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to skidder
If you need true connection- or transaction- specific variables you can write a small UDF which manages mapping between your variables and values of CURRENT_CONNECTION or CURRENT_TRANSACTION pseudo-variables.

So your resulting PSQL to do this stuff may look like this:

old_string_val = set_connection_var('MyVarName', CURRENT_CONNECTION, new_string_var);

cur_string_val = get_connection_var('MyVarName', CURRENT_CONNECTION);

Reply With Quote
  #9  
Old October 6th, 2004, 08:20 AM
fikret fikret is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Location: Sarajevo, Bosnia
Posts: 111 fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level)fikret User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 5 h 32 m 19 sec
Reputation Power: 8
Quote:
Originally Posted by skidder
If you need true connection- or transaction- specific variables you can write a small UDF which manages mapping between your variables and values of CURRENT_CONNECTION or CURRENT_TRANSACTION pseudo-variables.

So your resulting PSQL to do this stuff may look like this:

old_string_val = set_connection_var('MyVarName', CURRENT_CONNECTION, new_string_var);

cur_string_val = get_connection_var('MyVarName', CURRENT_CONNECTION);


Yes, Nickolay, that can be done

--
Best regards,
Fikret Hasovic http://fikret.fbtalk.net

FirebirdSQL Foundation member.
- Join today at http://www.firebirdsql.org/ff/foundation
JEDI VCS contributor
http://jedivcs.sourceforge.net/

Reply With Quote
  #10  
Old October 2nd, 2008, 07:47 PM
HuguesV HuguesV is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2008
Posts: 2 HuguesV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 40 sec
Reputation Power: 0
Simple solution

hi,

a simple solution without UDF:


/******************************************************************************/
/* Tables */
/******************************************************************************/



CREATE TABLE USER_VARIABLE (
IDCONNECTION INTEGER,
VARIABLE_NAME VARCHAR(100),
VARIABLE_VALUE VARCHAR(100)
);




/******************************************************************************/
/* Indices */
/******************************************************************************/

CREATE INDEX USER_VARIABLE_IDX1 ON USER_VARIABLE (IDCONNECTION);
CREATE INDEX USER_VARIABLE_IDX2 ON USER_VARIABLE (VARIABLE_NAME);


/******************************************************************************/
/* Triggers for tables */
/******************************************************************************/



/* Trigger: USER_VARIABLE_BI0 */
CREATE OR ALTER TRIGGER USER_VARIABLE_BI0 FOR USER_VARIABLE
ACTIVE BEFORE INSERT POSITION 0
AS
begin
/* Trigger text */
delete from user_variable
where
idconnection=current_connection
and
variable_name=new.variable_name;
end


CREATE OR ALTER PROCEDURE GETVARIABLE (
varname varchar(100))
returns (
varvalue varchar(100))
as
begin
select coalesce(variable_value,'') from user_variable where idconnection=current_connection and variable_name=:Varname into :Varvalue;
suspend;
end

CREATE OR ALTER PROCEDURE SETVARIABLE (
varname varchar(100),
varvalue varchar(100))
as
begin
insert into user_variable values (current_connection,:Varname,:Varvalue);
end
-----------------------------------------------------------------

Usage:
execute procedure setvariable('VarTest','34');
select * from getvariable('vartest')

I was looking for a solution to do this and found it here in the previous post with the "current_connection" variable.

so many thanks to the forum ^^

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesFirebird SQL Development > Global variable in Firebird???


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT