calling sql database from GUI

4 visualizaciones (últimos 30 días)
Christof
Christof el 24 de Jun. de 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 comentario
Kaustubha Govind
Kaustubha Govind el 24 de Jun. de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Anathea Pepperl
Anathea Pepperl el 24 de Jun. de 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.

Más respuestas (1)

Christof
Christof el 29 de Jun. de 2011
thanks for your help

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by