필터 지우기
필터 지우기

Write "BIT" data type to existing PostgreSQL table from Matlab

조회 수: 1 (최근 30일)
Anastasia Rybcova
Anastasia Rybcova 2021년 2월 20일
댓글: Anastasia Rybcova 2021년 3월 10일
Hi everyone,
I created a table in PostgreSQL that has a data column with the BIT type:
create table parameters (
row_num serial,
value_parameter bit(1),
primary key (row_num);
);
After that I successfully connected to the PostgreSQL from MATLAB, and tried to add a record to the table:
conn = postgresql(username,password,'DatabaseName',"postgres",'PortNumber',5432);
my_table = table("0", 'VariableNames', 'value_parameter');
sqlwrite(conn, 'public.parameters', my_table);
As a result I get the error:
"The VariableNames property is a cell array of character vectors. To assign multiple variable names, specify nonempty names in a string array or a
cell array of character vectors".
I have tried many ways to write the request but invariably get the above error. How to correctly write such a request, or where can I read about it?
Thank you in advance

답변 (1개)

Vimal Rathod
Vimal Rathod 2021년 2월 22일
Hi,
Try using the following code.
my_table = table("0", 'VariableNames', {'value_parameter'});
You were getting the error because you didn't put the variable names in the cell array format.
Refer to the following link to see another example with the same syntax

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by