The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Problem with connection to database
Replies: 3   Last Post: Jul 27, 2013 11:31 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Davide Zoccatelli

Posts: 1
Registered: 7/24/13
Problem with connection to database
Posted: Jul 24, 2013 11:36 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I need to connect to the database both from the main program and from functions. After fetching lots of data (200k records) from the database in the main program, the function is not able to connect and get data anymore. I tried to close the connection or the cursor but it's still not working.

This is the code with comments describing where the connection doesn't work anymore:

function FTestConn( )
conn1 = database('DBname', 'Name', 'psw');

And the main program:

conn1 = database('DBname', 'Name', 'psw');
isconnection(conn1) %this connection works
FTestConn() %this connection works

%fetching some data from the database
curs1 = exec(conn1, 'select min(id) from table1');
curs1 = fetch(curs1);
T =;

%The connection in the function still works

%Fetching A LOT of data from the table
curs1 = exec(conn1, 'select distinct id from table1'); %about 200000 records
curs1 = fetch(curs1);
ID =;
isconnection(conn1) %the connection still works

%The function cannot connect to the database anymore
FTestConn() %result = 0, no connection.

Any idea on what I could try?

Thank you

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.