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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:42:50+00:00 2026-05-24T13:42:50+00:00

I have a table with many records and it continues to grow: table T_A

  • 0

I have a table with many records and it continues to grow:

  table T_A
  { 
    total varchar2(10),
    total number
  }

The “total” field composed with 5 numbers and 1 character, e.g. “12345p”, the character is either “p” or “N”.

Now, I want to write a trigger to convert existing “total” to numbers and store them in “total_num”. furthermore, if there are inserting or updating operations, it can automatically finishes this conversion, and it must satisfy the following condition:

if the character is “p”, the number is positive, e.g. “12345p”
converts to “12345”, otherwise, the number is negative. e.g.
“12345N” converts to “-12345”.

How to write this trigger?

  • 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-05-24T13:42:51+00:00Added an answer on May 24, 2026 at 1:42 pm

    Try this

    (not tested as I don’t have an oracle connection at the moment)

      CREATE OR REPLACE TRIGGER trg_ta_totals
      BEFORE INSERT OR UPDATE ON T_A
      FOR EACH ROW
    
        DECLARE
            vnum number;
        BEGIN
    
        IF instr(:NEW.total,'p') > 0 THEN
           vnum:=TO_NUMBER(SUBSTR(:NEW.total,0,LENGTH(:NEW.total)-1));     
        ELSIF instr(:NEW.total,'N') > 0 THEN
           vnum:=TO_NUMBER(SUBSTR(:NEW.total,0,LENGTH(:NEW.total)-1))*-1;
        END IF; 
    
        :NEW.total_num := vnum; 
    
        END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing table 'people_table', with a field full_name . Many records have
I have a table which contains many records. I'm looking for an efficient way
I have a table within my database that has many records, some records share
I have a table of many values where one column has the WO Number,
In each table have many number of rows with amount. Like this i have
I have a table contents many fields db.define_table('i2l_templates', Field('id','id', represent=lambda id:SPAN(A(T('View'),_href=URL('view_template',args=id)),' | ', A(T('Edit'),_href=URL('edit_template',args=id)))),
I have table X, and each record in X has many records in Y.
I have a table that contains a float column. There are many records in
SQL Server 2005 Database. I have a temporary table with many records, these records
I have a table with many duplicate records: shop ID tax_id 1 10 1

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.