AlaSQL / alasql

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.
http://alasql.org
MIT License
7.04k stars 659 forks source link

Records in table are always insert empty in the table #1484

Open amiagarw opened 2 years ago

amiagarw commented 2 years ago

Hi We are planing to upgrade the alssql version from .2 to 1.7.3. We are using the browser version of alasql and download from https://cdn.jsdelivr.net/npm/alasql@1.7( Got this link from official site (https://github.com/AlaSQL/alasql) and include in the our webpage. But with latest records in table are always insert empty in the table.

We are trying to create the table 'BCPartners' and then insert the data into JSON formate. We can see the records set but each column has blank value.This is a blocker for us so need help ASAP Below are the sample code and more details ----------- Sample HTML page ---------------------

<html>

<head></head>

<body>
    <script language="javascript" src="scripts/3rdParty/alasql.min.js"></script>
    <script language="javascript" src="test.js"></script>
    "CREATE TABLE IF NOT EXISTS [BCPartners] ( RecordNum INTEGER PRIMARY KEY AUTOINCREMENT , [TABLE_NAME] TEXT DEFAULT \"\", [BC] TEXT DEFAULT \"\")" =
    <script>
        var data = [

             {TABLE_NAME: "S_CON_ADDR", BC: "Pharma Address Inter Table - CE,CUT Address for Ac…,Pharma Pick Address,CUT Address Inter Table - CE"},
             {TABLE_NAME: "S_PROD_INT", BC: "Pharma Internal Product,Internal Product,FINS Security,Pharma Sample Lot for Picklist"},
            {TABLE_NAME: "S_LST_OF_VAL", BC: "List Of Values,PickList Generic,List Of Values Chi… Of Values Dynamic,PickList Hierarchical Sub-Area"},
                   {TABLE_NAME: "S_EMP_PRDINT", BC: "Pharma Personal Products List,Pharma Personal Samp…Items List,Pharma Personal Promotional Items List"},
             {TABLE_NAME: "S_ADDR_PER", BC: "CUT Address,CUT Address - CE,Pharma Address"},
             {TABLE_NAME: "S_LIT", BC: "Admin Sales Tool,Admin Sales Tool Thumbnail"},
            {TABLE_NAME: "S_EVT_ACT", BC: "Pharma Professional Call - Mobile,Pharma Account Call,Pharma Professional Call,Action"},
             {TABLE_NAME: "S_MSG_PLAN", BC: "LS Messaging Plans BC,LS Admin Messaging Plans BC"},
             {TABLE_NAME: "S_ACT_PRDINT", BC: "LS Pharma Call Sample Dropped Rollup,LS Pharma Pro…motional Items Dropped,Pharma Call Sample Dropped"},

          ]

          function showResult(x){
              document.getElementById('result').textContent = JSON.stringify(x,  null, '\t');
          }

          CreateDB();
    </script>

    <xmp id="result"></xmp>
</body>

</html>

---------- Sample JS (test.js) code ---------

function CreateDB() {
    debugger
    var inmemDB = new alasql.Database("alasql_db");
    window._memDB = inmemDB;
    var
        query = "CREATE TABLE IF NOT EXISTS [BCPartners] ( RecordNum INTEGER PRIMARY KEY
    AUTOINCREMENT, [TABLE_NAME] TEXT DEFAULT\ "\", [BC] TEXT DEFAULT \"\")"
    inmemDB.exec(query);;
    inmemDB.exec("insert into [BCPartners] select * from ?
            ",[data]);
}
harish343 commented 2 years ago

Can I work on this issue

mathiasrw commented 2 years ago

@harish343 Absolutely

harish343 commented 2 years ago

how can I find this file scripts/3rdParty/alasql.min.js

mathiasrw commented 2 years ago

@harish343 Use https://cdn.jsdelivr.net/npm/alasql@2.1.4/dist/alasql.js instead so you dont get the minified version.

@amiagarw what is in the test.js file?

harish343 commented 2 years ago

plz provide documentation and which database I can use with alasql

mathiasrw commented 2 years ago

alasql is the database

harish343 commented 2 years ago

how can I check records table