You are not logged in.
Pages: 1
@gunix
Which version of Delphi are you using?Edit: my guess is that it is FPC/Lazarus.
I have committed a huge refactoring for better Lazarus compatibility of the mormot.db.rad.*.pas units.
Fpc 3.3.1, lazarus 3.6
largeintfield set filter error reported freepascal.org forum
create table testtable(prjid int8 primary key,prjname varchar(20),address varchar(64),telephone varchar(12));
INSERT INTO testtable ("prjid", "prjname", "address", "telephone") VALUES (3556856671915480078, '华泰大夏', NULL, NULL);
INSERT INTO testtable ("prjid", "prjname", "address", "telephone") VALUES (3566802869275333664, '盛世钱门', '', '17706555935');
var
i:integer;
FDBCOnnect:TSqlDBConnectionProperties;
FPData:TsqlDataset;
begin
FDBCOnnect:=TSqlDBPostgresConnectionProperties.Create('0575.tech:5432','test','test','test123');
FPData:=TsqlDataset.Create(self);
FPData.Connection:=FDBCOnnect;
FPData.CommandText:='select * from testtable';
FPData.Open;
showmessage('address size='+inttostr(FPData.fieldbyname('address').Datasize));
while not FPData.EOF do begin
showmessage(inttostr(FPData.RecNo)+'row prjname='+ FPData.FieldByName('prjname').AsWideString);
FPData.Next;
end;
I solved this problem by defining the fields of the dataset directly at design time
It's mistake,I should use TsqlDataset
but all null value widestring field the size will be 0 in TsqlDataset
TVirtualDataSet.GetFieldData to get widestring value will rise exception when value is chinese words like '测试中文' (fieldsize=12)
change
Utf8ToWideString(data, len, WideString(dest^));
to
if len = 0 then
PWideChar(dest)^ := #0
else
Utf8ToWideChar(dest, data, Field.DataSize, len);
can display right value
largeInt field set filter is Ineffective
unidac can Get field size, string field.size =character_octet_length
pq.fsize always return -1
when client app commit data to server, raise error "value is too long(20)" when insert more than 20 character ( fiedtype=varchar(20)),so, Give a permit length is a good idea in client side.
I have test ,Can't work right
procedure TSqlDBPostgresStatement.BindColumns;
var
nCols, c,k: integer;
cName: RawUtf8;
p: PUtf8Char;
begin
ClearColumns;
nCols := PQ.nfields(fRes);
fColumn.Capacity := nCols;
for c := 0 to nCols - 1 do
begin
p := PQ.fname(fRes, c);
FastSetString(cName, p, StrLen(p));
with AddColumn(cName)^ do
begin
ColumnAttr := PQ.ftype(fRes, c);
ColumnType := TSqlDBPostgresConnectionProperties(Connection.Properties).
Oid2FieldType(ColumnAttr);
//add
ColumnDataSize:=PQ.fsize(fRes, c);
end;
end;
end;
then,why FieldDefs need set field size of string field?
DBgrid Can Adjust Column width by Field size?
also I can set field size to -1
fsize :: Result
-> Column
-> IO Int
fsize result (Col colNum) = numFromResult result $ \ptr -> c_PQfsize ptr colNum;
Can Use fsize function in libpq.dll get field size on Postgresql DBMS?
if Can get field size ,the unit can be UTF-8 bytes
You can try the TSqlDBConnectionProperties.GetFields() method ab mentioned. This method outputs the field definition to the Fields parameter, which is a TSqlDBColumnDefineDynArray type. Each element contains the following information:
I don't know Field from which Table,because I read Sql from Json File, Fetch Data,Display Data.
in order to convert into Delphi TDataset, FieldDefs.Add( FieldName,FieldType,FieldSize,CanNull)
SqlStatement:TSqlDbStatement;
SqlStatement.Execute('select A.F1,A.F2,...... from Test A join xxx B on A.xxx=B.xxx where .....');
ColumnType(0) Can Get F1 FieldType ftUtf8, But i don't know how to get field size
What do you call "field size" then?
create table Test (F1 char(20), F2 varchar(10));
insert into Test(F1,F2) Values('F1 Test Value','Should ok')
How Can I get F1 Field Size=20 and F2 Field size=10?
You have ISqlDBRows.ColumnNull() for this.
For the field size, use ColumnUtf8() and its returned length.
function ColumnUtf8(Col: integer): RawUtf8;
ColumnUtf8 can't get field size, only return empty string
i Should know the size of Character field, and Whether or not field can be null?
I am not sure I understand what you meant, sorry.
Do you mean that your callback should return result = 200 so that it works as expected?
So is it solved?
Yes
I See, OnRequest call back shoud return HTTP_SUCCESS
OnRequest(Ctxt: THttpServerRequestAbstract): cardinal;
begin
Result:=HTTP_FOUND; //default return value
Ctxt.OutContentType:=TEXT_CONTENT_TYPE;
if StartWith(Ctxt.Url, uppercase('/upgradefile/')) then begin
Ctxt.OutContentType:=STATICFILE_CONTENT_TYPE;
ctxt.OutContent:=StringToUtf8('xxxxxxx');
ctxt.RespStatus:= HTTP_SUCCESS; ==> Result:=HTTP_SUCCESS;
end
end;
if Context.ContentFromFile(fn, CompressGz) then
OutContent := Context.Content ==> fRespStatus := HTTP_SUCCESS outContent no need
else
begin
FormatString('Impossible to find %', [fn], fErrorMessage);
fRespStatus := HTTP_NOTFOUND;
end;
follow :
Context.Content := OutContent; ==> if not ((OutContent <> '') and (OutContentType = STATICFILE_CONTENT_TYPE)) then Context.Content := OutContent;
Context.ContentType := OutContentType;
then can right download file
i Understand:
image is no Transparent property in pdf,so, should draw image first,then text out words.
var
Fpdf:TPdfDocumentGDI;
Apic:TGraphic;
begin
Fpdf:=TPdfDocumentGDI.Create;
Apic:=TBitmap.Create;
try
Fpdf.DefaultPaperSize:=psA4;
Fpdf.ScreenLogPixels:=Screen.PixelsPerInch;
Fpdf.AddPage;
Apic.LoadFromFile('d:\z.bmp');
Apic.Transparent:=True;
TBitmap(Apic).TransparentColor:=clWhite;
Fpdf.VCLCanvas.StretchDraw(Rect(20,20,20+Apic.Width,20+Apic.Height),Apic);
Fpdf.SaveToFile('d:\test.pdf');
finally
Apic.Free;
Fpdf.Free;
end;
------------------------------------------------
when pictuere with Transparent property set to be True,can not draw picture in pdf.
Pages: 1