- Check Column Consistency: Ensure that both parts of the EXCEPT query return the same number of columns with the same data types.
- Simplify the Query: Test each part of the query separately in MATLAB to ensure they return the expected results.
- Combine the Queries: If both parts work separately, combine them and ensure the EXCEPT statement is correctly formatted.
Problem using SQL 'except' command in Matlab Datbase Toolbox
조회 수: 7 (최근 30일)
이전 댓글 표시
Here is the Follwing code I use after i sucessfully connect to a database:
if true
% codes
end
sqlquery=['select *'... %line 17
' FROM test.dbo.chem '...
' where substring(type,1,1) in ''B'''...
' and substring(num,1,6) in( ''800'', ''801'', ''802'',''803'')'
'except'...
'select *'...
'FROM test.dbo.chem'...
'where substring(type,1,1) in ''B'''...
'and substring(num,1,6) in ''800'''...
' order by heatno desc' ];...
curs = exec(conn,sqlquery)'...
curs = fetch(curs)'...
close(curs)
WHEN I RUN THE CODE INBETWEEN THE PARENTHESES BY ITSELF I CAN SUCESSFULLY QUERY THE DATABSE IN A SCRIPT FILE.
HOWEVER WHEN I RUN THE QUERY WITH THE SECTION OF CODE INBETWEEN THE @ SYMBOLS IN CONJUNCTION WITH EVERYTHIGN ELSE (USING AN EXCEPT COMMAND) I GET THE FOLLOWING ERROR:
Error using Collect_tischem_QUAL (line 17) Error using vertcat Dimensions of matrices being concatenated are not consistent.
when done in microsoft sql server management studio the sql part of the code works
when querying just the specific numbers in matlab the code works (using database toolbox)
when querying the specific numbers in matlab with the except command it does not work
any suggestions?
-Pat
댓글 수: 0
답변 (1개)
Piyush Kumar
2024년 11월 28일
Hi,
The error message suggests that there is a problem with the dimensions of the matrices being concatenated. This can happen if the two queries in the EXCEPT statement return different numbers of columns or if there are differences in the data types of the columns.
Try the following troubleshooting steps -
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Database Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!