SQLdb | Postgres >=10 \ cacth RAiSE NOTICE lazarus / 63-Database ---------------------------------------------------------------------- cpalx · 2020-02-28 15:56 Hello, I am using SQLdb (PQConnection) and postgres 10 with lazarus 2.0.6 (Linux) I need to catch a RAISE NOTICE. Example Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DO $$ BEGIN     RAISE NOTICE '{"id": % }', 4;END$$;  i need to get {"id"; 4} any idea? ---------------------------------------------------------------------- dsiders · 2020-02-28 16:23 Quote from: cpalx on February 28, 2020, 04:56:21 pmHello, I am using SQLdb (PQConnection) and postgres 10 with lazarus 2.0.6 (Linux) I need to catch a RAISE NOTICE. Example Code: SQL  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i DO $$ BEGIN     RAISE NOTICE '{"id": % }', 4;END$$;  i need to get {"id"; 4} any idea? Not when using PQConnection. The function library in packages/postgres/ has PQSetNoticeReceiver and PQSetNoticeProcessor though. ---------------------------------------------------------------------- cpalx · 2020-02-28 17:08 i can do it now,  (https://forum.lazarus.freepascal.org/index.php?topic=44854.0) but i have a new problem, I can public with writeln, but can not get to another variable using in my Class Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i ..TMyPQConnection = class(pqconnection.TPQConnection)..public Answer Pchar;.. procedure TForm1.Connect();begin  Postg:= TMyPQConnection.Create(nil);  Postg.DatabaseName:= 'zzzzz';  Postg.HostName:= '127.0.0.1';  Postg.UserName:= 'yyyy';  Postg.Password:= 'xxxxxxx';  Postg.Connected:= True;  SQLTransaction1.DataBase:= Postg;  SQLQuery1.DataBase:= Postg;end; procedure MyNoticeReceiver(arg: pointer; res: PPGresult);cdecl;const PG_DIAG_MESSAGE_PRIMARY = 77;begin  //WriteLn( PQresultErrorField(res, PG_DIAG_MESSAGE_PRIMARY) ); // This Work Fine   Form1.Answer:= PQresultErrorField(res, PG_DIAG_MESSAGE_PRIMARY); // CAn assign but lost later  end; procedure TForm1.Button1Click(Sender: TObject);begin  Connect;  SQLQuery1.Close;  SQLQuery1.SQL.Text:= memo1.Text;  try     SQLQuery1.Prepare;     SQLQuery1.ExecSQL;       PQsetNoticeReceiver(PPGConn(Postg.GetHandle), @MyNoticeReceiver, nil);       ShowMessage( Answer ); //<-- Always empty  except on e: Exception do begin    Memo2.Text:= e.Message;  end;  end;  Postg.Free;end; ---------------------------------------------------------------------- sstvmaster · 2020-02-28 20:43 Have you tried this? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Form1.Answer:= PQresultErrorField(res, ord(PG_DIAG_MESSAGE_PRIMARY)); Found here: https://sourceforge.net/p/zeoslib/code- 0/17/tree//trunk/src/plain/ZPlainPostgreSqlDriver.pas?diff=500986a671b 75b2b8b001f0f:16 at the end. Or you can try get the error direct, example code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i Answer := xxx.GetResultErrorField(Res, PG_DIAG_MESSAGE_PRIMARY); ---------------------------------------------------------------------- cpalx · 2020-02-28 22:44 i tried QuoteCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     Form1.Answer:= PQresultErrorField(res, ord(PG_DIAG_MESSAGE_PRIMARY)); but the same What "xxx" means? QuoteCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     Answer := xxx.GetResultErrorField(Res, PG_DIAG_MESSAGE_PRIMARY); i dont use Zcomponents (i will like to, but it is imposible that works in cgi project) ---------------------------------------------------------------------- sstvmaster · 2020-02-28 23:14 So i don't know, how i can help you, sorry