Making query without table lazarus / 16-Databases ---------------------------------------------------------------------- madref · 2015-06-02 15:32 I want to make the following query. 2|2-man 3|3-man 4|4-man Is that possible without a table? ---------------------------------------------------------------------- sin_dragan · 2015-06-02 19:19 That query has to connected to some Database (local or server), I don't understand your question about a table. If you have those data in the database it is possible to retrieve them via select query. ---------------------------------------------------------------------- madref · 2015-06-02 19:52 i want to store these values in a DBCombobox and store them automatically in a different table ---------------------------------------------------------------------- Martin_fr · 2015-06-02 20:54 If you are connected to a postgresql server the following should work select unnest, unnest||'-man' from unnest(ARRAY[1,2,3]) ---------------------------------------------------------------------- madref · 2015-06-03 10:10 Nope its a stand alone ---------------------------------------------------------------------- rvk · 2015-06-03 11:25 Quote from: madref on June 02, 2015, 09:52:08 pmi want to store these values in a DBCombobox and store them automatically in a different table You can use DBCombobox.Items to store these values. But because DBCombobox uses just strings in Items and not a key you can't automatically store a key in the result-field of your database. This is how you can fill in the DBCombobox1: Code: [Select]  DBCombobox1.Items.Clear;   DBCombobox1.Items.Add('2|2-man');   DBCombobox1.Items.Add('3|3-man');   DBCombobox1.Items.Add('4|4-man'); (or use the ObjectInspector to fill the Items-property) But my guess is you want the 2, 3 and 4 as Integer in your result- field and not as String. In that case it might be better to use a TDBLookupCombobox in combination with a TMemoryDataset. In your FormCreate you can do this: Code: [Select]procedure TForm1.FormCreate(Sender: TObject); var   tbMem: TMemDataset;   dsMem: TDataSource; begin   tbMem := TMemDataset.Create(Self);   tbMem.FieldDefs.Add('Id', ftInteger);   tbMem.FieldDefs.Add('Name', ftstring, 30);   tbMem.CreateTable;   tbMem.Open;   tbMem.Insert;   tbMem.FieldByName('Id').AsInteger := 2;   tbMem.FieldByName('Name').AsString := '2-man';   tbMem.Post;   tbMem.Insert;   tbMem.FieldByName('Id').AsInteger := 3;   tbMem.FieldByName('Name').AsString := '3-man';   tbMem.Post;   tbMem.Insert;   tbMem.FieldByName('Id').AsInteger := 3;   tbMem.FieldByName('Name').AsString := '3-man';   tbMem.Post;   tbMem.First;   dsMem := TDataSource.Create(Self);   dsMem.DataSet := tbMem;   DBLookupCombobox1.KeyField := 'Id';   DBLookupCombobox1.ListField := 'Name';   DBLookupCombobox1.ListSource := dsMem;   DBLookupCombobox1.DataSource := yourdataset;   DBLookupCombobox1.DataField := 'yourfield'; end; Now you have a virtual table in memory with 2-man, 3-man and 4-man and when choosing one in the TDBLookupCombobox the index (1, 2 or 3) is used to fill in your DB-field. ---------------------------------------------------------------------- madref · 2015-06-04 07:21 Thanx Rik