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

  • Home
  • SEARCH
  • 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 9271063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:31:30+00:00 2026-06-18T15:31:30+00:00

I have the following running code: DECLARE rec_present NUMBER (10) := 0; BEGIN SELECT

  • 0

I have the following running code:

DECLARE
  rec_present NUMBER (10) := 0;
BEGIN
  SELECT COUNT (*)
  INTO rec_present
  FROM ref_cross_exchange_rate
  WHERE local_ccy_pk =
    &localCcy
  AND base_ccy_pk =
    &baseccy
  AND base_date =
    &BaseDate;
  IF rec_present = 0 THEN
    INSERT
    INTO ref_cross_exchange_rate
      (
        cross_exchange_rate_pk,
        base_date ,
        local_ccy_pk ,
        base_ccy_pk 
      )
      VALUES
      (
        (SELECT NVL (MAX (cross_exchange_rate_pk), 0) + 1
          FROM ref_cross_exchange_rate
        )
        ,
        &BaseDate,
        &localCcy,
        &baseccy
      );
    DBMS_OUTPUT.put_line ('1 RECORD INSERTED');
  ELSE
    DBMS_OUTPUT.put_line ('RECORD ALREADY EXISTS');
  END IF;
END;
/
COMMIT;

but the problem is I have to enter same value several times, so I have done some modification as follows:

DECLARE
  rec_present number (10) := 0;
  bdate Date          := &basedate;
  local_ccy     NUMBER(10,0)  := &localccy;
  base_ccy      NUMBER(10,0)  := &baseccy;
  exchange_rate NUMBER(20,10) := &ExchangeRate;
BEGIN
  SELECT COUNT (*)
  INTO rec_present
  from ref_cross_exchange_rate
  where local_ccy_pk = local_ccy
  and base_ccy_pk    = base_ccy
  AND base_date      =TO_DATE (bdate) ;
  IF rec_present     = 0 THEN
    INSERT
    INTO ref_cross_exchange_rate
      (
        cross_exchange_rate_pk,
        base_date ,
        local_ccy_pk ,
        base_ccy_pk 
      )
      VALUES
      (
        (SELECT NVL (MAX (cross_exchange_rate_pk), 0) + 1
          FROM ref_cross_exchange_rate
        )
        ,
        TO_DATE (bdate),
        local_ccy,
        base_ccy
      );
    DBMS_OUTPUT.put_line ('1 RECORD INSERTED');
  ELSE
    DBMS_OUTPUT.put_line ('RECORD ALREADY EXISTS');
  END IF;
END;
/
COMMIT;

but unfortunately its not working.
I tried the suggestion from this question, but its not working.

Error:

Error report:

ORA-06550: line 3, column 26:
PLS-00382: expression is of wrong type
ORA-06550: line 3, column 9:
PL/SQL: Item ignored
ORA-06550: line 13, column 24:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 13, column 24:
PL/SQL: ORA-00904: "BDATE": invalid identifier
ORA-06550: line 8, column 3:
PL/SQL: SQL Statement ignored
ORA-06550: line 40, column 9:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 40, column 9:
PL/SQL: ORA-00904: "BDATE": invalid identifier
ORA-06550: line 15, column 5:
PL/SQL: SQL Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.
*Action:
commited.
  • 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-18T15:31:32+00:00Added an answer on June 18, 2026 at 3:31 pm

    Added quotes in the declare part to assign the values to the variables properly.

    This should work,

    DECLARE
    
      rec_present number (10) := 0;
      bdate Date          := '&basedate';
      local_ccy     NUMBER(10,0)  := '&localccy';
      base_ccy      NUMBER(10,0)  := '&baseccy';
      exchange_rate NUMBER(20,10) := '&ExchangeRate';
    
    BEGIN
      SELECT COUNT (*)
      INTO rec_present
      from ref_cross_exchange_rate
      where local_ccy_pk = local_ccy
      and base_ccy_pk    = base_ccy
      AND base_date      =TO_DATE (bdate) ;
      IF rec_present     = 0 THEN
        INSERT
        INTO ref_cross_exchange_rate
          (
            cross_exchange_rate_pk,
            base_date ,
            local_ccy_pk ,
            base_ccy_pk 
          )
          VALUES
          (
            (SELECT NVL (MAX (cross_exchange_rate_pk), 0) + 1
              FROM ref_cross_exchange_rate
            )
            ,
            TO_DATE (bdate),
            local_ccy,
            base_ccy
          );
        DBMS_OUTPUT.put_line ('1 RECORD INSERTED');
      ELSE
        DBMS_OUTPUT.put_line ('RECORD ALREADY EXISTS');
      END IF;
    END;
    /
    COMMIT;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code running on my Android device. It works great and
I have the following code for running a mongo query, Where the 'mongotester' is
I have the following code: public void disconnect() { running = false; if(thread !=
I have the following code in a jQuery JavaScript document running on a page
I have the following code: RegistryKey installKey = Registry.LocalMachine.OpenSubKey(installKey); I am running a static
I have the following code to declare a queue: Connection connection = RabbitConnection.getConnection(); Channel
I have the following code running in my site. It is done to show
I keep running into the following problem where I need to declare the input_fields
I have the following T-SQL code: SET TRANSACTION ISOLATION LEVEL SERIALIZABLE BEGIN TRANSACTION T1_Test
I have the following code running when the user clicks the Save button: -

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.