Update showing no data found error

时间:2022-09-21 06:29:32

The following update is not updating my table. It is stating the following error message when submitting:

以下更新不会更新我的表。它在提交时声明以下错误消息:

ORA-01403: no data found

ORA-01403:未找到任何数据

I have made sure all the fields are input with some data, but it still states the following error of there being no data. any ideas or help?

我确保所有字段都输入了一些数据,但它仍然表明没有数据的以下错误。任何想法或帮助?

DECLARE

  l_upload_size INTEGER;
  l_upload_blob BLOB;
  l_image_id    NUMBER;
  l_image       ORDSYS.ORDImage;
  l_name        VARCHAR2(100);
  l_address        VARCHAR2(100);  
  l_postcode       VARCHAR2(100);
  l_description   VARCHAR2(100);

BEGIN

  --
  -- Get the BLOB of the new image from the APEX_APPLICATION_TEMP_FILES (synonym for WWV_FLOW_TEMP_FILES)
  -- APEX 5.0 change from APEX_APPLICATION_FILES which has been deprecated
  -- APEX_APPLICATION_TEMP_FILES has fewer columns and is missing doc_size
  --

  SELECT
    blob_content
  INTO
    l_upload_blob
  FROM
    apex_application_temp_files
  WHERE
    name = :P3_filename;
  --
  -- Insert a new row into the table, initialising the image and
  -- returning the newly allocated image_id for later use
  --
UPDATE bars
SET
      image_id = :P3_IMAGE_ID,
      filename = :P3_FILENAME,
      image = ORDSYS.ORDImage(),
      name = :P3_NAME,
      address = :P3_ADDRESS,
      postcode = :P3_POSTCODE,
      description = :P3_DESCRIPTION

  WHERE
    image_id = l_image_id;

  -- find the size of BLOB (get doc_size)
  l_upload_size := dbms_lob.getlength(l_upload_blob);
  -- copy the blob into the ORDImage BLOB container
  DBMS_LOB.COPY( l_image.SOURCE.localData, l_upload_blob, l_upload_size );

  -- set the image properties
  l_image.setProperties(); 
  create_blob_thumbnail(l_image_id);



END;

2 个解决方案

#1


1  

Like Alex mentioned, the ORA-01403 is not thrown by the UPDATE, but by the SELECT. Make sure that P3_filename has a value and there is matching data in the table.

就像Alex提到的那样,ORA-01403不是由UPDATE引发的,而是由SELECT引发的。确保P3_filename具有值,并且表中存在匹配的数据。

Simple to prove this, just enclose the SELECT in an exception block like this:

很容易证明这一点,只需将SELECT包含在一个异常块中,如下所示:

....
BEGIN

  SELECT
    blob_content
  INTO
    l_upload_blob
  FROM
    apex_application_temp_files
  WHERE
    name = :P3_filename;

EXCEPTION
  WHEN NO_DATA_FOUND THEN
     <<Add your troubleshooting code here, like display the variable>>
END
.....

#2


0  

Maybe you use the SQL%ROWCOUNT to check the number of rows affected. Here is a good example for it.

也许您使用SQL%ROWCOUNT来检查受影响的行数。这是一个很好的例子。

#1


1  

Like Alex mentioned, the ORA-01403 is not thrown by the UPDATE, but by the SELECT. Make sure that P3_filename has a value and there is matching data in the table.

就像Alex提到的那样,ORA-01403不是由UPDATE引发的,而是由SELECT引发的。确保P3_filename具有值,并且表中存在匹配的数据。

Simple to prove this, just enclose the SELECT in an exception block like this:

很容易证明这一点,只需将SELECT包含在一个异常块中,如下所示:

....
BEGIN

  SELECT
    blob_content
  INTO
    l_upload_blob
  FROM
    apex_application_temp_files
  WHERE
    name = :P3_filename;

EXCEPTION
  WHEN NO_DATA_FOUND THEN
     <<Add your troubleshooting code here, like display the variable>>
END
.....

#2


0  

Maybe you use the SQL%ROWCOUNT to check the number of rows affected. Here is a good example for it.

也许您使用SQL%ROWCOUNT来检查受影响的行数。这是一个很好的例子。