Recent

Author Topic: Zeos + id session  (Read 3277 times)

xinyiman

  • Hero Member
  • *****
  • Posts: 2092
    • Lazarus and Free Pascal italian community
Zeos + id session
« on: January 04, 2012, 11:35:45 am »
How can I get a unique identifier of the session is connected to a database (firebird) better if the solution is cross-platform.

This ZEOS with members!
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Zeos + id session
« Reply #1 on: January 04, 2012, 12:41:32 pm »
Code: [Select]
select current_connection from rdb$database

xinyiman

  • Hero Member
  • *****
  • Posts: 2092
    • Lazarus and Free Pascal italian community
Re: Zeos + id session
« Reply #2 on: January 04, 2012, 01:33:43 pm »
Code: [Select]
select current_connection from rdb$database

Thank you. One question, this is a only solution to firebird?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Zeos + id session
« Reply #3 on: January 04, 2012, 02:01:26 pm »
If you mean: is this Firebird-specific, the answer is yes... but it should work on all platforms Firebird runs on (Linux, Windows, OSX...)
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

xinyiman

  • Hero Member
  • *****
  • Posts: 2092
    • Lazarus and Free Pascal italian community
Re: Zeos + id session
« Reply #4 on: January 04, 2012, 02:14:19 pm »
There is something cross-database?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

ludob

  • Hero Member
  • *****
  • Posts: 1173
Re: Zeos + id session
« Reply #5 on: January 04, 2012, 05:48:24 pm »
There is something cross-database?
AFAIK, no.
MySQL has the CONNECTION_ID() which returns the process_id for the current connection. This is unique among existing connections. ID's will be re-used sooner or later.
Firebirds current_connection is a counter starting with when the server is start up and incremented by 1 for every session requesting current_connection (FB 1.5).
Oracle has sys_context('USERENV', 'SESSIONID') or userenv('SESSIONID').

It depends on what you want to do because there are other options:
- use database vars. Since vars are session specific you can set a var to a value of your choice when making the connection. At any time you can request the var back to identify your session. The syntax for database vars is not cross-database neither.
- use temporary tables and enter session specific info as the first record. The syntax is roughly the same on all DB's with the difference that oracle and firebird temporary tables are visible by all sessions (not the data, only the structure) while mssql and mysql temporary tables are visible only for the current session. This complicates creating temporary tables in a cross-db way a little bit.




 

TinyPortal © 2005-2018