Oracle Apex - should I use Empty_BLOB() or null?












2















I am currently using Oracle Apex 5.1.2.



I created a table in the database that contains a column that can hold a BLOB data type, a column for filename, and a column for MIME type.



In my APEX application, I have a File Browse page item. The intent for this page item is to allow the end-user to attach a file to the page. This part works perfectly - the user is able to browse for a file using that item and attach it to a page and later download the file in order to view it.



The problem: I want the end-user to be able to delete the attachment if they need to and, if they'd like, attach another file in its place. My idea is to create a button and in the settings for the button set the Action to "Submit Page" and the Database Action to SQL Update Action. Then I will create a page process of type PL/SQL code and set the Server-side Condition in the settings for the process to occur when the button I created is pressed. In the PL/SQL code section of the process, it appears from the research I have done that I have one of two options:



UPDATE table_name
SET blob_column = EMPTY_BLOB()
WHERE my_id = id


OR:



UPDATE table_name
SET blob_column = null
WHERE my_id = id


I have already tried both of these options and they both work, but I don't know which option is better for what I am trying to achieve. I have tried to research this problem, but unfortunately I can't find the exact answer I am looking for. Does anyone have any recommendations?



Thank you in advance.










share|improve this question



























    2















    I am currently using Oracle Apex 5.1.2.



    I created a table in the database that contains a column that can hold a BLOB data type, a column for filename, and a column for MIME type.



    In my APEX application, I have a File Browse page item. The intent for this page item is to allow the end-user to attach a file to the page. This part works perfectly - the user is able to browse for a file using that item and attach it to a page and later download the file in order to view it.



    The problem: I want the end-user to be able to delete the attachment if they need to and, if they'd like, attach another file in its place. My idea is to create a button and in the settings for the button set the Action to "Submit Page" and the Database Action to SQL Update Action. Then I will create a page process of type PL/SQL code and set the Server-side Condition in the settings for the process to occur when the button I created is pressed. In the PL/SQL code section of the process, it appears from the research I have done that I have one of two options:



    UPDATE table_name
    SET blob_column = EMPTY_BLOB()
    WHERE my_id = id


    OR:



    UPDATE table_name
    SET blob_column = null
    WHERE my_id = id


    I have already tried both of these options and they both work, but I don't know which option is better for what I am trying to achieve. I have tried to research this problem, but unfortunately I can't find the exact answer I am looking for. Does anyone have any recommendations?



    Thank you in advance.










    share|improve this question

























      2












      2








      2








      I am currently using Oracle Apex 5.1.2.



      I created a table in the database that contains a column that can hold a BLOB data type, a column for filename, and a column for MIME type.



      In my APEX application, I have a File Browse page item. The intent for this page item is to allow the end-user to attach a file to the page. This part works perfectly - the user is able to browse for a file using that item and attach it to a page and later download the file in order to view it.



      The problem: I want the end-user to be able to delete the attachment if they need to and, if they'd like, attach another file in its place. My idea is to create a button and in the settings for the button set the Action to "Submit Page" and the Database Action to SQL Update Action. Then I will create a page process of type PL/SQL code and set the Server-side Condition in the settings for the process to occur when the button I created is pressed. In the PL/SQL code section of the process, it appears from the research I have done that I have one of two options:



      UPDATE table_name
      SET blob_column = EMPTY_BLOB()
      WHERE my_id = id


      OR:



      UPDATE table_name
      SET blob_column = null
      WHERE my_id = id


      I have already tried both of these options and they both work, but I don't know which option is better for what I am trying to achieve. I have tried to research this problem, but unfortunately I can't find the exact answer I am looking for. Does anyone have any recommendations?



      Thank you in advance.










      share|improve this question














      I am currently using Oracle Apex 5.1.2.



      I created a table in the database that contains a column that can hold a BLOB data type, a column for filename, and a column for MIME type.



      In my APEX application, I have a File Browse page item. The intent for this page item is to allow the end-user to attach a file to the page. This part works perfectly - the user is able to browse for a file using that item and attach it to a page and later download the file in order to view it.



      The problem: I want the end-user to be able to delete the attachment if they need to and, if they'd like, attach another file in its place. My idea is to create a button and in the settings for the button set the Action to "Submit Page" and the Database Action to SQL Update Action. Then I will create a page process of type PL/SQL code and set the Server-side Condition in the settings for the process to occur when the button I created is pressed. In the PL/SQL code section of the process, it appears from the research I have done that I have one of two options:



      UPDATE table_name
      SET blob_column = EMPTY_BLOB()
      WHERE my_id = id


      OR:



      UPDATE table_name
      SET blob_column = null
      WHERE my_id = id


      I have already tried both of these options and they both work, but I don't know which option is better for what I am trying to achieve. I have tried to research this problem, but unfortunately I can't find the exact answer I am looking for. Does anyone have any recommendations?



      Thank you in advance.







      oracle oracle-apex oracle-apex-5 oracle-apex-5.1






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked May 11 '18 at 15:51









      Katherine ReedKatherine Reed

      12910




      12910
























          3 Answers
          3






          active

          oldest

          votes


















          2














          The choice is a matter of opinion, since both options delete the previous attachment.



          I think most people would use blob_column = null to mean "no attachment", while blob_column = empty_blob() would mean "blank file attached". So I would recommend using null, but as you said, it works fine either way.






          share|improve this answer
























          • Sounds great to me - thank you!

            – Katherine Reed
            May 12 '18 at 14:56



















          0














          I think it depends on how you would like to test for nulls



          http://nuijten.blogspot.com.au/2009/11/empty-clob-is-not-null-its-not-null.html






          share|improve this answer































            0














            If you update your blob column with empty_blob() then you have to take care while selecting records like below:




            suppose you want all records where blob column has some file (useful) then you have to select like below




            select * from your_table where SYS.DBMS_LOB.GETLENGTH(blob_column) > 0;


            but if you update your blob column with null then you can simply write like:



            select * from your_table where blob_column is not null;





            share|improve this answer























              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%2f50295957%2foracle-apex-should-i-use-empty-blob-or-null%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              2














              The choice is a matter of opinion, since both options delete the previous attachment.



              I think most people would use blob_column = null to mean "no attachment", while blob_column = empty_blob() would mean "blank file attached". So I would recommend using null, but as you said, it works fine either way.






              share|improve this answer
























              • Sounds great to me - thank you!

                – Katherine Reed
                May 12 '18 at 14:56
















              2














              The choice is a matter of opinion, since both options delete the previous attachment.



              I think most people would use blob_column = null to mean "no attachment", while blob_column = empty_blob() would mean "blank file attached". So I would recommend using null, but as you said, it works fine either way.






              share|improve this answer
























              • Sounds great to me - thank you!

                – Katherine Reed
                May 12 '18 at 14:56














              2












              2








              2







              The choice is a matter of opinion, since both options delete the previous attachment.



              I think most people would use blob_column = null to mean "no attachment", while blob_column = empty_blob() would mean "blank file attached". So I would recommend using null, but as you said, it works fine either way.






              share|improve this answer













              The choice is a matter of opinion, since both options delete the previous attachment.



              I think most people would use blob_column = null to mean "no attachment", while blob_column = empty_blob() would mean "blank file attached". So I would recommend using null, but as you said, it works fine either way.







              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered May 11 '18 at 18:58









              kfinitykfinity

              2,9891614




              2,9891614













              • Sounds great to me - thank you!

                – Katherine Reed
                May 12 '18 at 14:56



















              • Sounds great to me - thank you!

                – Katherine Reed
                May 12 '18 at 14:56

















              Sounds great to me - thank you!

              – Katherine Reed
              May 12 '18 at 14:56





              Sounds great to me - thank you!

              – Katherine Reed
              May 12 '18 at 14:56













              0














              I think it depends on how you would like to test for nulls



              http://nuijten.blogspot.com.au/2009/11/empty-clob-is-not-null-its-not-null.html






              share|improve this answer




























                0














                I think it depends on how you would like to test for nulls



                http://nuijten.blogspot.com.au/2009/11/empty-clob-is-not-null-its-not-null.html






                share|improve this answer


























                  0












                  0








                  0







                  I think it depends on how you would like to test for nulls



                  http://nuijten.blogspot.com.au/2009/11/empty-clob-is-not-null-its-not-null.html






                  share|improve this answer













                  I think it depends on how you would like to test for nulls



                  http://nuijten.blogspot.com.au/2009/11/empty-clob-is-not-null-its-not-null.html







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered May 14 '18 at 4:14









                  ScottScott

                  1,94511420




                  1,94511420























                      0














                      If you update your blob column with empty_blob() then you have to take care while selecting records like below:




                      suppose you want all records where blob column has some file (useful) then you have to select like below




                      select * from your_table where SYS.DBMS_LOB.GETLENGTH(blob_column) > 0;


                      but if you update your blob column with null then you can simply write like:



                      select * from your_table where blob_column is not null;





                      share|improve this answer




























                        0














                        If you update your blob column with empty_blob() then you have to take care while selecting records like below:




                        suppose you want all records where blob column has some file (useful) then you have to select like below




                        select * from your_table where SYS.DBMS_LOB.GETLENGTH(blob_column) > 0;


                        but if you update your blob column with null then you can simply write like:



                        select * from your_table where blob_column is not null;





                        share|improve this answer


























                          0












                          0








                          0







                          If you update your blob column with empty_blob() then you have to take care while selecting records like below:




                          suppose you want all records where blob column has some file (useful) then you have to select like below




                          select * from your_table where SYS.DBMS_LOB.GETLENGTH(blob_column) > 0;


                          but if you update your blob column with null then you can simply write like:



                          select * from your_table where blob_column is not null;





                          share|improve this answer













                          If you update your blob column with empty_blob() then you have to take care while selecting records like below:




                          suppose you want all records where blob column has some file (useful) then you have to select like below




                          select * from your_table where SYS.DBMS_LOB.GETLENGTH(blob_column) > 0;


                          but if you update your blob column with null then you can simply write like:



                          select * from your_table where blob_column is not null;






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 23 '18 at 12:31









                          p27p27

                          1,35412041




                          1,35412041






























                              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%2f50295957%2foracle-apex-should-i-use-empty-blob-or-null%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

                              Feedback on college project

                              Futebolista

                              Albești (Vaslui)