HELP PLEASE! How to insert arrays 1x24 in columns of a database sql?

조회 수: 3 (최근 30일)
Hello guys, how are you? (I speak spanish)
I need inserts 4 arrays 1x24 at the same time in a database but have an error
%% INSERT TO DATABASE SQL
columns = {'FechaHora,Presion,Volumen,Energia,id_Distribucion,RangoOperacional,Valido'};
dato = {x1,x2,x3,x4,id3,RangoOp,Valido}; %%ARRAYS 1X24 WITH VARIOUS DATA (X1 IS STRING - DATETIME) (X2,3,4 ARE DOUBLES)
insert(conn2,'dbo.Datos',{columns},{dato});
exec(conn2,query2);

답변 (2개)

Guillaume
Guillaume 2020년 3월 20일
Your columns input is completely wrong. It's a cell array with just one cell, a very long char vector. You then wrap that into another cell array when calling insert. Correct syntax should be:
columns = {'FechaHora', 'Presion', 'Volumen', 'Energia', 'id_Distribucion', 'RangoOperacional', 'Valido'};
dato = {x1,x2,x3,x4,id3,RangoOp,Valido}; %%ARRAYS 1X24 WITH VARIOUS DATA (X1 IS STRING - DATETIME) (X2,3,4 ARE DOUBLES)
insert(conn2,'dbo.Datos', columns, dato);
exec(conn2,query2);

Andrés Felipe Fontalvo Mejia
Andrés Felipe Fontalvo Mejia 2020년 3월 20일
Hello Guillaume, see this error please (Already changed the error of columns)
can you help me? I need you, i'm learning matlab and sql
Is a new error

카테고리

Help CenterFile Exchange에서 Database Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by