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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:58:31+00:00 2026-06-11T08:58:31+00:00

I have a query as shown below: TRUNCATE TABLE DNARTLOAD; COMMIT; …. <Cursor here>

  • 0

I have a query as shown below:

TRUNCATE TABLE DNARTLOAD;
COMMIT;

.... <Cursor here> .... <do something>.....

tmp_future_phaseA := substr(tmp_phases,1,1);
tmp_future_phaseB := substr(tmp_phases,2,1);
tmp_future_phaseC := substr(tmp_phases,3,1);

INSERT INTO DNARTLOAD (LOADNAME,KVARATING,PHASE,FULLPHASE) VALUES 
(tmp_load_name, tmp_kvarating, tmp_future_phaseA, tmp_phase);

The problem is that the query fails to insert tmp_phases correctly every time. What I’m doing is taking the substring of temp phases (which is never null) and assigning the first, second, and third character to another set of varchar variables. Once they are assigned, I insert the data into a table and commit. The problem is it doesn’t work all the time. It will ALWAYS fill tmp_future_phaseA, B, and C with a character, but when I insert the tmp_phase it will sometimes populate null and sometimes populate the values.

Example Data:

tmp_phase = 'ABC'

tmp_futurephaseA = 'A'

tmp_futurephaseB = 'B'

tmp_futurephaseC = 'C'

Sometimes I’ll get the following:

A  'ABC'

B 'ABC'

C 'ABC'

Other times during the same plsql I’ll get the following:

A NULL

B NULL

C NULL

EDIT: Added for question:

LOOP
    tmp_future_phaseA := NULL;
    tmp_future_phaseB := NULL;
    tmp_future_phaseC := NULL;
    tmp_phases := NULL;

    FETCH C3 INTO tmp_load_name, tmp_kvarating, tmp_phases;
    EXIT WHEN C3%NOTFOUND;

IF LENGTH(tmp_phases) = 3 THEN
  tmp_kvarating := tmp_kvarating / 3;
END IF;

IF LENGTH(tmp_phases) = 2 THEN
  tmp_kvarating := tmp_kvarating /2;
END IF;

tmp_future_phaseA := substr(tmp_phases,1,1);
tmp_future_phaseB := substr(tmp_phases,2,1);
tmp_future_phaseC := substr(tmp_phases,3,1);

IF tmp_future_phaseA IS NOT NULL THEN
  INSERT INTO DNARTLOAD (LOADNAME,KVARATING,PHASE) VALUES (tmp_load_name, tmp_kvarating, tmp_future_phaseA);
END IF;

IF tmp_future_phaseB IS NOT NULL THEN
  INSERT INTO DNARTLOAD (LOADNAME,KVARATING,PHASE) VALUES (tmp_load_name, tmp_kvarating, tmp_future_phaseB);
END IF;

IF tmp_future_phaseC IS NOT NULL THEN
  INSERT INTO DNARTLOAD (LOADNAME,KVARATING,PHASE) VALUES (tmp_load_name, tmp_kvarating, tmp_future_phaseC);
END IF;  
  • 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-11T08:58:33+00:00Added an answer on June 11, 2026 at 8:58 am

    “Sometimes I’ll get the following: … Other times during the same
    plsql I’ll get the following:”

    Sometimes your program works, sometimes it doesn’t. This means you have a data problem.

    More accurately, you have written a program which caters correctly for data in some states but not in others. There’s absolutely no way we’re going to be able to diagnose that.

    So, what you need to do is debug your code. If you have a proper IDE that should offer you a debugging facility. Otherwise you will need to use something like DBMS_OUTPUT to display the input for each trip round the loop and the subsequent outcome, so that you can understand which values your program isn’t handling correctly.

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

Sidebar

Related Questions

Ok I have a table in my mysql query browser like shown below: NAME:
I have sales table data as shown below Sales Table Data http://lh5.ggpht.com/_KT7tmVVBHFM/TCryAax1JlI/AAAAAAAAAFk/zahMq4RoOuw/s144/Sales.png I want
I have this query (shown below) which currently uses temporary and filesort in order
I have a select query in MySQL shown below: This query executes and produces
I have a portion of my query as shown below which the TOP 1
I have a simple query in my code (shown below) written by my colleague.
I have a table as shown below. ID ParentID Node Name Node Type ------------------------------------------------------------------
I have a sample query as shown below: SELECT * FROM [#temp1] UNION SELECT
I have produced a result from the following query as shown below.Now the result
I have a table similar to the example shown below. AccountNo DateOfOrder OrderID -----------------------------------------

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.