ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

PDF Documents in table

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PDF Documents in table

    I don't know if this belongs in SQL or RPG...

    I have a PDF document that I've created. I want to put that PDF document into a SQL table. I presume I'd create a cell as a BLOB to put it in... but how do I accomplish the task of putting the PDF into that cell?

  • #2
    I assume the PDF-document is located somewhere within the IFS.
    If so, you can use the GET_BLOB_FROM_FILE scalar function in the Insert Statement, something like this:

    Code:
    Insert Into YourTable (BLOBFLD)
    Values(Get_Blob_From_File('/IFSDir/IFSDir2/.../YourPDF.pdf', '0'));
    Birgitta

    Comment


    • #3
      Your assumption is correct - how do I test it to make sure it worked? That is - how do I reverse the process?

      Comment


      • #4
        The easiest way to write it back to the IFS is to use embedded SQL with File Reference Variables.

        File Reference Variables are converted into a data strcuture by the SQL precompiler.
        The sub-fields of this data structure need to be populated within the source code.
        File Reference variables (not the generated data structure!) can be used in composition with (embedded) SQL statements like any Single or Double Byte Character or Binary (unconverted) Variable.

        Something like this:
        Code:
        DCL-S   IfsBlobFile      SQLTYPE(Blob_File);
        
        IFSBlobFile_Name = '/Dir1/Dir2/.../DirN/YourIFSFile.pdf';
        IFSBlobFile_NL   = %Len(%Trim(IFSBlobFile_Name);
        IFSBlobFile_FO   = SQFOVR;   //Write a new file or replace an existing one
        
        Exec SQL
           Select BlobColumn   into :IFSBlobFile
              From YourTable
              Where UniqueKey1 = .... and UniqueKey2 = ....;
        Birgitta
        Last edited by B.Hauser; June 7, 2017, 10:58 PM.

        Comment


        • #5
          Birrgitta,

          Thank you. As always you are most helpful. I appreciate you.... a lot.

          Rocky

          Comment


          • #6
            Birgitta, is this a space saver for the IFS? Are these files much smaller when stored in a table?
            Your friends list is empty!

            Comment


            • #7
              I don't know if there is any space saving. To the best of my knowledge, the advantage of storing them in tables is that they can be accessed via SQL Query via whatever keys are available on the file, and that they are included in any backups of the table.

              Comment


              • #8
                Originally posted by Vectorspace View Post
                I don't know if there is any space saving. To the best of my knowledge, the advantage of storing them in tables is that they can be accessed via SQL Query via whatever keys are available on the file, and that they are included in any backups of the table.
                Why is that an advantage? Surely the effect is the same if you simply store a locator in the table? Unless you are assuming that the text in the PDF can be searched - which given the nature of PDFs seems unlikely. Admittedly I've never tried.

                Comment


                • #9
                  Text can be seached for in a PDF Jon.
                  Regards

                  Kit
                  http://www.ecofitonline.com
                  DeskfIT - ChangefIT - XrefIT
                  ___________________________________
                  There are only 3 kinds of people -
                  Those that can count and those that can't.

                  Comment

                  Working...
                  X