10 Replies Latest reply on Jul 5, 2012 11:13 AM by Andrew Lea

    PL/SQL Selecting Blob in Oracle Forms

    user3841965
      Hi,

      I have a custom form that has been working for some time in EBS until we upgraded our database over the weekend from 10 to 11g.

      Basically this form allows users to add attachments using the standard attachment functionality. The user can choose to email the attachments to users by hitting a send email button, calling the when-button-pressed trigger.

      When this happens the PL/SQL program has a cursor that selects the file_name and file_data (blob) into a variable and then does an insert statement to insert the attachment into a custom table, from there I have a UTL_SMTP function that I call that is able to send the attachment. However since the upgrade it errors out before its able to insert the attachment.

      However since the upgrade we get the following error message when hitting the send email button. Below I've pasted the snippet of the PL/SQL program that is erroring out, what is strange is if I copy this PL/SQL trigger into SQL Developer the program works perfectly fine, it just doesn't work when run through the form. Also if I comment out the l.file_data from the cursor it works fine as well, but obviously just no attachment is sent in the email.

      ORA-01403: no data found
      --------------------------------------------------------------
      FRM-40735: WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-06502.

      DECLARE
      v_file_data                               blob;
      v_file_name                               varchar2(100);

      cursor c_send_email is
      select d.file_name, l.file_data
      from fnd_documents_vl d
                , fnd_attached_documents ad
                , srcust_projects p
                , srcust_project_tasks pt
      , fnd_lobs l
           where ad.entity_name like 'SRCUST_PROJECT_TASKS'
                and d.document_id = ad.document_id
                and p.project_id = pt.project_id
                and to_char(pt.task_id) = ad.pk1_value
      and d.media_id = l.file_id
                and pt.task_id = :task_detail.task_id;

      BEGIN
      .
      .
      .
      select sar.srcust_email_attach_mail_id_s.nextval
      into v_mail_id
      from dual;

      for emailx in c_send_email loop
      v_file_name := emailx.file_name;
      v_file_data := emailx.file_data;

      insert into srcust_email_attachments
      values
      (v_mail_id          --Mail ID of attachment inserted above
      , sar.srcust_email_attach_seq_id_s.nextval --Assigning a unique value to seq_no for each attachment
      , v_file_name               --File Name
      , v_file_data);               --Actual Data File (blob)

      END LOOP; ---END C_SEND_EMAIL LOOP
      commit; --Commit attachment inserts

      Has anyone else experienced this or have any thoughts on why I'm unable to select a blob since the upgrade?

      Thanks in advance for your help.
        • 1. Re: PL/SQL Selecting Blob in Oracle Forms
          Srini Chavali-Oracle
          Pl post details of OS, database and EBS versions.

          Have you enabled FRD to determine what could be the issue ?

          How To Collect And Use Forms Trace (FRD) in Oracle Applications Release 12 [ID 373548.1]     
          11i: Obtaining Forms Runtime Diagnostics (FRD) In Oracle Applications 11i [ID 150168.1]

          HTH
          Srini
          • 2. Re: PL/SQL Selecting Blob in Oracle Forms
            user3841965
            Solaris 10
            RDBMS : 11.2.0.3.0
            Oracle Applications : 11.5.10.2

            I'll check out the other documents you posted as well, thanks.
            • 3. Re: PL/SQL Selecting Blob in Oracle Forms
              user3841965
              Below is the section from the FRD trace on the when-button-pressed trigger

              WHEN-BUTTON-PRESSED Trigger Fired:
              Form: SRCUST_PROJECT
              Block: EMAIL_DETAIL_TASK
              Item: PUSH_BUTTON_SEND

              State Delta:
              FORM SRCUST_PROJECT
              CURFIELD PUSH_BUTTON_SEND
              SRCUST_PROJECT, 0, Trigger, Entry, 559092, WHEN-BUTTON-PRESSED

              SRCUST_PROJECT, 1, Prog Unit, Entry, 559092, /SRCUST_PROJECT-5/P158_09_SEP_201111_07_54

              SRCUST_PROJECT, 2, Prog Unit, Entry, 559092, /SRCUST_PROJECT-5/P158_09_SEP_201111_07_54

              SRCUST_PROJECT, 2, Prog Unit, Exit, 559092, /SRCUST_PROJECT-5/P158_09_SEP_201111_07_54

              SRCUST_PROJECT, 2, Prog Unit, Entry, 559092, /SRCUST_PROJECT-5/P158_09_SEP_201111_07_54

              SRCUST_PROJECT, 2, Prog Unit, Exit, 559092, /SRCUST_PROJECT-5/P158_09_SEP_201111_07_54


              Unhandled Exception ORA-06502
              State Delta:

              Error Message: FRM-40735: WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-06502.

              ON-ERROR Trigger Fired:
              Form: SRCUST_PROJECT

              State Delta:
              SRCUST_PROJECT, 2, Trigger, Entry, 559092, ON-ERROR

              SRCUST_PROJECT, 3, Prog Unit, Entry, 559092, /SRCUST_PROJECT-5/P58_09_SEP_201111_07_54


              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Entering app_standard.event. Event is ON-ERROR.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing ERROR_TYPE Built-in:
              Out Argument 0 - Type: String Value: FRM

              Executing ERROR_CODE Built-in:
              Out Argument 0 - Type: Number Value: 40735

              Executing ERROR_TEXT Built-in:
              Out Argument 0 - Type: String Value: WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-06502.

              Executing SET_APPLICATION_PROPERTY Built-in:
              In Argument 0 - Type: Number Value: 263
              In Argument 1 - Type: String Value: DEFAULT
              In Argument 2 - Type: Number Value: 0

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Entering app_exception.on_error.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing BELL Built-in:

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Entering app_form.reset_message_level.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: 0
              In Argument 1 - Type: String Value: SYSTEM.MESSAGE_LEVEL

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Completed app_form.reset_message_level.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing DBMS_ERROR_CODE Built-in:
              Out Argument 0 - Type: Number Value: -1403

              Executing DBMS_ERROR_TEXT Built-in:
              Out Argument 0 - Type: String Value: ORA-01403: no data found


              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Entering app_exception.extract.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Completed app_exception.extract. RETURN n.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Entering app_debug.show.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Entering app_debug.init_group.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing FIND_GROUP Built-in:
              In Argument 0 - Type: String Value: APP_DEBUG

              Executing CREATE_GROUP Built-in:
              In Argument 0 - Type: String Value: APP_DEBUG
              In Argument 1 - Type: Number Value: 302
              In Argument 2 - Type: Number Value: 20
              Out Argument 0 - Type: Integer Value: -25

              Executing ADD_GROUP_COLUMN Built-in:
              In Argument 0 - Type: Integer Value: -25
              In Argument 1 - Type: Number Value: 1300
              In Argument 2 - Type: String Value: PROCEDURE
              In Argument 3 - Type: Number Value: 61
              Out Argument 0 - Type: Number Value: -1638399

              Executing ADD_GROUP_COLUMN Built-in:
              In Argument 0 - Type: Integer Value: -25
              In Argument 1 - Type: Number Value: 1300
              In Argument 2 - Type: String Value: EVENT
              In Argument 3 - Type: Number Value: 100
              Out Argument 0 - Type: Number Value: -1638398

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Completed app_debug.init_group. RETURN group_id
              In Argument 1 - Type: String Value: global.frd_debug

              Executing GET_GROUP_ROW_COUNT Built-in:
              In Argument 0 - Type: Integer Value: -25
              Out Argument 0 - Type: Number Value: 0

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Entering app_debug.clear
              In Argument 1 - Type: String Value: global.frd_debug

              Executing FIND_GROUP Built-in:
              In Argument 0 - Type: String Value: APP_DEBUG
              Out Argument 0 - Type: Integer Value: -25

              Executing DELETE_GROUP_ROW Built-in:
              In Argument 0 - Type: Integer Value: -25
              In Argument 1 - Type: Number Value: -1

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Completed app_debug.free.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Completed app_debug.show. RETURN rrow >0.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing DBMS_ERROR_TEXT Built-in:
              Out Argument 0 - Type: String Value: ORA-01403: no data found


              Executing DBMS_ERROR_TEXT Built-in:
              Out Argument 0 - Type: String Value: ORA-01403: no data found


              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND MESSAGE_STRING "ORA-01403: no data found\n"
              SRCUST_PROJECT, 4, Built-In, Entry, 559092, USER_EXIT

              SRCUST_PROJECT, 4, Built-In, Exit, 559092, USER_EXIT


              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND MESSAGE_STRING "FRM-40735: WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-06502."
              SRCUST_PROJECT, 4, Built-In, Entry, 559092, USER_EXIT

              SRCUST_PROJECT, 4, Built-In, Exit, 559092, USER_EXIT


              Executing COPY Built-in:
              In Argument 0 - Type: String Value: NULL
              In Argument 1 - Type: String Value: GLOBAL.OUT

              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND MESSAGE_GET "GLOBAL.OUT" "Y"
              SRCUST_PROJECT, 4, Built-In, Entry, 559092, USER_EXIT

              SRCUST_PROJECT, 4, Built-In, Exit, 559092, USER_EXIT


              Executing NAME_IN Built-in:
              In Argument 0 - Type: String Value: GLOBAL.OUT
              Out Argument 0 - Type: String Value: FRM-40735: WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-06502.

              Executing NAME_IN Built-in:
              In Argument 0 - Type: String Value: GLOBAL.OUT1
              Out Argument 0 - Type: String Value: NULL

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: NULL
              In Argument 1 - Type: String Value: GLOBAL.OUT

              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND MESSAGE_GET "GLOBAL.OUT" "Y"
              SRCUST_PROJECT, 4, Built-In, Entry, 559092, USER_EXIT

              SRCUST_PROJECT, 4, Built-In, Exit, 559092, USER_EXIT


              Executing NAME_IN Built-in:
              In Argument 0 - Type: String Value: GLOBAL.OUT
              Out Argument 0 - Type: String Value: ORA-01403: no data found
              

              Executing NAME_IN Built-in:
              In Argument 0 - Type: String Value: GLOBAL.OUT1
              Out Argument 0 - Type: String Value: NULL

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: NULL
              In Argument 1 - Type: String Value: GLOBAL.OUT

              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND MESSAGE_GET "GLOBAL.OUT" "Y"
              SRCUST_PROJECT, 4, Built-In, Entry, 559092, USER_EXIT

              SRCUST_PROJECT, 4, Built-In, Exit, 559092, USER_EXIT


              Executing NAME_IN Built-in:
              In Argument 0 - Type: String Value: GLOBAL.OUT
              Out Argument 0 - Type: String Value: NULL

              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND MESSAGE_STRING "FRM-40735: WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-06502."
              SRCUST_PROJECT, 4, Built-In, Entry, 559092, USER_EXIT

              SRCUST_PROJECT, 4, Built-In, Exit, 559092, USER_EXIT


              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND MESSAGE_STRING "ORA-01403: no data found\n"
              SRCUST_PROJECT, 4, Built-In, Entry, 559092, USER_EXIT

              SRCUST_PROJECT, 4, Built-In, Exit, 559092, USER_EXIT


              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND MESSAGE_DISPLAY HISTORY
              SRCUST_PROJECT, 4, Built-In, Entry, 559092, USER_EXIT


              TSE FSERVER_START -1 90 2401282364952900
              TSE FSERVER_END -1 0 2401282479091700
              TSE FSERVER_START -1 1012 2401283497032000
              TSE FSERVER_END -1 0 2401283497093000
              TSE FSERVER_START -1 93309 2401376811327900
              TSE FSERVER_END -1 0 2401376811393000
              # 20 - SRCUST_PROJECT:EMAIL_DETAIL_TASK.PUSH_BUTTON_SEND.2401404461854800
              USER_EXIT CHOICE OK

              TSE FSERVER_START -1 93309 2401404461658600
              TSE FSERVER_END -1 0 2401404461964600SRCUST_PROJECT, 4, Built-In, Exit, 559120, USER_EXIT


              Executing GET_APPLICATION_PROPERTY Built-in:
              In Argument 0 - Type: Number Value: 257
              Out Argument 0 - Type: String Value: SRCUST_PROJECT

              Executing DEFAULT_VALUE Built-in:
              In Argument 0 - Type: String Value: FALSE
              In Argument 1 - Type: String Value: GLOBAL.FND_LOG_ATTACHMENT_WRITTEN

              Executing NAME_IN Built-in:
              In Argument 0 - Type: String Value: GLOBAL.FND_LOG_ATTACHMENT_WRITTEN
              Out Argument 0 - Type: String Value: FALSE

              Executing NAME_IN Built-in:
              In Argument 0 - Type: String Value: SYSTEM.MODE
              Out Argument 0 - Type: String Value: NORMAL

              Executing DBMS_ERROR_CODE Built-in:
              Out Argument 0 - Type: Number Value: -1403

              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND DEBUG_LOG TEST "6" "fnd.forms.SRCUST_PROJECT.ON_ERROR" RETURN="GLOBAL.LOGTESTRETURN"
              SRCUST_PROJECT, 4, Built-In, Entry, 559120, USER_EXIT

              SRCUST_PROJECT, 4, Built-In, Exit, 559120, USER_EXIT


              Executing NAME_IN Built-in:
              In Argument 0 - Type: String Value: GLOBAL.LOGTESTRETURN
              Out Argument 0 - Type: String Value: N

              Unhandled Exception ORA-100501
              State Delta:
              SRCUST_PROJECT, 3, Trigger, Exit, 559120, ON-ERROR

              SRCUST_PROJECT, 2, Trigger, Exit, 559120, WHEN-BUTTON-PRESSED


              WHEN-NEW-ITEM-INSTANCE Trigger Fired:
              Form: SRCUST_PROJECT

              State Delta:
              SRCUST_PROJECT, 2, Trigger, Entry, 559120, WHEN-NEW-ITEM-INSTANCE

              SRCUST_PROJECT, 3, Prog Unit, Entry, 559120, /SRCUST_PROJECT-5/P61_09_SEP_201111_07_54


              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Entering app_standard.event. Event is WHEN-NEW-ITEM-INSTANCE.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing NAME_IN Built-in:
              In Argument 0 - Type: String Value: GLOBAL.FND_LAUNCHED_FROM_SELFSERV
              Out Argument 0 - Type: String Value: Y

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: NULL
              In Argument 1 - Type: String Value: GLOBAL.OUT

              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND GETPROFILE NAME="ICX_SESSION_ID" FIELD="GLOBAL.OUT" N
              SRCUST_PROJECT, 4, Built-In, Entry, 559120, USER_EXIT

              SRCUST_PROJECT, 4, Built-In, Exit, 559120, USER_EXIT


              Executing FORM_SUCCESS Built-in:
              Out Argument 0 - Type: Boolean Value: TRUE

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Entering fnd_session.check_session.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: NULL
              In Argument 1 - Type: String Value: GLOBAL.OUT

              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND GETPROFILE NAME="SIGNON_PASSWORD_FAILURE_LIMIT" FIELD="GLOBAL.OUT" N
              SRCUST_PROJECT, 4, Built-In, Entry, 559120, USER_EXIT

              SRCUST_PROJECT, 4, Built-In, Exit, 559120, USER_EXIT


              Executing NAME_IN Built-in:
              In Argument 0 - Type: String Value: GLOBAL.OUT
              Out Argument 0 - Type: String Value: 5

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: Entering fnd_sesssion.session_status.
              In Argument 1 - Type: String Value: global.frd_debug

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: NULL
              In Argument 1 - Type: String Value: GLOBAL.FND_GLOBAL

              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND SYSDATE "GLOBAL.FND_GLOBAL" DATETIMENUM
              SRCUST_PROJECT, 4, Built-In, Entry, 559120, USER_EXIT

              SRCUST_PROJECT, 4, Built-In, Exit, 559120, USER_EXIT


              Executing NAME_IN Built-in:
              In Argument 0 - Type: String Value: GLOBAL.FND_GLOBAL
              Out Argument 0 - Type: String Value: 2012/05/09 10:32:54

              Executing NAME_IN Built-in:
              In Argument 0 - Type: String Value: GLOBAL.FND_GLOBAL
              Out Argument 0 - Type: String Value: 2012/05/09 10:32:54

              Executing ERASE Built-in:
              In Argument 0 - Type: String Value: GLOBAL.FND_GLOBAL

              Executing COPY Built-in:
              In Argument 0 - Type: String Value: NULL
              In Argument 1 - Type: String Value: GLOBAL.OUT

              Executing USER_EXIT Built-in:
              In Argument 0 - Type: String Value: FND GETPROFILE NAME="ICX_SESSION_ID" FIELD="GLOBAL.OUT" N
              SRCUST_PROJECT, 4, Built-In, Entry, 559120, USER_EXIT
              • 4. Re: PL/SQL Selecting Blob in Oracle Forms
                Srini Chavali-Oracle
                Looks like your custom code is raising an ORA-06502 error that is not being handled in the code via an exception. You will have to look at the code to see why and make appropriate changes. This MOS Doc may help

                Master Note for Diagnosing ORA-06502 Error [ID 1137237.1]     

                HTH
                Srini
                • 5. Re: PL/SQL Selecting Blob in Oracle Forms
                  user3841965
                  I've narrowed it down to as soon as the loop calls the cursor select statement below it errors out with the ORA-06502 value error . As soon as I comment out l.file_data below it works without error. I guess the question is what has changed between db 10 and 11 that doesn't allow me to select a blob column?

                  v_file_data      blob;
                  v_file_name      varchar2(100);

                  select d.file_name, l.file_data
                  from fnd_documents_vl d
                  , fnd_attached_documents ad
                  , srcust_projects p
                  , srcust_project_tasks pt
                  , fnd_lobs l
                  where ad.entity_name like 'SRCUST_PROJECT_TASKS'
                  and d.document_id = ad.document_id
                  and p.project_id = pt.project_id
                  and to_char(pt.task_id) = ad.pk1_value
                  and d.media_id = l.file_id
                  and pt.task_id = :task_detail.task_id;

                  Edited by: user3841965 on May 9, 2012 12:46 PM
                  • 6. Re: PL/SQL Selecting Blob in Oracle Forms
                    user3841965
                    Ok, I've simplified this a bit to make it a little easier to understand. I've taken the cursor and loop out.

                    Below is the new section of code, erroring out for the same reason and I've added the exceptions below. When I hit the button for the when-button-pressed trigger the code below hits the value_error exception. I get the alert with the file name which is correct and then I get the same "ORA-01403: no data found FRM-40735: WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-06502." error.

                    All this is doing is selecting the blob column l.file_data into the blob variable v_file_data. I'm lost as to why this is a problem?

                    BEGIN
                         
                    select d.file_name, l.file_data
                    into v_file_name
                    , v_file_data
                    from fnd_documents_vl d
                    , fnd_attached_documents ad
                    , srcust_projects p
                    , srcust_project_tasks pt
                    , fnd_lobs l
                    where ad.entity_name like 'SRCUST_PROJECT_TASKS'
                    and d.document_id = ad.document_id
                    and p.project_id = pt.project_id
                    and pt.task_id = ad.pk1_value
                    and d.media_id = l.file_id
                    and pt.task_id = 175;
                    EXCEPTION when invalid_number then
                    v_msg := 'invalid number';
                    set_alert_property('alert_msg',ALERT_MESSAGE_TEXT,v_msg);
                    v_button := show_alert('alert_msg');
                    raise;
                    WHEN value_error then
                    v_msg := v_file_name; --'value error';
                    set_alert_property('alert_msg',ALERT_MESSAGE_TEXT,v_msg);
                    v_button := show_alert('alert_msg');
                    raise;
                    END;
                    • 7. Re: PL/SQL Selecting Blob in Oracle Forms
                      Srini Chavali-Oracle
                      Is the length of file_name longer than 100 characters ? Does this error occur consistently for all data ?

                      Resolving FRM-40735 Errors [ID 61579.1]     

                      HTH
                      Srini
                      • 8. Re: PL/SQL Selecting Blob in Oracle Forms
                        user3841965
                        I've tried this with several different attachments, but the file name I used as a test above was just test.txt and is only a 1k file.

                        Also if I comment out the l.file_data and v_file_data it doesn't error out. So I know it has to be specific to that blob column.

                        Edited by: user3841965 on May 9, 2012 2:05 PM
                        • 9. Re: PL/SQL Selecting Blob in Oracle Forms
                          user3841965
                          Anyone else have any thoughts or ever run in to this?
                          • 10. Re: PL/SQL Selecting Blob in Oracle Forms
                            Andrew Lea
                            I think I've just run into the same problem and have a workaround.


                            The error did not occur on 10g but does on 11g.


                            Code extract is:-


                            PROCEDURE upload_transfer
                            IS
                            the_file_id NUMBER;
                            gfm_access_id NUMBER;
                            image_count NUMBER;
                            image_data BLOB;

                            CURSOR image_data_cursor
                            IS
                            SELECT file_data
                            FROM fnd_lobs
                            WHERE file_id = the_file_id;
                            BEGIN
                            OPEN image_data_cursor;

                            FETCH image_data_cursor INTO image_data;

                            CLOSE image_data_cursor;
                            END;


                            error 06502:PL/SQL numeric or value error occurs on fetch statement.


                            My workaround was not to fetch the blob into a variable at all.

                            Where I need to insert/update it in a table I draw the value directly from the table:-



                            UPDATE a_table
                            SET image =
                            (SELECT file_data
                            FROM fnd_lobs
                            WHERE file_id = the_file_id)
                            WHERE match = 'MATCH_CRITERIA';