Forums

Find answers, ask questions, and connect with our
community all around the world.

Home Forum Omnis General Forum $sessionPools

  • $sessionPools

    Posted by Franco Maregotto on December 2, 2022 at 11:02 am

    Ciao to all

    I’m strugglin’ with $makepool:

    I do exactly what Andreas Pfeiffer suggests in the “Moving your Omnis App to the Web…” white paper.

    when I inspect the content of the Object in the remote form $construct method

    Do $cinst.$sessionobject.$assign(<b style=”background-color: var(–bb-content-background-color); font-family: inherit; font-size: inherit; color: var(–bb-body-text-color);”>tSessionObj) I see it correctly instantiated but I get a DB error (a connection could not be established) because “FATALE: the database “username” does not exists”

    So the question is: How and when can I $assign the value to the tSessionObj.$database (and $port) ?

    Furthermore: when I try to

    Do $extobjects.PGSQLDAM.$objects.PGSQLSESS.$makepool(‘myPool’,2,etc etc)

    I always get a NULL return value for iPoolRef when the initial number of session is not zero.

    With 0 it works fine..

    What am I missing?

    Thanks & cheers

    Franco

    Andreas Pfeiffer replied 1 year, 9 months ago 2 Members · 1 Reply
  • 1 Reply
  • Andreas Pfeiffer

    Administrator
    December 2, 2022 at 12:05 pm

    Hello Franco,

    If using a session pool you can use a public method to determine the port and database name. The 6th argument of the $makepool method takes the name of the method which will be called for every session in the session pool.

    This method will then have a parameter of type item reference which points to the new session and you can then set its $port and any other session property.

    However nowadays I would not recommend using session pools because creating a new session to a database is very quick and does not take much time. So if you do a logon in the $construct of your remote task using a task variable you will have a session object as a task variable that can then be used whenever you need it to talk to the database. Since the task is encapsulated for every user it is save to do so. For example I have a $logon method in the remote task that is called from its $construct like this (tSessionObj is a task variable of type object, you can assign the subtype if you do not need to set this dynamically):

    # logon to PostgreSQL DB

    Do $extobjects.PGSQLDAM.$objects.PGSQLSESS.$new() Returns tSessionObj

    Do tSessionObj.$port.$assign(iniObj.$getSectionParam(‘DB’,’PORT’))

    Do tSessionObj.$database.$assign(iniObj.$getSectionParam(‘DB’,’DATABASE’))

    Do tSessionObj.$schema.$assign(iniObj.$getSectionParam(‘DB’,’SCHEMA’))

    Do tSessionObj.$logon(iniObj.$getSectionParam(‘DB’,’HOST’),iniObj.$getSectionParam(‘DB’,’USER’,iniObj),iniObj.$getSectionParam(‘DB’,’PASSWORD’)) Returns ok

    Quit method ok

    Note: the iniObj returns information from a text file.

    So in the $construct of your super table class you would do something like this:

    Do $cinst.$sessionobject.$assign(tSessionObj)

    Hope this helps.

    Best,

    Andreas 😀

Log in to reply.