Skip to content

Session connection #105

Closed
Closed

Description

@irwanto82

i'm trying using mysql/mariadb,
and test this simple command in demo,
select connection_id()

result always change, if you use mysql client or heidisql etc, connection id is always same until new connection create/broken

if use use this method, (i'm talk about single command not batchsql), whats happen ???

OpenSQL('set autocommit=0');
try
try
if NOT OpenSQL('update stok where qty=1') then //update with no autocommit
raise Exception.Create('error');

  if NOT OpenSQL('updateS produk where stokqty=x') then //trying send wrong sql, what happen with previous sql, rollback or commit ?
    raise Exception.Create('error');

  if NOT OpenSQL('Commit') then
    raise Exception.Create('error');

except
  if NOT OpenSQL('rollback') then
    raise Exception.Create('error');
end;

finally
OpenSQL('set autocommit=1');
end;

Activity

  1. mobius1qwe commented on Oct 12, 2022

    @mobius1qwe
    Contributor

    Connection_id is always different because for every request that you send to server, a new instance of the ServerMethodClass (RESTDWDataModule) will be created to individually process the request. After the request is processed, the instance will automatically be destroyed and released from memory. That behavior is called "Stateless call".

    About commit and rollback that will depend on which DAC you're using, if its FireDAC, you will need to handle the SQL Queries through:

      BeginTransaction;
      do something with query
      if true then 
        Commit
      else
        Rollback;

    Those are transaction controlling commands. On different DACs (Data Access Components) it will have different sintax, but that's the general Idea.

  2. locked and limited conversation to collaborators on Oct 13, 2022
  3. converted this issue into a discussion #106 on Oct 13, 2022
  4. moved this from Todo to Done in REST DataWareon Feb 14, 2023
  5. added this to the 2.1 milestone on Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions