2017-05-07 3 views
0

이제 "SQL-Data"를 시트로 가져 오는 방법을 알고 있습니다.
하지만 "SQL-Data"를 기존 시트에 추가 할 수는 없습니다. 이는 시간이 지남에 따라 커질 것입니다.OriginLab Pro의 시트에 추가/가져 오기 방법

//Pseudo Code 
1. maxID <-- getMaxValueOutOfColumnId() 
2. import via SQL --> "SELECT * FROM table WHERE ID > maxID" 
3. append the result set as rows to the sheet maxID came from. 

가져 오기에 대한 자습서를 찾았지만 SQL-Data를 추가하지 않았습니다.

답변

0

미래의 방문자를 위해 나는 생각 해낸 해결책을 게시합니다.

// In general 
1. have a book with 2 sheets named test_data and data_import 
2. put a click button on sheet data_import 
3. open the buttons preferences and activate tab "programming" 
4. write yourself some LabTalk code in the small code-field 

/* 1. Step */ 
range ra = "test_data"!col(A); 
int max_id = max(ra); 

/* 2. Step */ 
string strSQL$="SELECT * FROM table WHERE id > ($(max_id))"; 
string strConn$="<CONNECTION STRING GOES HERE>"; 
dbEdit change conn:=strConn$ sql:=strSQL$; 
dbImport; 
dbEdit remove; 

/* 3. Step */ 
range ra = "test_data"!;   // sheet to extend with imported data 
range rb = "data_import"!;  // helper sheet as cache 
wrcopy iw:=rb c1:=1 r1:=1   // append cached data on sheet test_data 
     ow:=ra dc1:=1 dr1:=ra.maxRows+1; 

/* 4. Step - cleaning up */ 
int cols = rb.ncols;    // number of columns 
for(int ii = cols; ii > 0; ii -= 1) { 
    delete wcol($(ii));   // delete all columns form data_import 
}; 
for(int ii = cols; ii > 0; ii -= 1) { 
    rb.addCol();     // append new columns 
};