The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Creating temporary table via dbImport
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Karsten8

Germany
26 Posts

Posted - 05/09/2023 :  03:04:44 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release: 2022b 9.9.5.171
Operating System: Windows Server 2012

Dear Origin-team,

I use dbImport to get data from SQL database. This works without problems. But now I have to create a temporary table at the database before I import the data. Thus I know that the server connection is ok, the SQL-import works and if I test the SQL-sequence to create the temporary table directly on the server software he creates the table without problems.


This sequence I want to use:
string SPECTRALtemp$="CREATE TABLE ##temp_spectral_data (wavelength int, intensity int)";
dbEdit change conn:=dbSource$ sql:=SPECTRALtemp$;
dbImport;

The following error message occurs:
(800a0e78) ADODB.Recordset: Der Vorgang ist für ein geschlossenes Objekt nicht zugelassen. C:\Windows\HELP\ADO270.CHM
... The process is not allowed for a closed object.

From web search I found that a closed connection could be a problem but I do not see the point why or where this should occur.

Thanks for your help and best regards,
Karsten8.

cpyang

USA
1406 Posts

Posted - 05/09/2023 :  10:40:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I tried in SQLite and it complained about the two ##, so I did


string SPECTRALtemp$="CREATE TABLE temp_spectral_data (wavelength int, intensity int)";
dbEdit change conn:=dbSource$ sql:=SPECTRALtemp$;
dbImport;


and I see the temp_spectral_data table created.

BTW, we improved the db support in LT in 2023b, so code can look cleaner where error code can return, so the above will look like


wks.db.conn$="Driver={SQLite3 ODBC Driver};Database=C:\Users\dev\Downloads\hawaii.sqlite";
wks.db.sql$="SELECT name FROM sqlite_master WHERE type='table' AND name='temp_spectral_data'";
string strErr$;
if(wks.db.test(1, strErr$) != 1) {
	//strErr$=;
	type "need to add table";
	wks.db.sql$="CREATE TABLE temp_spectral_data (wavelength int, intensity int)";
	wks.db.run();
}
else
	type "table existed already";


Go to Top of Page

Karsten8

Germany
26 Posts

Posted - 05/16/2023 :  01:36:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear Cpyang,

thanks for your answer. The ## are needed to generate a temporary table and no permanent table.
I switched to python and via SQLalchemy I could generate a ##temporary table without problems.
Perhaps the ADODB driver has problems with ##temporary tables.

This topic can be closed.

Best regards,
Karsten8.
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000