Forum OpenACS Development: ORA-00932: inconsistent datatypes

Collapse
Posted by mayang ray on
hello, anybody can help me?
i have problem in dis PL/SQL stuff and i have no idea to solve it again. i'm stuck :'(
d error said :
DECLARE
*
ERROR at line 1:
ORA-00932: inconsistent datatypes
ORA-06512: at line 71

but i have check all d tables i hv made n all is d same..please help me...
below is d code

DECLARE
  CURSOR c1 IS select extno, dialno, sdate, stime, duration, trunk, to_char(sdate, 'DAY') day, dur, detime
  from z_pabx;
  bill c1%rowtype;
  ctype char(1);
  cost number(7,2);
  unitprice number(7,2);
  unitpulse number(3);
  airtime number(6,3);
  destination varchar2(30);
BEGIN
  open c1;
  loop
      cost := 0;
      fetch c1 into bill;
      IF c1%NOTFOUND THEN
        exit;
      ELSE
        IF bill.dialno like '001%' THEN
        ctype := 'I';
            SELECT country_name
            INTO destination
            FROM z_count
            WHERE (to_number(bill.dialno,4,4)= country_code)
          OR (to_number(bill.dialno,4,3)= country_code)
          OR (to_number(bill.dialno,4,2)= country_code)
                  OR (to_number(bill.dialno,4,1)= country_code);
        IF bill.day = 'SUNDAY' THEN --OR bill.sdate in (SELECT daydate from z_holiday) THEN
              SELECT trfred
              INTO unitprice
              FROM z_count;
              cost := ceil(bill.dur/60)*unitprice;
            ELSE
              SELECT B.trf
              INTO unitprice
              FROM z_count A, z_cgroupt B
              WHERE A.grp_trf = B.grp_trf
              AND bill.detime
              BETWEEN to_number(B.stime )AND to_number(B.etime);
              cost := ceil(bill.dur/60)*unitprice;
            END IF;
        ELSIF bill.dialno like '016%' THEN
        ctype := 'V';
            IF substr(bill.dialno,4,2) like '08%' THEN
              SELECT city
          INTO destination
          FROM z_cellzone
          WHERE to_number(bill.dialno,6,2)= cell_code
          AND to_number(bill.dialno,8,6)
          BETWEEN range1 AND range2;
          cost := ceil(bill.dur/60)*2300;
            ELSIF substr(bill.dialno,4,1) like '0%' THEN
              SELECT city_name
          INTO destination
          FROM z_city
          WHERE to_number(bill.dialno,5,3)= city_code OR to_number(bill.dialno,5,2)= city_code;
          cost := ceil(bill.dur/60)*1500;
            ELSE
              SELECT dest
          INTO destination
          FROM z_local
          WHERE to_number(bill.dialno,1,3) = pref2
          OR to_number(bill.dialno,1,2)= pref2;
          cost := ceil(bill.dur/60)*1500;
          END IF;
        ELSIF bill.dialno like '0809%' THEN
      ctype := 'N';
      cost := ceil(bill.dur/3600)*9750;
        ELSIF bill.dialno like '0%' THEN
      ctype := 'D';
          SELECT C.city_name
          INTO destination
          FROM z_city C, z_zoning D
          WHERE to_number(bill.dialno,2,3) = C.city_code OR to_number(bill.dialno,2,2) = C.city_code
          AND C.zone = D.zone;
          IF bill.day = 'SUNDAY' THEN
              SELECT pulse, rpp
          INTO unitpulse, unitprice
              FROM z_zoning
              WHERE bill.detime
              BETWEEN to_number(fhour) AND to_number(lhour)
              AND holdflag = 1;
              cost := ceil(bill.dur/unitpulse)*unitprice;
          ELSE
              SELECT pulse, rpp
              INTO unitpulse, unitprice
              FROM z_zoning
              WHERE bill.detime
              BETWEEN to_number(fhour) AND to_number(lhour)
              AND holdflag = 0;
              cost := ceil(bill.dur/unitpulse)*unitprice;
          END IF;
     ELSIF bill.dialno like '08%' THEN
          ctype := 'C';
          SELECT A.city
          INTO destination
          FROM z_cellzone A, z_cellt C
          WHERE to_number(bill.dialno, 2, 3) = A.cell_code
          AND (to_number(bill.dialno,5,7) BETWEEN A.range1 AND A.range2)
          OR (to_number(bill.dialno,5,6) BETWEEN A.range1 AND A.range2)
          AND A.zone = C.zone;
          IF bill.day = 'SUNDAY' THEN --OR B.sdate in D.daydate THEN
              SELECT pulse, rpp, airtimepp
          INTO unitpulse, unitprice, airtime
          FROM z_cellt
              WHERE bill.detime
          BETWEEN to_number(stime) AND to_number(etime)
          AND holflag = 1;
              cost := ((ceil(bill.dur/unitpulse)*unitprice) + (ceil(bill.dur/unitpulse)*airtime));
          ELSE
              SELECT pulse, rpp, airtimepp
          INTO unitpulse, unitprice, airtime
              FROM z_cellt
              WHERE bill.detime
              BETWEEN to_number(stime) AND to_number(etime)
          AND holflag = 0;
              cost := ((ceil(bill.dur/unitpulse)*unitprice) + (ceil(bill.dur/unitpulse)*airtime));
          END IF;
        ELSE
            ctype := 'L';
            SELECT  A.dest
        INTO destination
            FROM z_local A, z_zoning B
        WHERE to_number(bill.dialno,1,5)
            BETWEEN A.pref1 AND A.pref2
            AND A.zone = B.zone;
            IF bill.day = 'SUNDAY' THEN --OR bill.sdate = z_holiday.daydate THEN
              SELECT pulse, rpp
          INTO unitpulse, unitprice
              FROM z_zoning
              WHERE bill.detime
              BETWEEN to_number(fhour) AND to_number(lhour)
              AND holdflag = 1;
              cost := ceil(bill.dur/unitpulse)*unitprice;
            ELSE
              SELECT pulse, rpp
          INTO unitpulse, unitprice
              FROM z_zoning
              WHERE bill.detime
              BETWEEN to_number(fhour) AND to_number(lhour)
              AND holdflag = 0;
              cost := ceil(bill.dur/unitpulse)*unitprice;
            END IF;
        END IF;
      END IF;

      insert into z_bin (JASA,EXTNO,DIALNO,SDATE,STIME,DURATION,COST)
      values(ctype,bill.extno,bill.dialno,bill.sdate,bill.stime,bill.duration, cost);
  end loop;
  commit;
  close c1;
END;

thanx 4 ur attention, i really appreciated it

Collapse
Posted by Sebastiano Pilla on
Well... where exactly is line 71? And once you've identified that, post the definitions of the objects (tables, views, etc.) referenced from the erroneous line.
Collapse
Posted by Dirk Gomez on
You are trying to convert data from type foo to type bar and this conversion is not possible. In SQL queries Oracle (and PG) do implicit conversion so it may very well happen that one query runs fine for a long time and then stops working because you've added "erroneous" data.

What is in line 71? What is in your data? Do you apply some explicit or implicit conversion there?

Collapse
Posted by Brian Fenton on
What is the datatype of the city_name column on the z_city table? You're selecting it into the variable called destination. Destination is defined as a varchar2(30), so what is city_name?

If you're using SQL*Plus, the easiest way to get the line numbers is to type "list" (or just "l" for short) in the same session after you've compiled your PL/SQL. Line 71 in your text editor may not be the same as what Oracle thinks line 71 is!

By the way, http://tahiti.oracle.com/ is a great site for looking up Oracle error messages and documentation. Oracle have really made a fine effort to make their docs more available.

Collapse
Posted by toni montana on
hi, i don't have this problem, but i get the same error for the following code. it's on c#. NET with ODP.NET (oracle data provider for .NET).

my oracle table is :

create table artikel (
benname varchar2(15),
gebiet varchar2(30),
datum date,
text clob not null,
gelesen number,
primary key (benname,datum) );

using Oracle.DataAccess.Client;
using Oracle.DataAccess.Types;

...

private void Button1_Click(object sender, System.EventArgs e)
{
DateTime datum = new DateTime();
datum = DateTime.Now;

string ConStr = "User Id=user1;Password=bllablla;Data Source=localhost";
OracleConnection con = new OracleConnection(ConStr);
con.Open();
OracleCommand cmd = con.CreateCommand();
cmd.CommandText = "insert into artikel(benname, gebiet, datum,text,gelesen) values('ruki', :pGebiet, :pDate, :pText, 0 )";
cmd.CommandType = CommandType.Text;

OracleParameter prm = new OracleParameter("pDate",OracleDbType.Date);
OracleParameter prm1 = new OracleParameter("pText",OracleDbType.Clob);
OracleParameter prm2 = new OracleParameter("pGebiet",OracleDbType.Varchar2);

prm.Direction = ParameterDirection.Input;
prm1.Direction = ParameterDirection.Input;
prm2.Direction = ParameterDirection.Input;

prm.Value =  datum; // it works
prm1.Value =  TextBox1.Text; // it works
prm2.Value =  TextBox2.Text; // it doesn't work

cmd.Parameters.Add(prm);
cmd.Parameters.Add(prm1);
cmd.Parameters.Add(prm2);

cmd.ExecuteNonQuery();

}

...

it show's the following exception:

ORA-00932: inconsistent datatypes

Oracle.DataAccess.Client.OracleException:
ORA-00932:inconsistent datatypes

Line 81:             cmd.Parameters.Add(prm2);
Line 82:
Line 83:             cmd.ExecuteNonQuery(); // red (it shows that the problem occures here, but when i remove the parameter prm2, it works)

i hope that someone can help me.
THANKS

Collapse
6: A PO LODHENI (response to 5)
Posted by esat daku on
OKI