<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Oh, maximum sorry! I missed your proposed changes, which btw result
    in the following (non?-)error:<br>
    <br>
    <meta name="qrichtext" content="1">
    <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><!--StartFragment--><span style=" font-family:'Monospace'; font-size:9pt; color:#aa0000;">Error: not an error Unable to execute multiple statements at a time</span><!--EndFragment--></p>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
    <style type="text/css">
p, li { white-space: pre-wrap; }
</style><br>
    Cheers,<br>
    Thomas<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 24.08.2016 16:03, David Greaves
      wrote:<br>
    </div>
    <blockquote
      cite="mid:14b0ec4e-13f6-b599-c23d-287658100959@jolla.com"
      type="cite">Did you try?
      <br>
      <br>
      I combined both the
      <br>
      PRAGMA foreign_keys = ON;
      <br>
      and
      <br>
      PRAGMA foreign_keys;
      <br>
      <br>
      into one transaction.
      <br>
      <br>
      David
      <br>
      <br>
      On 24/08/16 14:56, TE wrote:
      <br>
      <blockquote type="cite">Sorry for being ambiguous. It returns:
        {"foreign_keys":0}
        <br>
        <br>
        <br>
        On 24.08.2016 15:53, David Greaves wrote:
        <br>
        <blockquote type="cite">What does
          <br>
          <br>
           function queryForeignKeysEnabled()
          <br>
           {
          <br>
               instance().transaction(function(tx) {
          <br>
                   var rs = tx.executeSql("PRAGMA foreign_keys = ON;
          PRAGMA
          <br>
          foreign_keys;");
          <br>
                   console.log(JSON.stringify(rs.rows.item(0)))
          <br>
               });
          <br>
           }
          <br>
          <br>
          return?
          <br>
          <br>
          David
          <br>
          <br>
          On 24/08/16 13:45, TE wrote:
          <br>
          <blockquote type="cite">Hello Matthias,
            <br>
            <br>
            thanks for the quick reply! I access the database from the
            QML/JS
            <br>
            domain. To open a connection I use the following function:
            <br>
            <br>
            function instance()
            <br>
            {
            <br>
                var db = Storage.LocalStorage.openDatabaseSync("Db", "",
            "Nodes",
            <br>
            5000000);  /* DB Size: 5MB */
            <br>
                db.transaction(function(tx) {
            <br>
                    tx.executeSql("PRAGMA foreign_keys = ON;");
            <br>
                });
            <br>
                return db
            <br>
            }
            <br>
            <br>
            The following test function
            <br>
            <br>
            function queryForeignKeysEnabled()
            <br>
            {
            <br>
                instance().transaction(function(tx) {
            <br>
                    var rs = tx.executeSql("PRAGMA foreign_keys;");
            <br>
                    console.log(JSON.stringify(rs.rows.item(0)))
            <br>
                });
            <br>
            }
            <br>
            <br>
            returns
            <br>
            <br>
            {"foreign_keys":0}.
            <br>
            <br>
            Can you map this implementation to your C++ code and tell
            the
            <br>
            difference?
            <br>
            <br>
            Cheers,
            <br>
            Thomas
            <br>
            <br>
            <br>
            <br>
            <br>
            On 24.08.2016 13:54, Matthias Fehring wrote:
            <br>
            <blockquote type="cite">Hello Thomas,
              <br>
              <br>
              for me foreign key support is working. Directly after
              establishing the
              <br>
              connection to the SQLite database (QSqlDatabase::open()) I
              use
              <br>
              QSqlQuery to
              <br>
              execute "PRAGMA foreign_keys = ON".
              <br>
              <br>
              I think you have to do it every time you open a closed
              database, so I
              <br>
              implemented it in my database connection methods that it
              is executed
              <br>
              if the
              <br>
              database connection was closed before.
              <br>
              <br>
              Best greetings
              <br>
              Matthias
              <br>
              <br>
              <br>
              Am Mittwoch, 24. August 2016, 12:39:04 CEST schrieb TE:
              <br>
              <blockquote type="cite">Hello fellow devs,
                <br>
                <br>
                I have two SQLite tables. The second table references a
                key from the
                <br>
                first table as foreign key. Now when I delete a row in
                the first
                <br>
                table I
                <br>
                want all rows from the second table referencing the
                deleted key to be
                <br>
                deleted as well. For this the action ON DELETE CASCADE
                seems to be
                <br>
                appropriate. Unfortunately this doesn't work and the
                corresponding
                <br>
                rows
                <br>
                in the second table are *not* deleted.
                <br>
                <br>
                Here are the table definitions:
                <br>
                <br>
                First table:
                <br>
                CREATE TABLE IF NOT EXISTS NodeMetaData (id INTEGER
                PRIMARY KEY,
                <br>
                parentId INTEGER);
                <br>
                <br>
                Second table:
                <br>
                CREATE TABLE IF NOT EXISTS NodeConcreteData (refId
                INTEGER NOT NULL,
                <br>
                FOREIGN KEY(refId) REFERENCES NodeMetaData(id) ON DELETE
                CASCADE);
                <br>
                <br>
                In the sqlite docs, it is mentioned that foreign key
                support has to be
                <br>
                acitvated. So I tried tx.executeSql("PRAGMA foreign_keys
                = ON;"). But
                <br>
                the query tx.executeSql("PRAGMA foreign_keys;") returns
                0.
                <br>
                <br>
                When I recreate the scenario in an interactive SQLite
                session, the
                <br>
                above
                <br>
                works (PRAGMA foreign_keys = ON has to be executed).
                <br>
                <br>
                Any ideas?
                <br>
                Is the SFOS Qt lib compiled with foreign key support?
                <br>
                What am I missing?
                <br>
                <br>
                Many thanks in advance!
                <br>
                Thomas
                <br>
                _______________________________________________
                <br>
                SailfishOS.org Devel mailing list
                <br>
                To unsubscribe, please send a mail to
                <br>
                <a class="moz-txt-link-abbreviated" href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a>
                <br>
              </blockquote>
              <br>
              <br>
              <br>
              _______________________________________________
              <br>
              SailfishOS.org Devel mailing list
              <br>
              To unsubscribe, please send a mail to
              <br>
              <a class="moz-txt-link-abbreviated" href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a>
              <br>
            </blockquote>
            <br>
            <br>
            <br>
            _______________________________________________
            <br>
            SailfishOS.org Devel mailing list
            <br>
            To unsubscribe, please send a mail to
            <br>
            <a class="moz-txt-link-abbreviated" href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a>
            <br>
            <br>
          </blockquote>
          <br>
          _______________________________________________
          <br>
          SailfishOS.org Devel mailing list
          <br>
          To unsubscribe, please send a mail to
          <br>
          <a class="moz-txt-link-abbreviated" href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a>
          <br>
        </blockquote>
        <br>
        _______________________________________________
        <br>
        SailfishOS.org Devel mailing list
        <br>
        To unsubscribe, please send a mail to
        <a class="moz-txt-link-abbreviated" href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a>
        <br>
        <br>
      </blockquote>
      <br>
      _______________________________________________
      <br>
      SailfishOS.org Devel mailing list
      <br>
      To unsubscribe, please send a mail to
      <a class="moz-txt-link-abbreviated" href="mailto:devel-unsubscribe@lists.sailfishos.org">devel-unsubscribe@lists.sailfishos.org</a>
      <br>
    </blockquote>
    <br>
  </body>
</html>