ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
#1
|
|||
|
|||
Problems with import of data from a database
Hello,
i try to import data from a database to my model. I do this every day in the simulation and use the following program code: int day = (time() / 1440 + 1); string ODBCname = "Flexsim Database"; string query = concat("SELECT Ma_BrukteMonster.* FROM Ma_Brukte WHERE Ma_Brukte.Dag =",numtostring(day)); dbopen(ODBCname,query,0); dbviewtable(); dbclose(); The problem is that it doesn't run stabile. Sometimes I get the table with the data and sometimes not. I think the problem is that there are no data for some days and that results in an empty table in Flexsim and that is something Flexsim doesn't like. But actually I have no real idea what causes this failure. Does someone knows a possible cause for it? Thanks in advance, Matthias |
#2
|
||||
|
||||
Mattias,
The problem is in the dbopen() command. It doesn't work correctly when the query returns an empty table. This is something we'll need to look into. What I've done in the past to get around that is to make sure that the initial query always retrieves something, even if it's not data that you actually plan to use. I typically use a simple SELECT statement on a small table in the database. Then, once the dbopen() command has succeeded, you can use the dbsqlquery() command to call the query that you really want to use. This command does not have the same problem with empty sets that dbopen() does. |
The Following User Says Thank You to AJ Bobo For This Useful Post: | ||
Matthias Hofmann (09-29-2008) |
Thread | Thread Starter | Forum | Replies | Last Post |
Excel Data Import | Sung Kim | Q&A | 2 | 07-16-2010 10:41 AM |
Sample Access Database | Brandon Peterson | Tips and Tricks | 1 | 07-09-2008 12:15 PM |
Problems with Excel-Import | tobias.biemueller | Q&A | 1 | 06-18-2008 06:17 AM |
Problems with wrl file | Steven Hamoen | Q&A | 1 | 01-25-2008 06:00 AM |
Graphics problems | Yaghm | Installation | 5 | 09-28-2007 02:12 PM |