Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8991609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:46:06+00:00 2026-06-15T22:46:06+00:00

I’m a neophyte with Oracle and PL/SQL; I’m having some issues with a select

  • 0

I’m a neophyte with Oracle and PL/SQL; I’m having some issues with a select into several variables. What I’m trying to do is search for multiple items in one table (SA_SPECIFICATION_DETAILS) and concatenate them together into a field in the other table (SA_ASSET). The SA_SPECIFICATION_DETAILS table holds several rows of attributes per each SA_ASSET.ASSET_ID. I’ve been working on this a few days now and keep getting several errors. Here is my sample code:

DECLARE 
manuf VARCHAR(50);
mods VARCHAR(50);
mvs VARCHAR(50);
yeara VARCHAR(4);
assid VARCHAR(50):= &assid;

BEGIN
SELECT TRIM(ATTRIBUTE_VALUE) INTO manuf      
    FROM
      SA_SPECIFICATION_DETAILS d,
      SA_ASSET a
    WHERE
      d.SPECIFICATION_NO = a.SPECIFICATION_NO
    AND d.ATTRIBUTE_DESC = 'MANUFACTURER'
    AND ASSET_ID = assid;

SELECT TRIM(ATTRIBUTE_VALUE) INTO mods
    FROM
      SA_SPECIFICATION_DETAILS d,
      SA_ASSET a
    WHERE
      d.SPECIFICATION_NO = a.SPECIFICATION_NO
    AND d.ATTRIBUTE_DESC = 'MODEL'
    AND ASSET_ID = assid;

SELECT TRIM(ATTRIBUTE_VALUE) INTO mvs
    FROM
      SA_SPECIFICATION_DETAILS d,
      SA_ASSET a
   WHERE
      d.SPECIFICATION_NO = a.SPECIFICATION_NO
    AND d.ATTRIBUTE_DESC = 'MAIN VALVE SIZE'
    AND ASSET_ID = assid;

SELECT TRIM(ATTRIBUTE_VALUE) INTO yeara
    FROM
      SA_SPECIFICATION_DETAILS d,
      SA_ASSET a
    WHERE
      d.SPECIFICATION_NO = a.SPECIFICATION_NO
    AND d.ATTRIBUTE_DESC = 'YEAR MANUFACTURED'
    AND ASSET_ID = assid;

dbms_output.ENABLE(buffer_size => NULL);
DBMS_OUTPUT.PUT_LINE ('Variables:');
dbms_output.put_line (manuf);
dbms_output.put_line (mods);
dbms_output.put_line (mvs);
dbms_output.put_line (yeara);
dbms_output.put_line (assid);
END;

BEGIN
UPDATE
  SA_ASSET
SET
  ASSET_DESC = TRIM(ATTRIBUTE1)
  || ' - Service Type: PW, Manf: '
  || manuf
  || ', Model: '
  || mods
  || ', Main Valve Size: '
  || mvs
  || ', Year Manf: '
  || yearm
  || ', Location: '
  || TRIM(SA_ASSET.STREET_NUMBER_CHAR)
  || ' '
  || TRIM(SA_ASSET.STREET_NAME)
WHERE
  ASSET_TYPE     = 'HYDRANT'
AND ASSET_STATUS = 'ACTIVE'
AND UPPER(ASSET_DESC) NOT LIKE '%LOCATION:%'
AND UPPER(ASSET_DESC) NOT LIKE '%HYDRANT%'
AND SA_ASSET.ASSET_ID = assid
END;

I’ve tested this and it fails with:
Error report:
ORA-06550: line 73, column 1:
PLS-00103: Encountered the symbol “BEGIN”
ORA-06550: line 96, column 1:
PLS-00103: Encountered the symbol “END” when expecting one of the following:

So I commented out the update portion and tried this:

    declare 
    manuf sa_specification_details.attribute_value%type;
    mods sa_specification_details.attribute_value%type;
    mvs sa_specification_details.attribute_value%type;
    yeara sa_specification_details.attribute_value%type;
    assid varchar2(15):= &assid;

    --dbms_output.ENABLE(buffer_size => NULL);

    BEGIN
    SELECT ATTRIBUTE_VALUE INTO manuf      
        FROM
          SA_SPECIFICATION_DETAILS d,
          SA_ASSET a
        WHERE
          d.SPECIFICATION_NO = a.SPECIFICATION_NO
        AND d.ATTRIBUTE_DESC = 'MANUFACTURER'
        AND ASSET_ID = assid;
    dbms_output.put_line (manuf);

   SELECT ATTRIBUTE_VALUE INTO mods
        FROM
          SA_SPECIFICATION_DETAILS d,
          SA_ASSET a
        WHERE
          d.SPECIFICATION_NO = a.SPECIFICATION_NO
        AND d.ATTRIBUTE_DESC = 'MODEL'
        AND ASSET_ID = assid;
    dbms_output.put_line (mods);

    SELECT ATTRIBUTE_VALUE INTO mvs
        FROM
          SA_SPECIFICATION_DETAILS d,
          SA_ASSET a
       WHERE
          d.SPECIFICATION_NO = a.SPECIFICATION_NO
        AND d.ATTRIBUTE_DESC = 'MAIN VALVE SIZE'
        AND ASSET_ID = assid;
    dbms_output.put_line (mvs);

    SELECT ATTRIBUTE_VALUE INTO yeara
        FROM
          SA_SPECIFICATION_DETAILS d,
          SA_ASSET a
        WHERE
          d.SPECIFICATION_NO = a.SPECIFICATION_NO
        AND d.ATTRIBUTE_DESC = 'YEAR MANUFACTURED'
        AND ASSET_ID = assid;
    dbms_output.put_line (yeara);  

    SYS.dbms_output.ENABLE;
    DBMS_OUTPUT.PUT_LINE ('Variables:');
    dbms_output.put_line (manuf);
    dbms_output.put_line (mods);
    dbms_output.put_line (mvs);
    dbms_output.put_line (yeara);
    dbms_output.put_line (assid); 
    END;

Which gets me the error:
Error report:
ORA-01403: no data found
ORA-06512: at line 11
01403. 00000 – “no data found”
*Cause:
*Action:

So I ran the query without the select into:

SELECT
  ATTRIBUTE_VALUE
FROM
  SA_SPECIFICATION_DETAILS d,
  SA_ASSET a
WHERE
  d.SPECIFICATION_NO = a.SPECIFICATION_NO
AND d.attribute_desc = 'MANUFACTURER'
AND asset_id = '001722';

And it returns a single row/single column (aka it works). So what am I doing wrong? I’ve declared the variables, I’ve got the selects to run correctly but it’s not passing the variables (that I can tell – haven’t got dbms_output.put_line (manuf); to work). Am I close or on the wrong track completely?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:46:08+00:00Added an answer on June 15, 2026 at 10:46 pm

    in your code, you need to add single quotes here:

    assid VARCHAR2(50):= '&assid';
    

    also remove the end/begin here:

    dbms_output.put_line (assid);
    END;
    
    BEGIN
    

    as you want this as one block (as you’re using the variables from the first selects in the update).

    finally i think you mean this to be yeara and not yearm

      || ', Year Manf: '
      || yearm <-- yeara?
    

    an optimisation you can do too, is replace the 4 selects with one:

    select max(case d.attribute_desc
                 when 'MANUFACTURER' then trim(attribute_value)
               end) manuf,
           max(case d.attribute_desc
                 when 'MODEL' then trim(attribute_value)
               end) mods,
           max(case d.attribute_desc
                 when 'MAIN VALVE SIZE' then trim(attribute_value)
               end) mvs,
           max(case d.attribute_desc
                 when 'YEAR MANUFACTURED' then trim(attribute_value)
               end) yeara
      into manuf, mods, mvs, yeara
      from sa_specification_details d,
           sa_asset a
     where d.specification_no = a.specification_no
       and d.attribute_desc in ( 'MANUFACTURER', 'MODEL', 'MAIN VALVE SIZE',
                                 'YEAR MANUFACTURED' )
       and asset_id = assid; 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to select an H1 element which is the second-child in its group
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm interested in microtypography issues on the web. I want a tool to fix:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.