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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:59:49+00:00 2026-05-22T23:59:49+00:00

I am writing a small procedure. I have a cursor called c1 , and

  • 0

I am writing a small procedure. I have a cursor called c1, and a variable v_c1 that is declared like this: v_c1 c1%ROWTYPE. The cursor is fetched into it.

The problem however is that the value extracted from the cursor is not a number. I’m really confused since it’s a number in the table and it looks like a number when it is printed. Here is the procedure.

create or replace
PROCEDURE mini
IS
  CURSOR c1
  IS
    SELECT * FROM utslipp;

  v_c1 c1%ROWTYPE;
  v_co2_utslipp NUMBER;
  v_kildenavn VARCHAR2(200);
  v_temp NUMBER;

BEGIN
  OPEN c1;
  FETCH c1 INTO v_c1;
  v_co2_utslipp := v_c1.co2_utslipp;
  v_co2_utslipp := v_c1.co2_utslipp;

  LOOP
    FETCH c1 INTO v_c1;
    EXIT WHEN c1%NOTFOUND;

    v_temp := v_c1.co2_utslipp;

    IF v_temp < v_co2_utslipp THEN
      v_co2_utslipp := v_c1.co2_utslipp;
      v_kildenavn := v_c1.kildenavn;

    -- According to SQL Developer the error is here.
    ELSIF v_temp = v_co2_utslipp THEN

      -- ...When the actual error is here.      
      v_co2_utslipp := v_co2_utslipp || ', ' || v_c1.co2_utslipp;
      v_kildenavn := v_kildenavn || v_c1.kildenavn;
    END IF;    
  END LOOP;

  DBMS_OUTPUT.PUT_LINE(v_kildenavn || ', ' || v_co2_utslipp);
END; 

Update: Here is the script:

alter table utslipp
 drop primary key cascade ;
alter table produkt
 drop primary key cascade ;
alter table fylke
 drop primary key cascade ;
alter table eieren
 drop primary key cascade ;
drop table utslipp ;
drop table produkt ;
drop table fylke ;
drop table eieren ;



create table produkt
(
  pid number(2) primary key,
  produktnavn varchar2(20)
) ;

create table fylke
(
 fid number(2) primary key ,
 fylkesnavn varchar2(20)
) ;

create table eieren
(
 eid number(2) primary key,
 eiernavn varchar2(20)
) ;

create table utslipp
(
  kid number(2) ,
  kildenavn varchar2(20),
  eid number(2),
  pid number(2),
  fid number(2),
  aar number(4),
  co2_utslipp number(4),
  constraint utslipp_pk primary key(kid,aar) ,
  constraint eieren_fk
   FOREIGN KEY (eid)
   REFERENCES eieren,
  constraint produkt_fk
   FOREIGN KEY (pid) 
   REFERENCES produkt,
  constraint fylke_fk
   FOREIGN KEY (fid)
   REFERENCES fylke 
) ;

insert into eieren values(1,'Statoil');
insert into eieren values(2,'Hydro');
insert into eieren values(3,'Yara');
insert into eieren values(4,'Esso');
insert into eieren values(5,'Norcem') ;
insert into eieren values(6,'Alcoa') ;
insert into eieren values(7,'Eramet') ;
insert into eieren values(8,'Gassco') ;
insert into eieren values(9,'Philips') ;
insert into eieren values(10, 'Noretyl') ;

insert into produkt values(1,'Olje');
insert into produkt values(2,'Naturgass');
insert into produkt values(3,'Aluminium');
insert into produkt values(4,'Kunstgjødsel');
insert into produkt values(5,'Etylen');
insert into produkt values(6,'Stål');
insert into produkt values(7,'Bensin');
insert into produkt values(8,'Sement') ;

insert into fylke values(1, 'Finm') ;
insert into fylke values(2, 'Troms') ;
insert into fylke values(3, 'Nordland') ;
insert into fylke values(4, 'Nord-Trøndelag') ;
insert into fylke values(5, 'Sør-Trøndelag') ;
insert into fylke values(6, 'Møre-Romsdag') ;
insert into fylke values(7, 'Sogn-Fjordane') ;
insert into fylke values(8, 'Hordaland') ;
insert into fylke values(9, 'Rogaland') ;
insert into fylke values(10, 'Vest-Agder') ;
insert into fylke values(11, 'Aust-Agder') ;
insert into fylke values(12, 'Telemark') ;
insert into fylke values(13, 'Vestfold') ;
insert into fylke values(14, 'Buskrud') ;
insert into fylke values(15, 'Akershus') ;
insert into fylke values(16, 'Oslo') ;
insert into fylke values(17, 'Østfold') ;
insert into fylke values(18, 'Oppland') ;
insert into fylke values(19, 'Hedmark') ;
insert into fylke values(20, 'Offshore') ;

insert into utslipp values(1,'Snøhvit',1,1,1,2009,805);
insert into utslipp values(2,'Kjøpsvik',5,8,3,2009,409);
insert into utslipp values(3,'Mosjøen',6,3,3,2009,312);
insert into utslipp values(4,'Heidrun',1,1,20,2009,410);
insert into utslipp values(5,'Åsgard',1,1,20,2009,1041);
insert into utslipp values(6,'Tjeldbergodden',1,3,5,2009,315);
insert into utslipp values(7,'Sunndal',2,3,6,2009,528);
insert into utslipp values(8,'Snorre',1,1,20,2009,585);
insert into utslipp values(9,'Statfjord',1,1,20,2009,576);
insert into utslipp values(10,'Gullfaks',1,1,20,2009,979);
insert into utslipp values(11,'Troll',1,2,20,2009,625);
insert into utslipp values(12,'Mongstad',1,2,7,2009,1549);
insert into utslipp values(13,'Oseberg',1,1,20,2009,1143);
insert into utslipp values(14,'Odda',7,8,8,2009,328);
insert into utslipp values(15,'Karmøy',2,3,9,2009,317);
insert into utslipp values(16,'Kollsnes',8,2,9,2009,1129);
insert into utslipp values(17,'Sleipner',1,1,20,2009,865);
insert into utslipp values(18,'Ekkofisk',9,1,20,2009,1023);
insert into utslipp values(19,'Porsgrunn',3,4,12,2009,629);
insert into utslipp values(20,'Brevik',5,8,12,2009,825);
insert into utslipp values(21,'Bamble',10,5,12,2009,459);

-- Here is the newest insert.
INSERT INTO utslipp VALUES(2, 'foobar', 3, 1, 2, 2008, 312);    
insert into utslipp values(1,'Snøhvit',1,1,1,2008,1300);
insert into utslipp values(1,'Snøhvit',1,1,1,2007,1600);

Sorry for the length of it, but I don’t want to remove anything that can affect the result.

What am I doing wrong here?

  • 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-22T23:59:50+00:00Added an answer on May 22, 2026 at 11:59 pm

    the problem is not when you compare numbers. It is on the next line – you try to assign a string containing comma (,) into a number variable v_co2_utslipp.

    You completely misguided me by the wrong “error” line :(.

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

Sidebar

Related Questions

I'm writing a small/beta testing program that will be put to use in my
I'm writing a small bootloader for an x86 based PC. The problem is that
I'm writing a small Django-based frontend to collect and graph internet usage statistics. Currently,
I'm writing a small sample iphone application just to consume a SOAP Web service.
I'm writing a small program using CLR console application and when I write something
I'm writing a small file conversion utility. Files get automatically converted when they are
I am writing a small, really simple lisp parser in ruby with the treetop
I will preface the question by saying that I am somewhat new to the
perl -MCPAN -e'install File::Find::Rule' CPAN: Storable loaded ok Going to read /root/.cpan/Metadata Database was
There are lots of texts on how to plan software projects (with user stories,

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.