Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Problem with import from databases - Array

pawelwalczpawelwalcz Posts: 2Member
Hi everyone, i have a problem with i can't beat down. Exacly: i want to connect co my database in embedded matlab function by the code:

-------------------------
function TF = polaczenie_funkcja (ID)

eml.extrinsic('database')
conn=database('connection','user','password');
eml.extrinsic('exec')
curs5 = exec(conn, 'select zaklocenia from zbiornik_praca where ID_Zbiornik=1');
eml.extrinsic('fetch')
eml.extrinsic('setdbprefs')
setdbprefs('DataReturnFormat','numeric')
curs5=fetch(curs5);
m=curs5.data(1)
TF = strcmp('No data',m);
-------------------------------

I have a error in line with m=curs5.data(1). ("Attempt to extract field 'data' from 'mxArray'."). Maybe You can help? :)

Greetings,
pawelwalcz

Comments

  • pawelwalczpawelwalcz Posts: 2Member
    I already solved it, checking is there a available rows by using numrows=rows(curs) and eml.extinsic to all functions insted of using sctrcmp(). But now i have a new problem when i try to run it in rapid acceleration mode (in normal mode it runs properly) it gives me a error "failed to eliminate a use of the MATLAB function 'database'. For non-simulation builds, uses of unsupported MATLAB functions are eliminated if they do not affect function outputs."

    Any ideas??

    here is my new code:

    [code]
    function numrows = polaczenie_funkcja (ID)
    eml.extrinsic('database')
    conn=database('polaczenie','user','password');
    eml.extrinsic('exec')
    eml.extrinsic('num2str');
    curs = exec(conn, ['select* from zbiornik_praca where ID_Zbiornik= ' num2str(ID) ' ']);
    eml.extrinsic('fetch')
    curs=fetch(curs);
    eml.extrinsic('rows')
    numrows=4;
    numrows=rows(curs)
    end
    [/code]
Sign In or Register to comment.