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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:38:56+00:00 2026-06-15T04:38:56+00:00

I want to write a PL/SQL function that takes as a parameter 2 arguments.

  • 0

I want to write a PL/SQL function that takes as a parameter 2 arguments. First parameter is an integer and second parameter is an Oracle sequence object.

This function returns a decimal value which is param1.param2 where param2 must be the next value of the sequence object taken as parameter.

Example: function myFc(15,objSq). Suppose objSq.nextVal is 33 then the returned decimal value must be 15.33

  • 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-15T04:38:57+00:00Added an answer on June 15, 2026 at 4:38 am

    This seems a little strange. You should always know what sequence you’re going to be using and please be aware that a sequence will never generate a gap-free sequence of numbers, a perfect 1, 2 ..n.

    As you don’t know an object name you have to use execute immediate, which enables you to use it. You should probably also use dbms_assert to protect against SQL Injection.

    The answer to your question would look something like this:

    create or replace my_function ( 
                    Pnumber in number
                  , Psequence in varchar2 ) return number is
    
       l_nextval number;
    
    begin
    
       execute immediate '
           select ' || dbms_assert.sql_object_name(Psequence) || '.nextval
             from dual'
             into l_nextval;
    
       -- Who knows how many decimal places you might need?
       return to_number(Pnumber || '.' || l_nextval, '99.9999');
    
    end;
    /
    

    However, I don’t understand why you would want to do this. You obviously know the name of the sequence that you are attempting to use. Instead of using a function you could simply use this information in your calling code:

    to_number(15 || '.' || sequence_name.nextval, '99.9999')
    

    Lastly, as David says in his comment this is a very strange requirement. Are you absolutely certain that this is what you want to be doing? Maybe by explaining why you’re doing this someone may be able to come up with a better suggestion.

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

Sidebar

Related Questions

I want to write a function in PL/SQL, which has a sql-statement as parameter.
My function takes pointer *d as parameter. I wrote that line - EXEC SQL
I'm trying to write a Powershell function that takes an array argument. I want
I want to write an Oracle function that collects some data in multiple steps
I'm trying to write an sql function in Postgresql that will parse a file
I want to Write a function that returns the Products brought in a given
I want to write a function that allows users to match data based on
Question: I want to write a custom aggregate function that concatenates string on group
I want to write a function that creates new variables in a dataframe based
I'm trying to write a SQL Statement that should function like the below Linq

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.