Icon View Thread

The following is the text of the current message along with any replies.
Messages 21 to 23 of 23 total
Thread ExecSQL in ewb
Wed, Jul 1 2015 6:46 PMPermanent Link

Raul

Team Elevate Team Elevate

On 7/1/2015 6:28 AM, Hüseyin Aliz wrote:
> Here's what i do now (working but may not be optimal solution).
> - When user clicks a button (menu), a new form is created with a new
> order number assigned.
> - When user enters the form, items grid are populated with items (5-10
> max) lines.
> - User selects the items to be inserted to the orderline dataset, and
> orderline will be posted to the dataset with a transaction.

OK.


> if user decides to remove all lines, i am now using the method
> (suggested by you) by deleting from dataset and afterwards select * from.
> So to start with, there are no orderlines

You can but using EWB dataset should work just as well - just start a
transaction and then loop thru the dataset deleting all the rows and
then commit. Once you commit this should result EWB sending a
transaction to back end server that basically does a delete for every
row your dataset had.

The only reason i'm suggesting this is that you can use the same dataset
and all your EWB logic is essentially similar:

Insert would look like this (i omitted the try/except and rollback to
keep it brief) :

Database.StartTransaction;

//add record to your dataset
myDataset.Insert;
Columns['MyColumn1'].AsString:='something';
//keep adding more column data as needed
myDataset.Save

Database.Commit;

and removing all the lines would be something like this  :

Database.StartTransaction;
myDataset.First
while myDataset.EOF = false do
begin
  myDataset.Delete
end;
Database.Commit;


Thu, Jul 2 2015 5:38 PMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Raul,

Thank you, learning about ewb every day Smile

Regards,
Hüseyin

On 02-07-2015 00:46, Raul wrote:
> On 7/1/2015 6:28 AM, Hüseyin Aliz wrote:
>> Here's what i do now (working but may not be optimal solution).
>> - When user clicks a button (menu), a new form is created with a new
>> order number assigned.
>> - When user enters the form, items grid are populated with items (5-10
>> max) lines.
>> - User selects the items to be inserted to the orderline dataset, and
>> orderline will be posted to the dataset with a transaction.
>
> OK.
>
>
>> if user decides to remove all lines, i am now using the method
>> (suggested by you) by deleting from dataset and afterwards select *
>> from.
>> So to start with, there are no orderlines
>
> You can but using EWB dataset should work just as well - just start a
> transaction and then loop thru the dataset deleting all the rows and
> then commit. Once you commit this should result EWB sending a
> transaction to back end server that basically does a delete for every
> row your dataset had.
>
> The only reason i'm suggesting this is that you can use the same
> dataset and all your EWB logic is essentially similar:
>
> Insert would look like this (i omitted the try/except and rollback to
> keep it brief) :
>
> Database.StartTransaction;
>
> //add record to your dataset
> myDataset.Insert;
> Columns['MyColumn1'].AsString:='something';
> //keep adding more column data as needed
> myDataset.Save
>
> Database.Commit;
>
> and removing all the lines would be something like this  :
>
> Database.StartTransaction;
> myDataset.First
> while myDataset.EOF = false do
> begin
>   myDataset.Delete
> end;
> Database.Commit;
>
>
>

Fri, Jul 3 2015 2:48 PMPermanent Link

Huseyin Aliz

myBiss ApS

Avatar

Hi Raul,

I ended up using runtime dataset for this:

- I create and open defined (runtime) dataset, and insert the rows from
the grid (items) into this dataset.
- Deleting rows/items are done with runtime dataset without using
transactions.
- Finally when user decides to confirm - all rows from runtime dataset
are appended to a static dataset (orderlines) in a transaction.

It seems to work now, so thank you and others for your input.

I can post the code if anyone is interested Smile

Regards,
Hüseyin


On 02-07-2015 00:46, Raul wrote:
> On 7/1/2015 6:28 AM, Hüseyin Aliz wrote:
>> Here's what i do now (working but may not be optimal solution).
>> - When user clicks a button (menu), a new form is created with a new
>> order number assigned.
>> - When user enters the form, items grid are populated with items (5-10
>> max) lines.
>> - User selects the items to be inserted to the orderline dataset, and
>> orderline will be posted to the dataset with a transaction.
>
> OK.
>
>
>> if user decides to remove all lines, i am now using the method
>> (suggested by you) by deleting from dataset and afterwards select *
>> from.
>> So to start with, there are no orderlines
>
> You can but using EWB dataset should work just as well - just start a
> transaction and then loop thru the dataset deleting all the rows and
> then commit. Once you commit this should result EWB sending a
> transaction to back end server that basically does a delete for every
> row your dataset had.
>
> The only reason i'm suggesting this is that you can use the same
> dataset and all your EWB logic is essentially similar:
>
> Insert would look like this (i omitted the try/except and rollback to
> keep it brief) :
>
> Database.StartTransaction;
>
> //add record to your dataset
> myDataset.Insert;
> Columns['MyColumn1'].AsString:='something';
> //keep adding more column data as needed
> myDataset.Save
>
> Database.Commit;
>
> and removing all the lines would be something like this  :
>
> Database.StartTransaction;
> myDataset.First
> while myDataset.EOF = false do
> begin
>   myDataset.Delete
> end;
> Database.Commit;
>
>
>
« Previous PagePage 3 of 3
Jump to Page:  1 2 3
Image