Autor Beitrag
D. Annies
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 28.06.09 14:52 
Hi, Delpher,

ich brauche mal Hilfe bei dem folgenden Query-Befehl, er ist noch fehlerhaft:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
query1.SQL.Text :=
      format('select geschlecht, punkte, klasse, name, vorname from "%s" S '  +
             'where S.klasse like quotedstr(form1.ListBox1.Items[form1.ListBox1.itemindex][1]) ' +
             'order by S.geschlecht, S.punkte, S.klasse, S.name, S.vorname', [Table1.tablename]);


Wie ist es richtig?
Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: So 28.06.09 15:01 
Willst du jetzt "richtig" oder "funktioniert"?

Ersteres wären Prepared Statements mit Variablen, letzteres wäre das:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
query1.SQL.Text :=
      format('select geschlecht, punkte, klasse, name, vorname from "%s" S '  +
             'where S.klasse like ''%s'' ' +
             'order by S.geschlecht, S.punkte, S.klasse, S.name, S.vorname',
            [Table1.tablename, quotedstr(form1.ListBox1.Items[form1.ListBox1.itemindex][1])]);

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 28.06.09 15:20 
Danke für deine schnelle Antwort, aber leider Fehlermeldung:
Ungültiges Schlüsselwort in Zeile 1 Symbolstring 7''

wenn ich Klasse 7, also 7a bis 7e prüfen will.

_________________
ut vires desint, tamen est laudanda voluntas
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 28.06.09 15:35 
Ich würde das per (SQl-)Parameter lösen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
query1.SQL.Text :=
      format('select geschlecht, punkte, klasse, name, vorname from %s S '  +
             'where S.klasse like :klasse' +
             'order by S.geschlecht, S.punkte, S.klasse, S.name, S.vorname', [Table1.tablename]);
Query1.ParamByName('klasse').Value := form1.ListBox1.Items[form1.ListBox1.itemindex][1];

_________________
Markus Kinzler.
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 28.06.09 16:17 
Hi, Marcus,

tatsächlich muss oben .. from "%s" S ... stehen -

und jetzt muss ich noch rauskriegen, wieso in der query 0 Datensätze stehen.
Danke erstmal.

Gruß, Detlef

_________________
ut vires desint, tamen est laudanda voluntas
D. Annies Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 1843

windows 7
D6 Enterprise, D7 Pers und TD 2006
BeitragVerfasst: So 28.06.09 16:53 
Gelöst:

Hinter dem Parambyname ... muss noch + '%' als Joker stehen, damit alle Parallelklassen bearbeitet werden! JuHu,

Detlef

_________________
ut vires desint, tamen est laudanda voluntas