Sqlquery: create new table in main csdb

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Sqlquery: create new table in main csdb

Post by htuser »

Dear Cspro developer team,
I would like to know if it's possible for users to create new table in Csdb using sqlquery. In this event, can we use writecase function to write data in this table?
Now, for each external dictionary, we're obliged to have an external Csdb file... using sqlquery to create new table in Csdb will eliminate the need for severals Csdb files...

Thanks in advance for your support!
G.VOLNY, a CSProuser from Haiti, since 2004
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Sqlquery: create new table in main csdb

Post by Gregory Martin »

You can execute any valid SQLite statement using the SqlQuery function, so you could do something like "CREATE TABLE..." You won't be able to use WriteCase with this file though, as that only works with .csdb files described by CSPro dictionaries.

At one point we thought about allowing the data for multiple dictionaries to be stored in a single .csdb file but we decided against that. That is the approach that you really would have wanted.
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Sqlquery: create new table in main csdb

Post by htuser »

Hi Greg,
Thanks for your response!

Unfortunately :oops: , we'll continue to have multiples csdb files ... But, good news if we can create new table in any csdb file.
Right now, i'll try to create a new table and use insert into to transfer some items to this table.
Since sqlquery can't return string value, i'm still very limited now...

Hopefully :D , you informed that will change in the future with a sqlquery able to query string, items, records!

Best Regards,
G.VOLNY, a CSProuser from Haiti, since 2004
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Sqlquery: create new table in main csdb

Post by josh »

Do this at your own risk. We reserve the right to completely change the format of the csdb file in future releases so there is no guarantee that code that you write to manipulate a csdb file using sql will work in future versions of cspro.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Sqlquery: create new table in main csdb

Post by Gregory Martin »

SqlQuery can return a string value. See the example in the help: "Example - Query on CSPro DB File, Storing Results in List."

You can get the string value returned as the single and only element of the string list.
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Sqlquery: create new table in main csdb

Post by htuser »

Sorry Greg,
I misinterpret your sentence: "95% of the time with SqlQuery, you will want a numeric result, which is why it was designed to return a number."

@ Josh, Do you think it's a better idea to create the new table in the paradata log file?

Best!
G.VOLNY, a CSProuser from Haiti, since 2004
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Sqlquery: create new table in main csdb

Post by josh »

I think it is a better idea to create the new in a separate file that is not a cspro file.
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: Sqlquery: create new table in main csdb

Post by htuser »

Hi Josh,
Having a sqlquery able to extract items, record will cancel the need of creating new table. insert into etc.
Thanks to Greg and the whole Cspro Developer Team, the best existing small team, but smart team, who're implementing this.
In the meantime, what's happen with this code:

Code: Select all

string sqlReq =	maketext ("INSERT INTO identifiantquestionnaire (codetablet, codeutilisateur, numeroquestionnaire)VALUES (%v, %v, %v)",noTablet(),CODE_OPERATEUR,IQ_1_NUMERO_DU_QUESTIONNAIRF); ?
[/i]
Thanks a lot for your incredible support!
G.VOLNY, a CSProuser from Haiti, since 2004
Post Reply