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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:31:02+00:00 2026-06-08T12:31:02+00:00

I have a stored procedure that updates records if they exist, or adds a

  • 0

I have a stored procedure that updates records if they exist, or adds a new record if they don’t exist.

SQL:

CREATE OR REPLACE PROCEDURE ADDRECORD(ihost VARCHAR, iip VARCHAR)
AS 
   rc VARCHAR(4000);
   ROWCOUNT NUMBER;
BEGIN
   rc := 'select count(0) from myTable where physical_host =  ihost and primary_ip = iip';
   ROWCOUNT := to_number(rc, '99');

   IF ROWCOUNT = 1 THEN
      UPSERTRECORD(ihost, iip);
   ELSE
      INSERT INTO myTable(PHYSICAL_HOST, PRIMARY_IP)
      VALUES (ihost, iip);
      INSERT INTO IP (IP, IP_IND) VALUES (iip, 'V');
   END IF;    
END ADDRECORD;

The UPSERTRECORD is another stored procedure that is being called. It works fine. In fact, the error is occurring on the line that contains the to_number. The error is :

ORA-06502: PL/SQL: numeric or value error: character to number conversion error 

Is there another way to do this? Sorry, I’m not super experienced with SQL, but I need to get this figured out.

  • 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-08T12:31:03+00:00Added an answer on June 8, 2026 at 12:31 pm

    Do

    DECLARE rowcount As Number(38)
    select count(*) INTO rowcount from myTable 
    where physical_host =  ihost and primary_ip = iip
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a stored procedure that updates a table using linq, eg: (this is
I have a stored procedure that has this line: SET @SQL = 'SELECT path,title,tags
I have a SQL Server 2008 database. This database has a stored procedure that
My limited SQL knowledge prompted this post! I have a stored procedure that runs
I like to use Upsert stored procedures that update records if they exist or
I want to have a stored procedure that inserts a record into tableA and
I have a stored procedure that updates data in a table for a specific
I have a stored procedure that is required to update an existing record with
I have a stored procedure that says update table1 set value1 = 1 where
I have a stored procedure that has the parameter: @desk VARCHAR(50) I want to

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.