Is it possible in a codeunit (or processing only report) in Navision, to create a table via code ?
I could create a temp table and store my data in there, but that's not what I want.
In Sql there's the Create Table statement, is there something like that in CAL ?
I don't think it is possible, please proove me wrong.
Debugging is twice as hard as writing code. Therefore if you write the code as cleverly as possible you are by definition not smart enough to debug it.
0
Comments
TempTable.RESET;
TempTable.DELETEALL;
REPEAT
....
....
TempTable.INSERT;
UNTIL ...
And then you have your temporary records in a temporary table that will disappear after the codeunit runs, all without having to instantiate a new table etc.... I guess one of the restrictions for not allowing dynamic tables is due to licensing errors, unlike any other database in the world, Navision charges for tables.
* NOTE * : IF YOU DO NOT SET THE TEMPORARY FLAG YOU WILL WIPE OUT YOUR EXISTING TABLE WHEN YOU DO DELETEALL!!!
I hope this helps, have a great day!
No one loves you like the one who created you...
RIS Plus, LLC
And it is also possible to create extra fields in existing tables by inserting records in table Fields. But the problem was that you couldn't used them. Now with the recordrefrence and fieldreference I think it is possible to use them.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Could you explain this a bit further? Do you mean if you insert a record with 6 columns into a record variable based on a table with only 5 columns, that a 6th column will be created?
Microsoft Dynamics NAV Developer
That's just bloody cool! *hehe*
Microsoft Dynamics NAV Developer
RIS Plus, LLC
You need to create a new record in table "Field". This is a system table that shows the fields in the DB. And it is possible to delete or create fields. So if you create a field in this table, later you have it in your table.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
My method would be, you create the table you'd want to use in dev environment, then export it as txt.
You can run any exe with parameters from C/AL, or you can use the powershell method. You can store the txt in a text constant in your C/AL code, or even in a table's blob field.
Then you delete your exported table from dev environment.
Your code should do the following -> Export your string into TXT -> Call FinSQL with parameters pointing to your created txt, import, then compile.
If you only need an SQL table, you just simply run your SQL commands on the server from C/AL code just like in C# or any other language.