Filter löschen
Filter löschen

calling sql database from GUI

2 Ansichten (letzte 30 Tage)
Christof
Christof am 24 Jun. 2011
[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?
  1 Kommentar
Kaustubha Govind
Kaustubha Govind am 24 Jun. 2011
What happens when you set a breakpoint in your GUI code in the button callback and step through the code? It is likely that the data in getting creating in the workspace local to the GUI callback function. Use the function ASSIGNIN to send the data to the base workspace.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Anathea Pepperl
Anathea Pepperl am 24 Jun. 2011
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.

Weitere Antworten (1)

Christof
Christof am 29 Jun. 2011
thanks for your help

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Tags

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by