AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Datenbanken SQL Select IN Abfrage mit Parameter ?
Thema durchsuchen
Ansicht
Themen-Optionen

SQL Select IN Abfrage mit Parameter ?

Ein Thema von user0815 · begonnen am 30. Okt 2012 · letzter Beitrag vom 31. Okt 2012
 
Benutzerbild von user0815
user0815

Registriert seit: 5. Okt 2007
331 Beiträge
 
Delphi XE2 Professional
 
#9

AW: SQL Select IN Abfrage mit Parameter ?

  Alt 31. Okt 2012, 10:53
DANKE !
In der Hilfe gefunden, ausprobiert, funktioniert.

Zitat:
Working with Macros
Macros help you to change SQL statements dynamically. They allow partial replacement of the query statement by user-defined text. Macros are identified by their names which are then referred from SQL statement to replace their occurrences for associated values.
First step is to assign macros with their names and values to a dataset object.
Then modify SQL statement to include macro names into desired insertion points. Prefix each name with & ("at") sign to let UniDAC discriminate them at parse time. Resolved SQL statement will hold macro values instead of their names but at the right places of their occurrences. For example, having the following statement with the TableName macro name:

SELECT * FROM &TableName

You may later assign any actual table name to the macro value property leaving your SQL statement intact.

Query1.SQL.Text := 'SELECT * FROM &TableName';
Query1.MacroByName('TableName').Value := 'Dept';
Query1.Open;

UniDAC replaces all macro names with their values and sends SQL statement to the server when SQL execution is requested.
Delphi-Quellcode:
  SQL.Clear;
  SQL.Add('SELECT');
  SQL.Add(' FELD1, FELD2, DATUM');
  SQL.Add('WHERE');
  SQL.Add(' FELD1 IN (&Feldwerte) AND');
  SQL.Add(' DATUM >= :DATE1');
  SQL.Add('ORDER BY');
  SQL.Add(' FELD1 DESC');

  ParamCheck := true;
  ParamByName('DATE1').AsDateTime:= StartOfTheDay(DateTimePicker1.Date);
  MacroByName('Feldwerte').Value := '1,2,3,4,5,6,7,8,9';
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:58 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