MATLAB: Calling sql database from GUI

guiMATLAB

[EDIT: 20110625 11:12 CDT – reformat – WDR]
Hi, I tried using the following script in a GUI
global sql_call;
global global_flags;
global global_data;
global global_bdate;
global global_edate;
conn=database('fixedincome', '', '');
ping(conn)
flags=global_flags;
bdate=global_bdate;
edate=global_edate;
flags=find(flags==1);
n=length(flags);
sql_call = strcat('SELECT * FROM fixedincome.instrument', num2str(flags(1)));
for i = 2 : n
c=flags(i);
add_txt = strcat(' INNER JOIN fixedincome.instrument', num2str(c));
add_cond = strcat(' ON instrument', num2str(flags(1)),'.time = instrument', num2str(c),'.time');
sql_call=strcat(sql_call,add_txt,add_cond);
end
if ~isempty(global_bdate) | ~isempty(global_edate);
add_where = strcat(' where ');
if ~isempty(global_bdate);
add_where=strcat(add_where, ' TIME > ', ''', global_bdate,''');
if ~isempty(global_edate);
add_where=strcat(add_where, 'AND');
end;end;
if ~isempty(global_edate);
add_where=strcat(add_where, 'TIME < ',''', global_edate,''');
end;
sql_call= strcat(sql_call, add_where);
end;
curs = exec(conn, sql_call);
data_item = fetch(curs);
data = data_item.data;
global_data = data;
However, it does not load the data. If I execute the script as a separate script manually, it works. If I call the script from the GUI function assigned to a button, it does not load the data. Any ideas how I can work around that?

Best Answer

You need to pass the data. You can use ASSIGNIN as the comment above suggested, or save the data in the handles structure and use the GUIDATA function to update the data.