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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:20:26+00:00 2026-05-11T00:20:26+00:00

I have the following Oracle function: function get_job_no return number is V_job_no number; begin

  • 0

I have the following Oracle function:

function get_job_no return number is         V_job_no number;       begin          select appwork.tlm_corphier_job.nextval into V_job_no from dual;          return V_job_no;       end get_job_no; 

PLEASE NOTE:
1) This is a FUNCTION, not a procedure
2) This is returning a NUMBER, not a VARCHAR
3) I happen to be using System.Data.OracleClient rather than Oracle.DataAccess.Client (due to another issue I was having) but a solution with either would be fine.

I am trying to call this from VB.Net using the MS enterprise library like so:

Imports Microsoft.Practices.EnterpriseLibrary.Data Imports System.Data.OracleClient     Public Function GetNextJobNumber() As Object         Dim db As Database = DatabaseFactory.CreateDatabase()         Dim myresult As Object = Nothing         Using cmd As DbCommand = db.GetStoredProcCommand('CORPHIER_PKG.get_job_no')             Dim retval As New Data.OracleClient.OracleParameter('retval', GetType(System.Data.OracleClient.OracleNumber))             retval.Direction = ParameterDirection.ReturnValue             cmd.Parameters.Add(retval)             db.ExecuteNonQuery(cmd)             myresult = retval.Value         End Using         Return myresult     End Function 

I get the following error:

System.InvalidCastException: Failed to convert parameter value from a RuntimeType to a Decimal. —> System.InvalidCastException: Object must implement IConvertible. at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) at System.Data.OracleClient.OracleParameter.CoerceValue(Object value, MetaType destinationType) — End of inner exception stack trace — at System.Data.OracleClient.OracleParameter.CoerceValue(Object value, MetaType destinationType) at System.Data.OracleClient.OracleParameter.SetCoercedValueInternal(Object value, MetaType metaType) at System.Data.OracleClient.OracleParameterBinding.PrepareForBind(OracleConnection connection, Int32& offset) at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals) at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciRowidDescriptor& rowidDescriptor) at System.Data.OracleClient.OracleCommand.ExecuteNonQuery() at Microsoft.Practices.EnterpriseLibrary.Data.Database.DoExecuteNonQuery(DbCommand command) at Microsoft.Practices.EnterpriseLibrary.Data.Database.ExecuteNonQuery(DbCommand command)

  • 1 1 Answer
  • 1 View
  • 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. 2026-05-11T00:20:27+00:00Added an answer on May 11, 2026 at 12:20 am

    Ok, this seems to work:

    Public Function GetNextJobNumber() As Object     Dim db As Database = DatabaseFactory.CreateDatabase()     Using cmd As DbCommand = db.GetStoredProcCommand('CORPHIER_PKG.get_job_no')         db.AddParameter(cmd, 'retval', DbType.Int32, 0, ParameterDirection.ReturnValue, True, 0, 0, String.Empty, DataRowVersion.Current, Convert.DBNull)         db.ExecuteNonQuery(cmd)         Return db.GetParameterValue(cmd, 'retval')     End Using End Function 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a following oracle query: SELECT a.USER_ID, c.first_name, c.last_name, TO_CHAR( b.logon_date, 'MM/DD/YYYY HH:MI:SS
I have the following Oracle query: SELECT id, DECODE(state, 'Open', state_in, NULL) AS open_in,
I have the following query: SELECT wm_concat(DISTINCT NAME) as Methods FROM TPM_TRAININGPLAN JOIN TPM_DELIVERYMETHODS
I have an Oracle function GetEmployeeDetails which saves all the employee details into a
I have a function that inserts a chunk of data into oracle database. I'm
I have the following query: select id from table1 where some_func(?) = 1; where
I have a simple query: select * from countries with the following results: country_name
I have a following oracle sql query in which START_DATE is a number column
I have the following query: SELECT patient_id FROM patient_visit where visit_type in ('A', 'B',
I have the following bit of code that reads data from the an Oracle

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.