procedure TForm1.Button3Click(Sender: TObject);
var
blobID, blobRefID: system.Classes.TStream;
MyStreamID: TMemoryStream;
MyGuid0: TGUID;
sISBN,oldURL:
string;
sLINK:
string;
nRECNUM: integer;
k: Integer;
begin
nRecnum:=0;
while not(uniquery1.Eof)
do
begin
nRecNUm:=nrECNUm+1;
sISBN:=Uniquery1.FieldByName('
ISBN').AsString;
if getlinefromMemo(sISBN)
then
begin
label4.Caption:=Format('
LINKs found: %d @ RecNr.: %d',[listbox1.Count,Nrecnum]);
for k := 0
to listbox1.Count-1
do
begin
MyStreamID := TMemoryStream.Create;
if UniConnection1.ProviderName='
SQLite'
then
begin
(*
// INsert into location in Citavi DB
> insert into Location (ID,Address,ReferenceID,CreatedOn,ModifiedOn,AddressInfo,LocationType,PreviewBehaviour)
> (
> :MyRANDGUID,
> :FILENAME,
> :RefID,
> datetime(strftime('%s','now'), 'unixepoch', 'localtime'),
> datetime(strftime('%s','now'), 'unixepoch', 'localtime'),
> 1,
> 0,
> 0);
*)
blobID := UniQuery1.CreateBlobStream(UniQuery1.FieldByName('
ID'), bmRead);
// HIER HAPPERTS.
MyStreamID.Clear;
MyStreamID.LoadFromStream(blobID );
uniquery2.ParamByName('
RefID').LoadFromStream(MyStreamID, ftBlob);
CreateGUID(MyGuid0);
uniquery2.ParamByName('
MyRandGUID').AsBlob:=TEncoding.UTF8.GetBytes(GUIDToString(MyGuid0));
Label5.Caption:=Format('
DB Record GUID: %s : %s',[uniquery1.FieldByName('
MYID').AsString,uniquery1.FieldByName('
ID').AsString]);
end
else
begin
uniquery2.SQL.Text:='
Update refs set URL = :Filename where id = :RefID';
if not(checkbox3.Checked)
then
uniquery2.SQL.Text:='
Update refs set link_to_pdf = :Filename where id = :RefID';
uniquery2.ParamByName('
RefID').AsString:=uniquery1.FieldByName('
id').AsString;
end;
if (UniConnection1.ProviderName='
MySQL')
then
begin
if not(checkbox3.Checked)
then
oldURL:=uniquery1.FieldByName('
link_to_pdf').AsString
else
oldURL:=uniquery1.FieldByName('
url').AsString;
end;
if trim(oldURL) = '
'
then
uniquery2.ParamByName('
Filename').AsString:=convertfn(listbox1.Items[k])
else
uniquery2.ParamByName('
Filename').AsString:=oldURL+#13#10+convertfn(listbox1.Items[k]) ;
uniquery2.Execute;
MyStreamID.Free;
WriteLOgMemo(Format('
UPD: ISBN: %s -> Affected Rows: %d',[sISBN,uniquery2.RowsAffected]));
end;
Application.ProcessMessages;
end;
uniquery1.Next;
end;
WriteLOgMemo(Format('
UPDATE with URLs finished: Total affected Rows: %d',[nrecnum]));
end;