[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 199
  • Last Modified:

Please, anyone HELP ME!!! dbExpress NOOB question - I just need a simple example please

Hi folks,

I´ve already looked forward and read about GENERATORs and TRIGGERs (for days). I am using Delphi 7 and Firebird with dbExpress components (i need to implement this in dbExpress).

My NOOB question is: could anyone do a example for me (?)using:
- SQLConnection + SQLQuery + ClientDataSet + DataSetProvider;
- 2 buttons (INSERT and POST);
- 1 DBGrid

Suppose that i just have one table called CUSTOMER and this table contains just two fields (ID and CUSTOMER_NAME).

What i deeply need is: when i click in INSERT button, i just fill the field CUSTOMER_NAME (in the DBGrid) with anyname and, after click in POST, i´d like that the GENERATOR works (as well the TRIGGER) and i could see, immediatly, the NUMBER generated besides the CUSTOMER_NAME (in the field ID, which is in the DBGrid too).

Hey guys, i deeply need it. If anyone helps me, i will be very happy.

Best regards and thx. for now.
0
joelsilva
Asked:
joelsilva
1 Solution
 
joncmoraCommented:
The best way to get the generated number is to implement the INSERT in a stored procedure then make it an OUT parameter.

Another way is to get a bookmark for the newly inserted record, refresh/requery the table, then go back to the bookmarked record. Remember to call DisableControls before refreshing to minimize too much refresh. Call EnableControls after the refresh.

Hope this helps...
0
 
joelsilvaAuthor Commented:
Thx. for your comments.

I like the STORED PROCEDURE way. Must i create this STORED PROCEDURE in Delphi or in the database level? Could you give a example using SP?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now