ATTENTION

This 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

Go Back   FlexSim Community Forum > FlexSim Software > Q&A
Downloads

Q&A Using Flexsim and building models

  #1  
Old 09-26-2008
Matthias Hofmann Matthias Hofmann is offline
Flexsim User
 
Join Date: Jun 2008
Posts: 15
Downloads: 1
Uploads: 0
Thanks: 11
Thanked 0 Times in 0 Posts
Rep Power: 146
Matthias Hofmann is on a distinguished road
Default 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  
Old 09-26-2008
AJ Bobo's Avatar
AJ Bobo AJ Bobo is offline
Flexsim Senior Developer
 
Join Date: Jul 2007
Posts: 108
Downloads: 8
Uploads: 0
Thanks: 23
Thanked 89 Times in 41 Posts
Rep Power: 221
AJ Bobo is a jewel in the roughAJ Bobo is a jewel in the roughAJ Bobo is a jewel in the roughAJ Bobo is a jewel in the rough
Default

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


All times are GMT -6.
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Copyright 1993-2018 FlexSim Software Products, Inc.