Do not let any software impress you!

Only let it convince your intellect.
Slider img 1
Do not look for a business paradise!

It is a waste of time.
Slider img 2
Only yourself can push you uphill.

There is no easy road to prizes.
Slider img 3
Productivity is the name of the game.

And you have to conquer it.
Slider img 4
As long as you understand it,

you will start to build your know-how.
Slider img 5
We can help with that.

We have the tools and the method.
Slider img 6

Embedded SQL to Update records of the Database



A situation may arise where we need to update many records in a database table when specific information changes or needs to be modified.
You can use embedded SQL to update values in a table for all records or records that match specified criteria.
For Example, one of your product suppliers has decided to increase the price of their products by 3 percent (%). Let us see the steps.

1. Open the application.
2. Right-click and select “Developer.“
3. Select “Scripts“ and then select “Create.“
4. In the window, you must write your code.

proc upd_price()

       start_sql “PRODUCTS_LIST” “KOSMOS”
         SELECT
         PRODUCTS.PRODUCT, PRODUCTS.PRICE
         FROM
         PRODUCTS
         WHERE
         PRODUCTS.SUPPLIER = 2300
       end_sql
       q= QueryByName(“PRODUCTS_LIST”)
       
       rcount = TRecordCount(q)
 
       call TFirst(q)
       for i = 1 to rcount

         new_price = PRODUCTS_LIST.PRICE * 1,03
         start_sql “*”“KOSMOS”        
                UPDATE PRODUCTS
                WHERE (PRODUCTS = :P)        
         end_sql
         t = QueryByName()
         call TSetParam(t, “P“, PRODUCTS_LIST.PRODUCT)
         call TSetFld(t, ”PRICE”, “Float“, new_price)
         call TExecute(t)
         call FreeEmbSQL(t)

         call TNext(q)
       next

       call FreeEmbSQL(q)
 end

5. Save changes and close the window.
6. Call the procedure.
(You can call the procedure from the menu or with a button.
The command you use is “call procedure name().“
For example “call upd_price()“ )