Update query to append zeroes into blob field with SQLiteStudio Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Updating records older than n minutescould not convert BLOB to Buffer - Sqlite3How to update records that satisfies a condition with incrementing number in SQLite3?iPhone: sqlite3 blob field not unserialising properlysql for a fuzzy search querySQL query to update multiple tables with same column nameNode return image stored in sqlite blobSqlite3 inserting BLOBs instead of textAppending Pandas dataframes with time to SQLite3 databases & backHow to update a SQLite Blob column

Can gravitational waves pass through a black hole?

Why does BitLocker not use RSA?

How do I deal with an erroneously large refund?

What is the ongoing value of the Kanban board to the developers as opposed to management

Are Flameskulls resistant to magical piercing damage?

How to ask rejected full-time candidates to apply to teach individual courses?

Etymology of 見舞い

Should man-made satellites feature an intelligent inverted "cow catcher"?

Who's this lady in the war room?

Why did Israel vote against lifting the American embargo on Cuba?

Why doesn't the university give past final exams' answers?

Lemmatization Vs Stemming

Why these surprising proportionalities of integrals involving odd zeta values?

Is Bran literally the world's memory?

Can I ask an author to send me his ebook?

"Destructive force" carried by a B-52?

How is an IPA symbol that lacks a name (e.g. ɲ) called?

Is Vivien of the Wilds + Wilderness Reclimation a competitive combo?

Like totally amazing interchangeable sister outfit accessory swapping or whatever

“Since the train was delayed for more than an hour, passengers were given a full refund.” – Why is there no article before “passengers”?

tabularx column has extra padding at right?

Does Prince Arnaud cause someone holding the Princess to lose?

Are bags of holding fireproof?

Why is ArcGIS Pro not symbolizing my entire range of values?



Update query to append zeroes into blob field with SQLiteStudio



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Updating records older than n minutescould not convert BLOB to Buffer - Sqlite3How to update records that satisfies a condition with incrementing number in SQLite3?iPhone: sqlite3 blob field not unserialising properlysql for a fuzzy search querySQL query to update multiple tables with same column nameNode return image stored in sqlite blobSqlite3 inserting BLOBs instead of textAppending Pandas dataframes with time to SQLite3 databases & backHow to update a SQLite Blob column



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I'm trying to append zeroes to a blob field in a sqlite3 db.
What I tried is this:



UPDATE Logs
SET msg_buffer = msg_buffer || zeroblob(1)
WHERE msg_id = 'F0'


As you can see, the field name is "msg_buffer", and what I want is to append byte zero. It seems that the concat operator || doesn't work.
How could I achieve this?










share|improve this question




























    1















    I'm trying to append zeroes to a blob field in a sqlite3 db.
    What I tried is this:



    UPDATE Logs
    SET msg_buffer = msg_buffer || zeroblob(1)
    WHERE msg_id = 'F0'


    As you can see, the field name is "msg_buffer", and what I want is to append byte zero. It seems that the concat operator || doesn't work.
    How could I achieve this?










    share|improve this question
























      1












      1








      1








      I'm trying to append zeroes to a blob field in a sqlite3 db.
      What I tried is this:



      UPDATE Logs
      SET msg_buffer = msg_buffer || zeroblob(1)
      WHERE msg_id = 'F0'


      As you can see, the field name is "msg_buffer", and what I want is to append byte zero. It seems that the concat operator || doesn't work.
      How could I achieve this?










      share|improve this question














      I'm trying to append zeroes to a blob field in a sqlite3 db.
      What I tried is this:



      UPDATE Logs
      SET msg_buffer = msg_buffer || zeroblob(1)
      WHERE msg_id = 'F0'


      As you can see, the field name is "msg_buffer", and what I want is to append byte zero. It seems that the concat operator || doesn't work.
      How could I achieve this?







      sqlite3 sqlitestudio






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 22 at 14:00









      framontbframontb

      314214




      314214






















          2 Answers
          2






          active

          oldest

          votes


















          1














          Reading the doc link posted by Googie (3.2. Affinity Of Expressions), I managed to find the way:



          UPDATE Logs
          SET msg_buffer = CAST(msg_buffer || zeroblob(1) AS blob)
          WHERE msg_id = 'F0'


          The CAST operator can take the expression with the concatenate operator and force the blob affinity.






          share|improve this answer






























            1














            SQLite3 does support datatypes. See https://www.sqlite.org/datatype3.html



            They are not strictly linked with declared type of a column, but rather individual per each cell value. The type is determined by how it was created/modified. For example if you insert 5, it will be INTEGER. If you insert 5.5, it will be REAL. If you insert 'test' it will be TEXT, if you insert zeroblob(1), it will be BLOB and if you insert null, it will be NULL.



            Now, what you are doing is that you're trying to concatenate current value with a BLOB type. If current value is TEXT (or basically if you use || operator, as you do, you are converting any type into a TEXT), it will be concatenated with byte x00, which actually determines the end of a string. In other words, you are adding yet another string terminator, to an already existing one, that the TEXT type has.



            There will be no change on output of this operation. TEXT always ends with byte zero and it is always excluded from the result, as it's a meta character, not the value itself.



            Additional information from http://sqlite.1065341.n5.nabble.com/Append-data-to-a-BLOB-field-td46003.html - appending binary data to BLOB field is not possible. You can modify prealocated blob:




            Append is not possible. But if you preallocate space using
            zeroblob() or similar, you can write to it using the incremental
            blob API:



            http://www.sqlite.org/c3ref/blob_open.html




            Finally, please see accepted answer, as author of the question found an interesting solution.






            share|improve this answer

























            • msg_buffer field is declared as BLOB Data type, and data is inserted with a Python script as sqlite3.Binary(bytearray(...))

              – framontb
              Mar 25 at 8:32







            • 1





              Yes, but the concatenation operator works on strings. See sqlite.org/lang_expr.html - it says The || operator is "concatenate" - it joins together the two strings of its operands. and then also (...) the || concatenation operator which always evaluates to either NULL or a text value. SQLite takes your two binary values, converts them to TEXT, then concatenates and returns TEXT. You can also have a look at this explanation: sqlite.1065341.n5.nabble.com/…

              – Googie
              Mar 26 at 9:31












            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55301281%2fupdate-query-to-append-zeroes-into-blob-field-with-sqlitestudio%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Reading the doc link posted by Googie (3.2. Affinity Of Expressions), I managed to find the way:



            UPDATE Logs
            SET msg_buffer = CAST(msg_buffer || zeroblob(1) AS blob)
            WHERE msg_id = 'F0'


            The CAST operator can take the expression with the concatenate operator and force the blob affinity.






            share|improve this answer



























              1














              Reading the doc link posted by Googie (3.2. Affinity Of Expressions), I managed to find the way:



              UPDATE Logs
              SET msg_buffer = CAST(msg_buffer || zeroblob(1) AS blob)
              WHERE msg_id = 'F0'


              The CAST operator can take the expression with the concatenate operator and force the blob affinity.






              share|improve this answer

























                1












                1








                1







                Reading the doc link posted by Googie (3.2. Affinity Of Expressions), I managed to find the way:



                UPDATE Logs
                SET msg_buffer = CAST(msg_buffer || zeroblob(1) AS blob)
                WHERE msg_id = 'F0'


                The CAST operator can take the expression with the concatenate operator and force the blob affinity.






                share|improve this answer













                Reading the doc link posted by Googie (3.2. Affinity Of Expressions), I managed to find the way:



                UPDATE Logs
                SET msg_buffer = CAST(msg_buffer || zeroblob(1) AS blob)
                WHERE msg_id = 'F0'


                The CAST operator can take the expression with the concatenate operator and force the blob affinity.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 25 at 10:50









                framontbframontb

                314214




                314214























                    1














                    SQLite3 does support datatypes. See https://www.sqlite.org/datatype3.html



                    They are not strictly linked with declared type of a column, but rather individual per each cell value. The type is determined by how it was created/modified. For example if you insert 5, it will be INTEGER. If you insert 5.5, it will be REAL. If you insert 'test' it will be TEXT, if you insert zeroblob(1), it will be BLOB and if you insert null, it will be NULL.



                    Now, what you are doing is that you're trying to concatenate current value with a BLOB type. If current value is TEXT (or basically if you use || operator, as you do, you are converting any type into a TEXT), it will be concatenated with byte x00, which actually determines the end of a string. In other words, you are adding yet another string terminator, to an already existing one, that the TEXT type has.



                    There will be no change on output of this operation. TEXT always ends with byte zero and it is always excluded from the result, as it's a meta character, not the value itself.



                    Additional information from http://sqlite.1065341.n5.nabble.com/Append-data-to-a-BLOB-field-td46003.html - appending binary data to BLOB field is not possible. You can modify prealocated blob:




                    Append is not possible. But if you preallocate space using
                    zeroblob() or similar, you can write to it using the incremental
                    blob API:



                    http://www.sqlite.org/c3ref/blob_open.html




                    Finally, please see accepted answer, as author of the question found an interesting solution.






                    share|improve this answer

























                    • msg_buffer field is declared as BLOB Data type, and data is inserted with a Python script as sqlite3.Binary(bytearray(...))

                      – framontb
                      Mar 25 at 8:32







                    • 1





                      Yes, but the concatenation operator works on strings. See sqlite.org/lang_expr.html - it says The || operator is "concatenate" - it joins together the two strings of its operands. and then also (...) the || concatenation operator which always evaluates to either NULL or a text value. SQLite takes your two binary values, converts them to TEXT, then concatenates and returns TEXT. You can also have a look at this explanation: sqlite.1065341.n5.nabble.com/…

                      – Googie
                      Mar 26 at 9:31
















                    1














                    SQLite3 does support datatypes. See https://www.sqlite.org/datatype3.html



                    They are not strictly linked with declared type of a column, but rather individual per each cell value. The type is determined by how it was created/modified. For example if you insert 5, it will be INTEGER. If you insert 5.5, it will be REAL. If you insert 'test' it will be TEXT, if you insert zeroblob(1), it will be BLOB and if you insert null, it will be NULL.



                    Now, what you are doing is that you're trying to concatenate current value with a BLOB type. If current value is TEXT (or basically if you use || operator, as you do, you are converting any type into a TEXT), it will be concatenated with byte x00, which actually determines the end of a string. In other words, you are adding yet another string terminator, to an already existing one, that the TEXT type has.



                    There will be no change on output of this operation. TEXT always ends with byte zero and it is always excluded from the result, as it's a meta character, not the value itself.



                    Additional information from http://sqlite.1065341.n5.nabble.com/Append-data-to-a-BLOB-field-td46003.html - appending binary data to BLOB field is not possible. You can modify prealocated blob:




                    Append is not possible. But if you preallocate space using
                    zeroblob() or similar, you can write to it using the incremental
                    blob API:



                    http://www.sqlite.org/c3ref/blob_open.html




                    Finally, please see accepted answer, as author of the question found an interesting solution.






                    share|improve this answer

























                    • msg_buffer field is declared as BLOB Data type, and data is inserted with a Python script as sqlite3.Binary(bytearray(...))

                      – framontb
                      Mar 25 at 8:32







                    • 1





                      Yes, but the concatenation operator works on strings. See sqlite.org/lang_expr.html - it says The || operator is "concatenate" - it joins together the two strings of its operands. and then also (...) the || concatenation operator which always evaluates to either NULL or a text value. SQLite takes your two binary values, converts them to TEXT, then concatenates and returns TEXT. You can also have a look at this explanation: sqlite.1065341.n5.nabble.com/…

                      – Googie
                      Mar 26 at 9:31














                    1












                    1








                    1







                    SQLite3 does support datatypes. See https://www.sqlite.org/datatype3.html



                    They are not strictly linked with declared type of a column, but rather individual per each cell value. The type is determined by how it was created/modified. For example if you insert 5, it will be INTEGER. If you insert 5.5, it will be REAL. If you insert 'test' it will be TEXT, if you insert zeroblob(1), it will be BLOB and if you insert null, it will be NULL.



                    Now, what you are doing is that you're trying to concatenate current value with a BLOB type. If current value is TEXT (or basically if you use || operator, as you do, you are converting any type into a TEXT), it will be concatenated with byte x00, which actually determines the end of a string. In other words, you are adding yet another string terminator, to an already existing one, that the TEXT type has.



                    There will be no change on output of this operation. TEXT always ends with byte zero and it is always excluded from the result, as it's a meta character, not the value itself.



                    Additional information from http://sqlite.1065341.n5.nabble.com/Append-data-to-a-BLOB-field-td46003.html - appending binary data to BLOB field is not possible. You can modify prealocated blob:




                    Append is not possible. But if you preallocate space using
                    zeroblob() or similar, you can write to it using the incremental
                    blob API:



                    http://www.sqlite.org/c3ref/blob_open.html




                    Finally, please see accepted answer, as author of the question found an interesting solution.






                    share|improve this answer















                    SQLite3 does support datatypes. See https://www.sqlite.org/datatype3.html



                    They are not strictly linked with declared type of a column, but rather individual per each cell value. The type is determined by how it was created/modified. For example if you insert 5, it will be INTEGER. If you insert 5.5, it will be REAL. If you insert 'test' it will be TEXT, if you insert zeroblob(1), it will be BLOB and if you insert null, it will be NULL.



                    Now, what you are doing is that you're trying to concatenate current value with a BLOB type. If current value is TEXT (or basically if you use || operator, as you do, you are converting any type into a TEXT), it will be concatenated with byte x00, which actually determines the end of a string. In other words, you are adding yet another string terminator, to an already existing one, that the TEXT type has.



                    There will be no change on output of this operation. TEXT always ends with byte zero and it is always excluded from the result, as it's a meta character, not the value itself.



                    Additional information from http://sqlite.1065341.n5.nabble.com/Append-data-to-a-BLOB-field-td46003.html - appending binary data to BLOB field is not possible. You can modify prealocated blob:




                    Append is not possible. But if you preallocate space using
                    zeroblob() or similar, you can write to it using the incremental
                    blob API:



                    http://www.sqlite.org/c3ref/blob_open.html




                    Finally, please see accepted answer, as author of the question found an interesting solution.







                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Mar 26 at 9:35

























                    answered Mar 22 at 14:24









                    GoogieGoogie

                    3,81211025




                    3,81211025












                    • msg_buffer field is declared as BLOB Data type, and data is inserted with a Python script as sqlite3.Binary(bytearray(...))

                      – framontb
                      Mar 25 at 8:32







                    • 1





                      Yes, but the concatenation operator works on strings. See sqlite.org/lang_expr.html - it says The || operator is "concatenate" - it joins together the two strings of its operands. and then also (...) the || concatenation operator which always evaluates to either NULL or a text value. SQLite takes your two binary values, converts them to TEXT, then concatenates and returns TEXT. You can also have a look at this explanation: sqlite.1065341.n5.nabble.com/…

                      – Googie
                      Mar 26 at 9:31


















                    • msg_buffer field is declared as BLOB Data type, and data is inserted with a Python script as sqlite3.Binary(bytearray(...))

                      – framontb
                      Mar 25 at 8:32







                    • 1





                      Yes, but the concatenation operator works on strings. See sqlite.org/lang_expr.html - it says The || operator is "concatenate" - it joins together the two strings of its operands. and then also (...) the || concatenation operator which always evaluates to either NULL or a text value. SQLite takes your two binary values, converts them to TEXT, then concatenates and returns TEXT. You can also have a look at this explanation: sqlite.1065341.n5.nabble.com/…

                      – Googie
                      Mar 26 at 9:31

















                    msg_buffer field is declared as BLOB Data type, and data is inserted with a Python script as sqlite3.Binary(bytearray(...))

                    – framontb
                    Mar 25 at 8:32






                    msg_buffer field is declared as BLOB Data type, and data is inserted with a Python script as sqlite3.Binary(bytearray(...))

                    – framontb
                    Mar 25 at 8:32





                    1




                    1





                    Yes, but the concatenation operator works on strings. See sqlite.org/lang_expr.html - it says The || operator is "concatenate" - it joins together the two strings of its operands. and then also (...) the || concatenation operator which always evaluates to either NULL or a text value. SQLite takes your two binary values, converts them to TEXT, then concatenates and returns TEXT. You can also have a look at this explanation: sqlite.1065341.n5.nabble.com/…

                    – Googie
                    Mar 26 at 9:31






                    Yes, but the concatenation operator works on strings. See sqlite.org/lang_expr.html - it says The || operator is "concatenate" - it joins together the two strings of its operands. and then also (...) the || concatenation operator which always evaluates to either NULL or a text value. SQLite takes your two binary values, converts them to TEXT, then concatenates and returns TEXT. You can also have a look at this explanation: sqlite.1065341.n5.nabble.com/…

                    – Googie
                    Mar 26 at 9:31


















                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55301281%2fupdate-query-to-append-zeroes-into-blob-field-with-sqlitestudio%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

                    155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해