Hiba_t
7th April 2008, 12:37
Hi all,
I need to insert a record to a table programmatically. The table might not exist in the database and that's why I need to do the insert dynamically.
I have used dynamic sql before, but I didn't succeed in using it to insert a record to a table.
I searched the board but didn't find the solution.
Can anyone guide me how to do such a thing?
Thanks in advance,
Hiba
günther
7th April 2008, 14:46
The table might not exist in the database...
That's not possible for baan. You must create a table before you can use it.
There is a function db.create.table(), but I haven't tried it yet.
Günther
Hiba_t
8th April 2008, 08:27
It seems that I didn't make myself clear enough.
My program will run on several baan servers and some of these servers has this table in this their database and some don't have it. Only when this table exists I need to insert data to it. When it doesn't exist the program will do other actions and it won't create the table.
That's why I need to do the insert dynamically.
- Hiba
NPRao
8th April 2008, 09:00
My program will run on several baan servers and some of these servers has this table in this their database and some don't have it. Only when this table exists I need to insert data to it. When it doesn't exist the program will do other actions and it won't create the table.
Refer to the dynamic SQL example - Dynamic SQL (http://www.baanboard.com/programmers_manual_baanerp_help_functions_database_handling_dynamic_sql) and also the thread - Check Table in Company (http://www.baanboard.com/baanboard/showthread.php?t=29844&highlight=sql.fetch)
Add another case section for sql.fetch() for 506 or ENOTABLE and write your other action code there.
Hiba_t
8th April 2008, 09:04
Can you please give me a simple example on how to write a dynamic sql to insert data into a table?
This is the part that I have a problem with.
NPRao
8th April 2008, 09:12
Hiba,
I'm not in office now. Here are 2 threads for reference to start with -
sql.parse and make a update??? (http://www.baanboard.com/baanboard/showthread.php?t=46355&highlight=sql.parse)
Advanced programming. (http://www.baanboard.com/baanboard/showthread.php?t=6710&highlight=sql.parse)
Hiba_t
8th April 2008, 10:30
Thanks a lot NPRao...
I guess I missed these threads in my search