Problem with import from databases - Array - Programmers Heaven

Howdy, Stranger!

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

Categories

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.