Azzera filtri
Azzera filtri

calling sql database from GUI

2 visualizzazioni (ultimi 30 giorni)
Christof
Christof il 24 Giu 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 Commento
Kaustubha Govind
Kaustubha Govind il 24 Giu 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.

Accedi per commentare.

Risposta accettata

Anathea Pepperl
Anathea Pepperl il 24 Giu 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.

Più risposte (1)

Christof
Christof il 29 Giu 2011
thanks for your help

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Tag

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by