8 Replies Latest reply: Nov 22, 2012 2:57 AM by fac586 RSS

    image not displayed programmtically stored in blob column

    Sajjad
      Hi,

      I altered student table to store photoes of students. For this I added STIMG as blob, MIMETYPE,FILENAME,IMAGE_LAST_UPDATE COLUMNS to studentadmitted table. Image stored and displayed in report very nicely. With the following query

      select "ROWID",
      "ST_ID",
      "FIRST_NAME",
      "LAST_NAME",
      "FFIRST_NAME",
      "FLAST_NAME",
      "COURSE_ID",
      "SESSION_ID",
      "CONTACT#" "CONTACT_H",nvl(dbms_lob.getlength(STIMG),0) IMAGE
      from "#OWNER#"."STUDENTADMITTED"
      Images are displayed in column but they have different sizes.

      To control this I modified the query like this

      select "ROWID",
      "ST_ID",
      "FIRST_NAME",
      "LAST_NAME",
      "FFIRST_NAME",
      "FLAST_NAME",
      "COURSE_ID",
      "SESSION_ID",
      "CONTACT#" "CONTACT_H",decode(nvl(dbms_lob.getlength(stimg),0),0,null,
      '<img style="border: 4px solid #CCC; -moz-border-radius: 4px; -webkit-border-radius: 4px;" '||
      'src="'||
      apex_util.get_blob_file_src('P16_stIMG',st_id)||
      '" height="75" width="75" alt="Product Image" title="Product Image" />')
      detail_img
      from "#OWNER#"."STUDENTADMITTED"

      Report did'nt run with following error,

      report error:ORA-06502: PL/SQL: numeric or value error: character to number conversion error

      Win Server 2008
      Oracle Database :11G R2
      Apex Ver :4.2

      Sajjad
        • 1. Re: image not displayed programmtically stored in blob column
          fac586
          Sajjad wrote:

          I altered student table to store photoes of students. For this I added STIMG as blob, MIMETYPE,FILENAME,IMAGE_LAST_UPDATE COLUMNS to studentadmitted table. Image stored and displayed in report very nicely. With the following query

          select "ROWID",
          "ST_ID",
          "FIRST_NAME",
          "LAST_NAME",
          "FFIRST_NAME",
          "FLAST_NAME",
          "COURSE_ID",
          "SESSION_ID",
          "CONTACT#" "CONTACT_H",nvl(dbms_lob.getlength(STIMG),0) IMAGE
          from "#OWNER#"."STUDENTADMITTED"
          Images are displayed in column but they have different sizes.
          Stick to declarative BLOB images as above. They can be resized in reports using CSS. Add a style sheet in the page Inline CSS property:
          td[headers="IMAGE"] img {
            display: block;
            width: 75px;
            border: 1px solid #999;
            padding: 6px;
            background: #f6f6f6;
          }
          where the <tt>IMAGE</tt> value in the attribute selector is the table header ID of the image column. Setting only one dimension (in this case the width) scales the image with the correct aspect ratio. (The border, padding and background properties are just eye candy...)

          However, if the original images are large then scaling them in the browser this way is a huge waste of bandwidth and produces poorer quality images than creating proper scaled down versions using image tools. Downloading megapixel images and then reducing them to thumbnail size results in pointlessly pushing millions of bytes that will never be seen.

          For improved performance and image quality, and where you require image-specific scaling the best approach is to use the database ORDImage object to produce thumbnail and preview versions automatically. Note that this is not possible in Oracle XE as Multimedia is not included
          • 2. Re: image not displayed programmtically stored in blob column
            Jitendra
            Hi Sajjad,

            Try this,


            select "ROWID",
            "ST_ID",
            "FIRST_NAME",
            "LAST_NAME",
            "FFIRST_NAME",
            "FLAST_NAME",
            "COURSE_ID",
            "SESSION_ID",
            "CONTACT#" "CONTACT_H",
            '<img src="'|| NVL (dbms_lob.getlength(STIMG), 0)|| '" height="'||75|| '" width="'||75|| '" />' IMAGE
            from "#OWNER#"."STUDENTADMITTED"


            Hope this will helps you,

            Regards,
            Jitendra
            • 3. Re: image not displayed programmtically stored in blob column
              Sajjad
              Hi Fac


              Placing css code in page inline css, it displays same width no change. typing error it is page inline.

              Edited by: Sajjad on Nov 21, 2012 2:00 AM
              • 4. Re: image not displayed programmtically stored in blob column
                fac586
                Sajjad wrote:

                Placing css code in table inline css, it displays same width no change
                What is "table inline css"? In APEX 4.2 use the page's Inline CSS property.

                The best way to get help with problems like this is to create an example on apex.oracle.com.
                • 5. Re: image not displayed programmtically stored in blob column
                  Sajjad
                  Hi Jitendra

                  I tried your query but it gives the same error.
                  • 6. Re: image not displayed programmtically stored in blob column
                    Jitendra
                    Hi Sajjad,

                    Try this, Modified the last code.
                    I tried this is working at my side.


                    select "ROWID",
                    "ST_ID",
                    "FIRST_NAME",
                    "LAST_NAME",
                    "FFIRST_NAME",
                    "FLAST_NAME",
                    "COURSE_ID",
                    "SESSION_ID",
                    "CONTACT#" "CONTACT_H",
                    decode(nvl(dbms_lob.getlength(STIMG),0),0,null,'<img src="'||apex_util.get_blob_file_src('P16_stIMG',ST_ID)||'" width="75" height="75"/>') AS IMAGE,
                    "MIMETYPE",
                    "FILENAME",
                    "IMAGE_LAST_UPDATE"
                    from "#OWNER#"."STUDENTADMITTED"



                    Regards,
                    Jitendra
                    • 7. Re: image not displayed programmtically stored in blob column
                      Sajjad
                      Hi Jitendra,

                      Now all queries inclusing your's & mine is working but in a starnge way. I was following documentation & sample application "Orders, Products, Customers" and many other google stuff in which column attribute is chosen as "Blob" and after this blob column attribute portion appeared where blob table, column, mimrtype,filename is provided. This way it gives error.

                      Now I choose standard report column and nothing is chosen in Number / Date fornate, it works nicely.


                      Sajjad
                      • 8. Re: image not displayed programmtically stored in blob column
                        fac586
                        Sajjad wrote:

                        Now all queries inclusing your's & mine is working but in a starnge way. I was following documentation & sample application "Orders, Products, Customers" and many other google stuff in which column attribute is chosen as "Blob" and after this blob column attribute portion appeared where blob table, column, mimrtype,filename is provided. This way it gives error.

                        Now I choose standard report column and nothing is chosen in Number / Date fornate, it works nicely.
                        Declarative BLOB formats in reports and CSS sizing of the resulting images work perfectly well, and are better techniques than hard-coding HTML into the query as they provide proper separation of concerns. When you have a visual formatting or layout issue you'll get effective help faster if you create an example on apex.oracle.com so we can actually see the problem. I suggest you do this so we can find out why you had a problem with this.