• <GetStart>
  • CSPro User's Guide
    • The CSPro System
    • Data Dictionary Module
    • The CSPro Language
    • Data Entry Module
    • Batch Editing Applications
    • Tabulation Applications
    • Data Sources
    • CSPro Statements and Functions
    • Templated Reporting System
    • HTML and JavaScript Integration
    • Action Invoker
      • Overview
      • Execution Environments
      • Security and Formatting Options
      • Base Actions
      • Application Namespace
      • Clipboard Namespace
      • Data Namespace
      • Dictionary Namespace
      • File Namespace
      • Hash Namespace
      • Localhost Namespace
      • Logic Namespace
      • Message Namespace
      • Path Namespace
      • Settings Namespace
      • Sqlite Namespace
        • Sqlite Action Invoker Namespace
        • Sqlite.close Action
        • Sqlite.exec Action
        • Sqlite.open Action
        • Sqlite.rekey Action
        • SQLite Callback Functions
        • Sqlite Action Examples: Data Sources
        • Sqlite Action Examples: Paradata
      • System Namespace
      • UI Namespace
    • Appendix
  • <CSEntry>
  • <CSBatch>
  • <CSTab>
  • <DataViewer>
  • <TextView>
  • <TblView>
  • <CSFreq>
  • <CSDeploy>
  • <CSPack>
  • <CSDiff>
  • <CSConcat>
  • <Excel2CSPro>
  • <CSExport>
  • <CSIndex>
  • <CSReFmt>
  • <CSSort>
  • <ParadataConcat>
  • <ParadataViewer>
  • <CSCode>
  • <CSDocument>
  • <CSView>
  • <CSWeb>

Sqlite.close Action

Format
CS.Sqlite.close(db := ...)
ArgumentDescriptionTypes / Required
dbThe database ID returned by Sqlite.open.number
required
Description
The Sqlite.close action closes a SQLite database previously opened by Sqlite.open. Only files opened using path are closed, so if the database was opened using name, it is not actually closed, as data source and paradata resources may still be in use by other parts of CSPro.
Further information about closing databases is available on the SQLite website: sqlite3_close.
Return Value
The action returns undefined.
Exceptions
The action throws an exception if any of its arguments are not specified in a valid form, or if:
  • The database ID is not valid.
  • The database cannot be closed.
Example (CSPro Logic)
// example data available at: https://www.csprousers.org/resources/help/census2020.db

// open the SQLite database: census2020.db
numeric dbCensus2020 = tonumber(CS.Sqlite.open(path := "census2020.db"));

// quit if there was an error opening the database
if dbCensus2020 = default then
   
exit;
endif;

// query the database...

// string scalar: result is California
string largestState =
   
CS.Sqlite.exec(db := dbCensus2020,
                   
sql := "SELECT `name` FROM `census2020` ORDER BY `resident_pop` DESC LIMIT 1;");

// numeric scalar: result is 15920696
numeric populationStatesBeginningWithA = tonumber(
   
CS.Sqlite.exec(db := dbCensus2020,
                   
sql := "SELECT SUM(`resident_pop`) FROM `census2020` WHERE `name` LIKE 'A%';"));

// scalar array: result is California, District of Columbia, Georgia, Pennsylvania, Virginia, West Virginia
List string statesEndingInIa;
statesEndingInIa.
updateValueFromJson(
   
CS.Sqlite.exec(db := dbCensus2020,
                   
sql := "SELECT `name` FROM `census2020` WHERE `name` LIKE '%ia' ORDER BY `name`;",
                   
rowFormat := "scalarArray"));

// close the database
CS.Sqlite.close(db := dbCensus2020);
See also: Sqlite Action Invoker Namespace, Sqlite.open Action