Baanboard.com

Baanboard.com (http://www.baanboard.com/baanboard/index.php)
-   Tools Development (http://www.baanboard.com/baanboard/forumdisplay.php?f=8)
-   -   Insert the records of one table into another table with different company (http://www.baanboard.com/baanboard/showthread.php?t=70474)

pralash 4th October 2017 13:21

Insert the records of one table into another table with different company
 
Hi,

I'm new for LN Programming. I need to copy the records of existing table ttaad200(000-company) into my own table tccom200(600-company). I have to copy only few fields of the table ttaad200 into tccom200. Hence I have created the required field like the ttaad200 and also add some new fields in tccom200. Can anybody help me that how to read a record one by one from the table ttaad200 and also how to store them in tccom200 table.
Thanks in advance...
Regards,
senthil

mark_h 4th October 2017 16:17

in 4c4 I would do something like below - in my case I check to see if item exists and just update some fields. If I do not find the item I insert a new record. You can play with everything you need - of course wait for an ln developer they might offer better suggestions.

Code:


db.retry.point()
select        tiitm001.*
from                tiitm001
where        tiitm001.item inrange :item.f and :item.t
selectdo
        select        tiemg001.*
        from        tiemg001 for update
        where        tiemg001._index1 = {:tiitm001.item}
        selectdo
                |record found
                tiemg001.dsca = tiitm001.dsca
                tiemg001.pdty = tiitm001.ctyp
                tiemg001.ctyp = tiitm001.ctyp
                tiemg001.temp = itemtemplate
                db.update(ttiemg001,db.retry)                       
        selectempty
                | Record not found
                tiemg001.dsca = tiitm001.dsca
                tiemg001.pdty = tiitm001.ctyp
                tiemg001.ctyp = tiitm001.ctyp
                tiemg001.temp = itemtemplate
                db.insert(ttiemg001,db.retry)
        endselect
        commit.transaction()
endselect


Ajesh 5th October 2017 03:27

Also you could use rcd store and copy functions with the help of db.bind ..That also.works..

pralash 5th October 2017 08:55

Thanks for your guidance...
Here I know tiitm001.item is a field..
But please let me about item.f and :item.t arguments

Thanks,
Pralash

mark_h 5th October 2017 13:56

Those are form fields on the session I pulled a snippet of code from. So the user could enter a range of parts. If I wanted to I could replace them with " " and "ZZZZZZZZ" (or use actual item range).


All times are GMT +2. The time now is 07:39.


vB.Sponsors
©2001-2017 - Baanboard.com - Baanforums.com