![]() |
Datenbank: SQL • Version: QDA Version9 • Zugriff über: Delphi
how to extract a list from a query to pass it to the next function
Hi Guys,
I am fighting with a piece of Code and can not move Forwards, do you a have a hint for a Delphi SQL beginner? I want to extract a list of names from a Database for making a return in my function and after that passing that to another function in my big program. 1. I tried following Code making a big program and I got my csv table with the column of names, but if I try to separate my big program in Little modules, it does not work any more I got by Debugging a run time error E/AFehler 103 when evaluating the instruction PushVar($0,$0,0,$0,$0,'Result'9. in the Position: (***) I am sure it is a very stupid Thing, but I cannot catch it now. 2. it is possible to Export this Little query to assign it to my fn1 result for passing this value to the function fn2? thnaks a lot in Advance and Kind regards Piedad function fn1:String; var ... qryPMV := TQuery.Create(nil); tsSQLListe := TStringList.create; qryPMV.DatabaseName := 'DB'; qryPMV.Close; qryPMV.Sql.Clear; qryPMV.Sql.Add('SELECT Distinct column1 PMV '); qryPMV.Sql.Add('FROM MMV_DB '); qryPMV.Sql.Add('Order by PMV '); strSQL := qryPMV.Sql.GetText; qryPMV.Open; if not (qryPMV.bof and qryPMV.eof) then begin strHeader := 'PM_guys'; Writeln(tfFilePointer, strHeader); (***) WHILE not qryPMV.EOF do begin strOutputZeile := ''; tsSQLListe.Add(cTrenner + qryPMV.FieldByName('PM_VERANTWORTLICHER').AsString ); strPPV := StringReplace(tsSQLListe.text, cCRLF, cDelimiter, 1); strOutputZeile := strPPV; tsSQLListe.Clear; Writeln(tfFilePointer, strOutputZeile); qryPMV.next; end; end; CloseFile(tfFilePointer); |
AW: how to extract a list from a query to pass it to the next function
.. maybe it will work in that way
Best regards Klaus
Delphi-Quellcode:
procedure fn1(var sl:TStringList);
var ... qryPMV := TQuery.Create(nil); qryPMV.DatabaseName := 'DB'; qryPMV.Close; qryPMV.Sql.Clear; qryPMV.Sql.Add('SELECT Distinct column1 PMV '); qryPMV.Sql.Add('FROM MMV_DB '); qryPMV.Sql.Add('Order by PMV '); strSQL := qryPMV.Sql.GetText; qryPMV.Open; if not (qryPMV.bof and qryPMV.eof) then begin strHeader := 'PM_guys'; WHILE not qryPMV.EOF do begin strOutputZeile := ''; strPPV := strHeader + cTrenner + qryPMV.FieldByName('PM_VERANTWORTLICHER').AsString; strPPV := StringReplace(strPPV, cCRLF, cDelimiter, 1); sl.add(strPPV); qryPMV.next; end; end; |
AW: how to extract a list from a query to pass it to the next function
Hi Klaus thanks a lot, I still does not get working in this waymaybe another idea ?
Best regards Piedad |
AW: how to extract a list from a query to pass it to the next function
FYI: There is an English version of Delphipraxis:
![]() |
AW: how to extract a list from a query to pass it to the next function
Zitat:
Zitat:
Any error message? Any result which you get which looks not as expected? I still don't understand what the TStringlist is for and why the "tfFilePointer"? Btw. It is interesting that you write in english, but some parts of the source code are german ;-) |
AW: how to extract a list from a query to pass it to the next function
Zitat:
This was simply a hint that there is an English version of DP and that not everybody can/will answer in English here.. |
AW: how to extract a list from a query to pass it to the next function
Hello,
Zitat:
Your code is almost ready. create a StringList, put it as a parameter to your submethod und replace the following in your submethod Writeln(tfFilePointer, strOutputZeile); with StringlistParam.Add(strOutputZeile); |
AW: how to extract a list from a query to pass it to the next function
thank you hoika, that was really what I was Looking for.
|
AW: how to extract a list from a query to pass it to the next function
Zitat:
I have to check it again |
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:29 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz