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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:13:42+00:00 2026-06-11T11:13:42+00:00

I have a sql which returns 3 records select emp_no from employees where dept_no=’S3407′

  • 0

I have a sql which returns 3 records

select emp_no from employees where dept_no='S3407'

results

1089
2092
1999 

I need to use the above SQL in a function and function should return all three values.
I would like to use this function in another sql statement like the following

select * from emp_history where emp_no in ('1089','2092','1999');

In the above sql I would like to use the function instead of hard coded employee numbers.

What is the best way to accomplish this?

As the query is quite complex as what I have mentioned above is only a sample of the query as the full query cannot be pasted here. So I need to use a function to achieve this.

Any help is highly appreciable.

Regards

  • 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-11T11:13:44+00:00Added an answer on June 11, 2026 at 11:13 am

    I would recommend you to consider Andomar suggestion by the following reasons:
    1. views permit to provide enough level of encapsulation
    2. CBO works nearly perfect with views so your query will work more or less predictably depending of number of records.

    Once you replace the views by a function you will face the case when CBO can’t estimate the cardinality of function so you have either to submit full scan or implement kind of package in order to calculate the cardinality of the function.

    So +`1 to Andomar

    Surely you could use pipelined functions and rewrite the query as

     select * from emp_history where emp_no in (select * from table(your pipelined function))
    

    but as I explained before it’s not the best way

    You could find the perfect article (by my opinion) about pipelined functions in the link http://www.oracle-base.com/articles/misc/pipelined-table-functions.php

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

Sidebar

Related Questions

I have the following SQL statement which returns a single record as expected: select
I have a SQL statement which returns a number of rows and these are
SQL Server 2005 I have an SQL Function (ftn_GetExampleTable) which returns a table with
i've got a SQL query which returns multiple rows, and i have : $data
I have a stored procedure called WEB_SEL_SECURITY_QUESTIONS in my sql database which returns a
I'm using Sql-Server, and I have the below query which returns all columns that
I have a JSP page which accepts SQL queries, performs them then returns the
I have a sql query which looks like this - NSString *createSQL = @SELECT
I have the following Django Model which retrieves 3 records from a database. The
I have a web based program which chooses some records from a database using

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.