Re: [firebird-support] Re: FB3 returning clause and new API
On Thursday 15 September 2016 12:25:31 Norbert Saint Georges n...@tetrasys.eu [firebird-support] wrote: > > below, a bit dirty but functional code in codetyphon, reading the > buffer is RS > Thanks, but do I read the code correct, that you also use IAttachment.prepare() in order to get the messagemetadata? Does this cause an additional server roundtrip? With IAttachment.execute() there is no messagemetadata available and with the statement " insert into TABLE1 (STR1) values ('aabbccdd') returning PK " IAttachment.openCursor() seems not to work. Martin
Re: [firebird-support] Re: FB3 returning clause and new API
On Thursday 15 September 2016 15:06:58 'Mark Rotteveel' m...@lawinegevaar.nl [firebird-support] wrote: > You either need to generate the necessary metadata yourself, but then you > either have to guess, or have the user provide the type. You can't use > openCursor as insert ... returning doesn't have a cursor; just like an > executable procedure it has a single result that is returned on execute. > Does calling IAttachment.prepare() in order to get the output message metadata produce a performance penalty, expecially an additional server roundtrip? I assume so. The format of the received data must be known in FB-client library when the data arrives, so it should be possible to provide an IMessageMetadata after execute(). A very comfortable solution would be when openCursor() would work for all statement types because of the problem that it is not known if openCursor() or execute() must be called before parsing the SQL statement in user code or preparing the statement. It seems that calling openCursor() with " insert into TABLE1 (STR1) values ('aabbccdd') returning PK " actually returns a valid IMessageMetadata by IResultSet.getMetadata(). What apparentely not works is fetchNext()... Martin
[firebird-support] Problem querying MON$STATEMENTS table
Hello I have a problem when i querying the MON$STATEMENS table on Server 2.5.5 and also 2.5.6 Do the follow steps: Open a connection to the database, then start a transaction an open a table to show the content and keep it open/active Now run the follow statement "SELECT * FROM MON$STATEMENS" The Row that should shows you the active query are not correct! The column MON$STATE shows allways Zero and also the columns MON$TRANSACTION_ID and MON$TIMESTAMP are also allways NULL!! The Server 3.0.1 are not affected on this problem. The follow databases with charset are not working (tested) NONE, WIN1250, ISO8859_1 A database with charset WIN1251 are working well. May this could be a bug. Best Regards Gregor
Re: [firebird-support] Problem querying MON$STATEMENTS table
Friday, September 16, 2016, 12:02:28 AM, Gregor Kobler wrote: > I have a problem when i querying the MON$STATEMENS table on Server 2.5.5 and > also 2.5.6 > > Do the follow steps: > > Open a connection to the database, then start a transaction an open > a table to show the content and keep it open/active Now run the > follow statement "SELECT * FROM MON$STATEMENS" > > The Row that should shows you the active query are not correct! Open output set <> active query. Once the SELECT statement has finished fetching, its state is no longer active...it becomes "idle". > > The column MON$STATE shows allways Zero Zero is the "idle" state. It will go to "active" (1) next time the cursor restarts. > and also the columns > MON$TRANSACTION_ID and MON$TIMESTAMP are also allways NULL!! Both of those fields will hold values only while the statement is active. A statement that is idle is not active. > > The Server 3.0.1 are not affected on this problem. > > The follow databases with charset are not working (tested) NONE, WIN1250, > ISO8859_1 > > A database with charset WIN1251 are working well. > > May this could be a bug. If you suspect a bug, please try to give a proper description of what you mean by "working well" and "not working" and post it, with your statements, to firebird-devel. Also give the build number of the snapshot that you refer to as "Server 3.0.1", as these snapshots are refreshed very regularly. The core devs have been working pretty solidly on Fb3 bugs over the past 3 months so you should be able to discover what kind of a problem (if any) you are actually observing and whether it is fixed. HB
Re: [firebird-support] FB3 returning clause and new API
15.09.2016 7:56, Martin Schreiber mse00...@gmail.com [firebird-support] wrote: > How the values of a returning clause can be fetched with OOP-API? Use IAttachment::execute() for single execution of queries without parameters and IStatement::execute() for the rest. -- WBR, SD. ++ Visit http://www.firebirdsql.org and click the Documentation item on the main (top) menu. Try FAQ and other links from the left-side menu there. Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ ++ Yahoo Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/firebird-support/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/firebird-support/join (Yahoo! ID required) <*> To change settings via email: firebird-support-dig...@yahoogroups.com firebird-support-fullfeatu...@yahoogroups.com <*> To unsubscribe from this group, send an email to: firebird-support-unsubscr...@yahoogroups.com <*> Your use of Yahoo Groups is subject to: https://info.yahoo.com/legal/us/yahoo/utos/terms/
Re: [firebird-support] FB3 returning clause and new API
On Thursday 15 September 2016 09:01:04 Dimitry Sibiryakov s...@ibphoenix.com [firebird-support] wrote: > 15.09.2016 7:56, Martin Schreiber mse00...@gmail.com [firebird-support] wrote: > > How the values of a returning clause can be fetched with OOP-API? > >Use IAttachment::execute() for single execution of queries without > parameters and IStatement::execute() for the rest. And then how to get the data? Is using openCursor() not possible so one does not need to know if it is a SELECT or another statement? Martin ++ Visit http://www.firebirdsql.org and click the Documentation item on the main (top) menu. Try FAQ and other links from the left-side menu there. Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ ++ Yahoo Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/firebird-support/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/firebird-support/join (Yahoo! ID required) <*> To change settings via email: firebird-support-dig...@yahoogroups.com firebird-support-fullfeatu...@yahoogroups.com <*> To unsubscribe from this group, send an email to: firebird-support-unsubscr...@yahoogroups.com <*> Your use of Yahoo Groups is subject to: https://info.yahoo.com/legal/us/yahoo/utos/terms/
Re: [firebird-support] FB3 returning clause and new API
15.09.2016 10:16, Martin Schreiber mse00...@gmail.com [firebird-support] wrote: > And then how to get the data? Last two parameter of the methods is an output message where output data is returned in. -- WBR, SD. ++ Visit http://www.firebirdsql.org and click the Documentation item on the main (top) menu. Try FAQ and other links from the left-side menu there. Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ ++ Yahoo Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/firebird-support/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/firebird-support/join (Yahoo! ID required) <*> To change settings via email: firebird-support-dig...@yahoogroups.com firebird-support-fullfeatu...@yahoogroups.com <*> To unsubscribe from this group, send an email to: firebird-support-unsubscr...@yahoogroups.com <*> Your use of Yahoo Groups is subject to: https://info.yahoo.com/legal/us/yahoo/utos/terms/
Re: [firebird-support] FB3 returning clause and new API
On Thursday 15 September 2016 10:29:27 Dimitry Sibiryakov s...@ibphoenix.com [firebird-support] wrote: > 15.09.2016 10:16, Martin Schreiber mse00...@gmail.com [firebird-support] wrote: > > And then how to get the data? > >Last two parameter of the methods is an output message where output data > is returned in. Signature of execute in firebird.pas is: " function execute(status: IStatus; transaction: ITransaction; inMetadata: IMessageMetadata; inBuffer: Pointer; outMetadata: IMessageMetadata; outBuffer: Pointer): ITransaction; " A value for outMetadata probably is available by IStatement.getOutputMetadata(). What if one wants to use IAttachment.execute() where no IStatement is available? How can one know if IAttachment.execute() or IAttachment.openCursor() must be called without having IStatement.getFlags() from a prepared statement other than parsing the SQL statement in user code? Does IAttachment.prepare() involve a server roundtrip? Thanks for your patience. Martin ++ Visit http://www.firebirdsql.org and click the Documentation item on the main (top) menu. Try FAQ and other links from the left-side menu there. Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ ++ Yahoo Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/firebird-support/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/firebird-support/join (Yahoo! ID required) <*> To change settings via email: firebird-support-dig...@yahoogroups.com firebird-support-fullfeatu...@yahoogroups.com <*> To unsubscribe from this group, send an email to: firebird-support-unsubscr...@yahoogroups.com <*> Your use of Yahoo Groups is subject to: https://info.yahoo.com/legal/us/yahoo/utos/terms/
[firebird-support] Re: FB3 returning clause and new API
Martin Schreiber mse00...@gmail.com [firebird-support] a écrit : > On Thursday 15 September 2016 11:09:43 Dimitry Sibiryakov s...@ibphoenix.com > [firebird-support] wrote: >> 15.09.2016 11:14, Martin Schreiber mse00...@gmail.com [firebird-support] >> wrote: >>> What if one wants to use >>> IAttachment.execute() where no IStatement is available? >> >>(S)he must provide IMetadata built with builder. > > I am implementing a Firebird 3 connection component for MSEide+MSEgui (a Free > Pascal toolkit) so I don't know the returned data of the statements in the > first place. > In case of input params I implemented an own IMessageMetadata derivate which > uses the type information of TParam in order to setup the metadata. In case > of "returning" the data type is unknown without parsing the SQL statement. > It seems I always need to prepare the statement first? > > Martin below, a bit dirty but functional code in codetyphon, reading the buffer is RS unit UserData; {$mode delphi} {$H+} interface uses Classes, SysUtils, lNet, Firebird, DateUtils, Tzutil, stdctrls, fgl, TgzIo, TzDeflate, TzCompres, FBRecordU; type FBSockException = class(Exception); TByteArray = array of byte; TListoutBuffer = array of TByteArray; buf_byte_ptr = ^buf_byte; buf_byte = array[0..4095] of byte; buf_AnsiChar = array of AnsiChar; buf_AnsiCharptr = ^buf_AnsiChar; InMessage = record n: SmallInt; nNull: WordBool; end; OutMessage = record relationId: SmallInt; relationIdNull: WordBool; relationName: array[0..93] of AnsiChar; relationNameNull: WordBool; end; TDataEvent = procedure (Data: AnsiString) of object; TServerObjectWorkerThread = class; TThrdExeProc = procedure of object; TServerObjectWorkerThread = class(TThread) protected FName : String; FStarted : Boolean; FThrdExeProc : TThrdExeProc; public procedure Execute; override; property Name: String read FName write FName; property Started : Boolean read FStarted write FStarted; property ThrdExeProc : TThrdExeProcread FThrdExeProc write FThrdExeProc; end; TUserData = class private _userdata : string; _asocket : TLSocket; _fmemo: TMemo; st : IStatus; master : IMaster ; util : IUtil; dpb : IXpbBuilder; prov : IProvider; att : IAttachment; tra : ITransaction; stmt: IStatement; rs: IResultSet; inMetadata, outMetadata: IMessageMetadata; inBuffer: InMessage; outBuffer: array of byte; outBufferptr: ^TByteArray; strm: TMemoryStream; procedure writeuserdata(fdata:String); procedure PrintError(s : IStatus; fmessage:string); private procedure sendfirstbuffer; procedure senddata(fdata:ansistring); procedure sendSize(fint:uint); Procedure SendCompressedString(str: ansistring); Procedure SendCompressedBytes(str: tBytesStream); Procedure SendRecord(str : ansiString); Function CompressToString(str: ansistring):ansistring; function concatbyte(a, b: array of byte):TByteArray; public constructor create(fsocket:TLSocket;amemo:tmemo); destructor destroy; override; property userdata : string read _userdata write writeuserdata; const RAW_WBITS = 15; end; implementation {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *} procedure TServerObjectWorkerThread.Execute; begin end; constructor TUserData.create(fsocket:TLSocket; amemo:TMemo); begin _asocket := fsocket; _asocket.SetState(ssNoDelay,true); _fmemo := amemo; _userdata := ''; strm := TMemoryStream.create; end; destructor TUserData.destroy; begin if att<> nil then att.detach(st); att := nil; if dpb <> nil then dpb.dispose; dpb := nil; if prov <> nil then prov.release; prov := nil; if st <> nil then begin st.dispose(); end; st := nil; if util<> nil then util := nil; if master<>nil then master := nil; _userdata:=''; if inMetadata <> nil then inMetadata := nil; if outMetadata <> nil then outMetadata := nil; _asocket.UserData:=nil; if strm<> nil then freeandnil(strm); inherited destroy; end; procedure TUserdata.PrintError(s : IStatus; fmessage:string); var maxMessage : Integer; outMessage : PAnsiChar; begin maxMessage := 256; outMessage := StrAlloc(maxMessage); util.formatStatus(outMessage, maxMessage, s); _fmemo.Append(concat(outMessage,#13#10,fmessage));
Re: [firebird-support] FB3 returning clause and new API
On Thursday 15 September 2016 11:09:43 Dimitry Sibiryakov s...@ibphoenix.com [firebird-support] wrote: > 15.09.2016 11:14, Martin Schreiber mse00...@gmail.com [firebird-support] wrote: > > What if one wants to use > > IAttachment.execute() where no IStatement is available? > >(S)he must provide IMetadata built with builder. I am implementing a Firebird 3 connection component for MSEide+MSEgui (a Free Pascal toolkit) so I don't know the returned data of the statements in the first place. In case of input params I implemented an own IMessageMetadata derivate which uses the type information of TParam in order to setup the metadata. In case of "returning" the data type is unknown without parsing the SQL statement. It seems I always need to prepare the statement first? Martin ++ Visit http://www.firebirdsql.org and click the Documentation item on the main (top) menu. Try FAQ and other links from the left-side menu there. Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ ++ Yahoo Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/firebird-support/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/firebird-support/join (Yahoo! ID required) <*> To change settings via email: firebird-support-dig...@yahoogroups.com firebird-support-fullfeatu...@yahoogroups.com <*> To unsubscribe from this group, send an email to: firebird-support-unsubscr...@yahoogroups.com <*> Your use of Yahoo Groups is subject to: https://info.yahoo.com/legal/us/yahoo/utos/terms/
Re: [firebird-support] FB3 returning clause and new API
15.09.2016 11:14, Martin Schreiber mse00...@gmail.com [firebird-support] wrote: > What if one wants to use > IAttachment.execute() where no IStatement is available? (S)he must provide IMetadata built with builder. -- WBR, SD. ++ Visit http://www.firebirdsql.org and click the Documentation item on the main (top) menu. Try FAQ and other links from the left-side menu there. Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ ++ Yahoo Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/firebird-support/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/firebird-support/join (Yahoo! ID required) <*> To change settings via email: firebird-support-dig...@yahoogroups.com firebird-support-fullfeatu...@yahoogroups.com <*> To unsubscribe from this group, send an email to: firebird-support-unsubscr...@yahoogroups.com <*> Your use of Yahoo Groups is subject to: https://info.yahoo.com/legal/us/yahoo/utos/terms/