How can I clear all the records from a TDataSource? - delphi-xe

I thought this would be simple but don't see a function that clears all records from the dataset of a TDataSource.
Any ideas?

There is no such function. You have to step through all records.
while ds.RecordCount>0 do
ds.delete;

try clear the DataSet with EmptyDataSet..
Example... ds.EmptyDataSet;

Related

How to filter out stuff from one column that is listed in another one?

I'm attempting to filter one column from another and the formula worked at first. Then I cleared the data and tried to reselect and now it doesn't work. What's the problem?
=FILTER(A2:A100,A2:A100=C2:C100)
you kinda need this:
=FILTER(A2:A, NOT(COUNTIF(E2:E, A2:A)))

Elquent Relation Limit records

I'm trying to send API with certain number of records
$category->products
I tried to use limit() or take() but it fails
so is there any smart solution than go to pivot and select it with limit ??
Copy data to a new collection.
$collection =$category->products;
you can now send the number of times you want using take ().
for example;
$collection->take(5);
if your question is different please explain it more clearly.
I found the solution I was easy
$category->products()->limit(2)->get()->all()
that's all

How can I remove unique column laravel 5

How can I dropUnique the column a_b from z table?
If it would be just column a, we can do this:
$table->dropUnique('z_a_unique');
I've tried:
$table->dropUnique('z_a_b_unique');
But obviously it didn't work.
Thanks for your help in advance!
dropUnqiue() will drop index, not the column. You need to use dropColumn() after dropUnique():
$table->dropColumn('a_b');
Actually, the answer is in the question, sorry guys, it works like this:
$table->dropUnique('z_a_b_unique');
And solved my problem

Using pluck with maximum

Is it possible to chain options when using maximum?
I have a PhoneStats class and I want to pull the name from a few columns who have the maximum value in the table. For example if I run
PhoneStat.maximum('calls')
I get the value I expect but I would like to get maximum value as well as the id of the user in that record. Is it possible to use pluck or collect for something like this?
Thanks spickermann
Thanks. Below got me exactly what I needed.
PhoneStat.order('calls DESC').pluck(:name).first
You have to write this a bit more detailed:
PhoneStat.order('calls DESC').first

SQL merging rows with same time

I am asking for help with my databse. I need a SQL query doing following.
http://shrani.si/f/2E/ge/2JXHBdq2/untitled.png
As you can see, that the time is equal in 3 rows, but the data is not in one row. What i want, is to make 1 row out of these.
http://shrani.si/f/3W/lZ/4NJJyHxf/untitled.png
Could u help me generate the query, if its possible? Or will i have to loop trough the databse and compare values and paste them together?
Thnx for your help!
select breaks,date,time, max(field1), max(field2).....
from table
group by breaks,date, time
not sure if max will work but some, but try it.

Resources