copy records in a master/detail clientdataset delphi dbexpress - delphi

How can I copy the information of a record from a master/detail clientdataset to a new record or to an existing one.
For example I want to copy te data of invoice No. 100 to Invoice No. 150 or the information of invoice No. 100 to a new Invoice
With IBX I did that with storedprocedures but I am running into trouble with clientdataset with 'lock conflict on no wait transaction' when I apply the updates, i think its becasue the information is already on the server side.
Thanks in advance

'Lock conflic on no wait transaction'?
AFAIR, it's an Interbase/Firebird error. It could mean that other connection modified the record and still doesn't committed yet....
UPDATE:
Other things that came to mind:
Have you revised your DBX connection configuration? If you don't know/ignore what CommitRetaining is/do, make sure it's configured to FALSE. Otherwise, other problems will arise...
On Firebird/Interbase, you can only commit/rollback from Client application. SPs have no business with transaction control.

Related

Firebird Trace SP's / Steps

I need a simple and free program to monitor all transactions on a Firebird Server.
I'm creating a web API that needs to mimic a user creating a new order in a custom made program.
Since I haven't got access to the source code I guess my best chance to properly insert all the data is to use the existing stored procedures. I can see all the SP's on the Firebird server and the details but I haven't got a clue which ones to use and in what order.
So the plan would be to monitor the activities while creating an order.
Many thanks for the help!
Thank you Mark & Arioch for contributing.
After hours of failed experimenting with the included fbtrace.exe included in Firebird 2.5 installation i've decided to use "FB TraceManager" Trial version.
Found here: https://www.upscene.com/downloads/fbtm

Local Firebird Table Editing

My application was coded under Delphi XE5 + Firebird-2.5.6, client / server. ZeosLib.
If I want to edit a record like this:
ZTable1.Edit;
ZTable1.FieldValues['champ1'] := Edit1.Text;
ZTable1.Post;
I wanted to know if this code on the local network, could it have worries or a conflict of editing and post please? That is, editing the table by multiple users will not even have an impact or an error message that pops up at those users. If yes, how to avoid this inconvenience please?
Thank you for your help.
It depends on the action with this record that will make the other user and how long your transaction will be active.
For read or after commit or rollback your transaction will be no conflict
Before a transaction end for editing or deleting the record of another user may lock a message or if a user transaction is started with no_wait flag, waiting edited transaction completion
P.S. Zeos for Firebird is a very straingth choice. Why you not uses standard IBX library?

How to design a good QuickBooks integration solution

I have now played with the QBO and QBD APIs and feel I have a fair understanding of how it thinks and how to interact with it. So now it is time to design the actual integration solution.
Inside my application you can create new customers, quote services, perform services, and soon, pass invoices to QuickBooks, sounds easy.
But what if the customer is not in QB yet? No problem - for each invoice I will look up the customer (need the id anyway) and if it doesn’t exist, add it. But if I have to look up the customer for each invoice it seems like it might be slow. I will likely have 30,000 customers and have 500-3000 invoices per day.
So my question is this; what are others doing?
a) Are you storing the QB id for each customer in your data?
b) How do you detect address changes (changed in your app and changed in QB)?
c) Is the batch submission interface so much faster I should use that?
Thanks for your help!
We often times do store the QB id in our database for use. If we post an invoice into QB, we'll then store the QB id for future use if we need to modify it.
As far as detecting changes on the customer record and other info, there's a couple ways to handle the conflict resolution. One is to keep a timestamp on your side as to when changes are made. You can then compare this with the timestamp of the last change on the QB record and then make your decision as to which one gets updated.
FreddyMac,
To detect changes on the Intuit side you can construct a query with a CDCasOf Filter, which will return only the data that has changed since a date you provide. (ChangeDataCapture as of)
https://ipp.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/0500_QuickBooks_Windows/0100_Calling_Data_Services/0015_Retrieving_Objects
You need to keep track of data changes on your side.
The batch submission is not faster, its just easier for you to write the code.
The IPP SDK can queue the API calls for your and aggregate the responses.
regards,
Jarred

Problems with Delphi XE2, DataSnap and Lookup Field

I have a bit of problem here. I have created a lookupfield in my application server using Delphi XE2 DataSnap technology. On the client side, that field becomes TStringField. Now, the problem is that I loose the lookup functionality on the client side. To top that, I can't change the stringfield on the client side because it is read only (even if I manually turn off the read only property).
I don't want to lookup tables on the client side because I don't want all the data loaded on my client side just to support look up.
I can change the Key field value, but the stringfield lookup text doesnt change unless I apply updates and reload the data.
Users want to see the text change.
What should I do?
Seems you have to review your GUI functionality: lookup fields are really an client side feature. And it needs the lookup source - so to use it on client the lookup table must be loaded. DataSnap guys are very nice here, converting it to an TStringField when transmitting it to the client... I would simply ignore it.
So, if the lookup table is that big, you shouldn't using lookup fields but search UIs - or autocomplete comboboxes which you do queries against the DataSnap Server. Maybe you have to code it manually in the combobox case, I don't know (see if JVCL have something you can use to shortcut the path).
Alternatively, if the lookup table are seldom updated, you can aggresively cache it and have an updating mechanism to detect changes. So you can use the lookup fields the way they were created for.
Long time ago i faced that problem and i found a solution that is a bit complex to analyze here but i try to give some guidelines till i have the time to write a detailed blog post.
The idea consists of info (concerning lookup fields such as field properties, datasets, providers) packaged by the provider as optionalparams at the server side.
At client side a derived TClientDataset can unpack and process these info, create on the fly client datasets that retrieve needed lookup datasets and setup it's lookup fields accordingly.
The process is transparent due to the embedded functionality in the derived client dataset class and the only things to remember is to create that info in the provider's OnGetDatasetProperties event and turn false all provider flags in lookup fields.

Tracking or Notifying DB Changes - Inserts and Updates mostly

How do I track or get notified whenever a record is inserted or updated in a DB? I would like to notify an external application of the changes in near real time whenever such changes in DB occur. Are there DBMS independent and application programming language independent ways of doing this? If not, then is it possible with MS Access and MS SQL Server in particular? I'm looking to avoid continuous polling of DB of course.
With SQL Server it is possible to load a DLL within SQL Server itself and call methods from this with extended stored procedures. The DLL could then notify other applications - usually via a TCP socket.
I think the latest version of Microsoft SQL Server allows you to raise events in your .NET code based on server conditions and events. I haven't tried it, and I haven't heard of any 'DBMS independent' way of doing this (without polling DB every X milliseconds).
With MS-Access, I keep track of record changes or record additions with fields in the main table that store the user name and date when the record is created or updated.
You need to use a windows API to record the user name, usually run when switchboard form is opened.
I am digging to find a away to track specific changes. My data base is used for project management. I would like to keep track of what specifically was changed, not just who and when that I have now.
I think this meets the requirements of the original question. I can later add the windows API that reads the name of the user.
Private Sub Form_BeforeInsert(Cancel As Integer)
Me!UserCreated = UCase(CurrentUser())
Me!DateCreated = Now()
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Me!DateModified = Now()
Me!UserModified = UCase(CurrentUser())
End Sub
-- Mike
To do this with SQL Server, you use the Notification Service - write a dll that subscribes to notifications from the DB for data updates which you can process in some way.
However, MS has said that they are removing this from SQL Server 2008.
Oracle has something similar (though they tend to leave their technology in place), but I've not seen anything that is database-neutral.

Resources