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 8023325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:32:02+00:00 2026-06-04T22:32:02+00:00

how can I turn this code into a function with the same output? declare

  • 0

how can I turn this code into a function with the same output?

declare
  record_name employees%ROWTYPE; 
begin
  FOR record_name IN (SELECT (a.first_name || ' ' || a.last_name) complete_name,
                      b.DEPARTMENT_NAME complete_name2
                     FROM employees a , departments b
                     WHERE ROWNUM < 1000 and a.DEPARTMENT_ID=b.DEPARTMENT_ID)
  LOOP 
    DBMS_OUTPUT.PUT_LINE('Employee name: ' || record_name.complete_name 
                           ||'DEPARTMENT name: '||record_name.complete_name2);
  END LOOP;
END;
  • 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-04T22:32:03+00:00Added an answer on June 4, 2026 at 10:32 pm
    create or replace function SOME_FUNCTION
    RETURN VARCHAR
    AS
      record_name employees%ROWTYPE;
      out_stmt varchar(4000); 
      TOO_LONG EXCEPTION;
    BEGIN
      FOR record_name IN (SELECT (a.first_name || ' ' || a.last_name) complete_name,
                          b.DEPARTMENT_NAME complete_name2
                         FROM employees a , departments b
                         WHERE ROWNUM < 1000 and a.DEPARTMENT_ID=b.DEPARTMENT_ID)
      LOOP
        IF (LENGTH(out_stmt) < 4000) THEN
           out_stmt := out_stmt || 'Employee name: ' || record_name.complete_name || 'DEPARTMENT name: '||record_name.complete_name2;
        ELSE
           RAISE TOO_LONG;
        END IF;
      END LOOP;
      return out_stmt;
    EXCEPTION
       WHEN TOO_LONG THEN
          RETURN 'OVERFLOW';
    END;
    

    Fast example, i don’t know whether is some type that not have integrity limitation because not always will be varchar(4000) enought. but i heard something about this type but now i dont exactly know wether exists.

    When you will work with this in app layer, must somehow format returned string.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to figure out how I can turn this: $('#username').blur(function(){ $.post('register/isUsernameAvailable', {username:$('#username').val()}, function(data){
How can I turn this behavoir off? It happens when you enter a close
I'd like a daemonizer that can turn an arbitrary, generic script or command into
I have a CGContext, which I can turn into an NSGraphicsContext. I have an
I asked a related question here: Clojure: How do I turn clojure code into
$('h2').each(function() { $('UL.chapters_list').append($('<li/>', {text: $(this).text()})) }); This code grabs all of the <H2> tags
I am trying to translate a function in a book into code, using MATLAB
Does anyone know how you can turn off autocompletion on a textfield in Django?
When using NUnit, I can turn off shadow copy so that my test assemblies
As you know, in Eclipse you can turn on Unnecessary 'else' statement check that

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.