If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL0401N : operation "=" are not compatible

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-02-06, 09:03
lehare lehare is offline
Registered User
 
Join Date: Feb 2006
Posts: 13
SQL0401N : operation "=" are not compatible

i'm executing the below code with the command

db2 -td! -v -fmysqlcode.sql
_________________________________

connect to APPLE USER webuser using webuser!
CREATE PROCEDURE insert_event_f
(connector_id_p VARCHAR(40),
object_key_p VARCHAR(80),
object_name_p VARCHAR(40),
object_verb_p VARCHAR(40),
event_priority_p DECIMAL(5),
v_SimilarCounts DECIMAL)

LANGUAGE SQL

BEGIN
DECLARE tmp_object_verb VARCHAR(30);
set tmp_object_verb = object_verb_p;
set v_SimilarCounts = (select count(*) <-- LINE 16
FROM webuser.WBIA_EVENTS
WHERE object_name = object_name_p
AND object_verb = object_verb_p
AND object_key = object_key_p
AND event_status = 0);
<---what could be wrong with this?
IF object_verb_p = 'Physical Delete' THEN

DELETE FROM webuser.WBIA_EVENTS
WHERE object_name = object_name_p
AND object_key = object_key_p
AND event_status != 3;
set tmp_object_verb = 'Delete';
END IF;

IF (v_SimilarCounts = 0) THEN

INSERT INTO webuser.WBIA_EVENTS
( connector_id,
object_key,
object_name,
object_verb,
event_priority,
event_status)
VALUES
(connector_id_p,
object_key_p,
object_name_p,
tmp_object_verb,
event_priority_p,
0);
END IF;
RETURN(1);
END!
_______________________________________

but i get this anoying error:
_______________________________________
DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returnedQL0401N The data types of the operands for the operation "=" are not compatible. LINE NUMBER=16. SQLSTATE=42818

regards, lehare

Last edited by lehare; 03-02-06 at 09:08.
Reply With Quote
  #2 (permalink)  
Old 03-02-06, 09:37
Rob den Heijer Rob den Heijer is offline
Registered User
 
Join Date: Feb 2006
Location: Utrecht, Netherlands
Posts: 16
Ehrm... event_status is not character, maybe? I would find it rather funny if it is.
Reply With Quote
  #3 (permalink)  
Old 03-02-06, 09:39
timseal timseal is offline
Registered User
 
Join Date: May 2002
Location: Philadelphia, PA
Posts: 14
try SELECT COUNT(*) INTO v_SimilarCounts FROM webuser.WBIA_EVENTS etc...

also, I don't know for sure, but wouldn't the != be a problem when using ! as a command terminator?
Reply With Quote
  #4 (permalink)  
Old 03-02-06, 09:44
Rob den Heijer Rob den Heijer is offline
Registered User
 
Join Date: Feb 2006
Location: Utrecht, Netherlands
Posts: 16
ah, that's the problem...

It's indeed the " ! "
and so it's not line 16, but line 26. Use <> instead.

cheers,
Rob.
Reply With Quote
  #5 (permalink)  
Old 03-02-06, 10:19
lehare lehare is offline
Registered User
 
Join Date: Feb 2006
Posts: 13
................................posted twise

Last edited by lehare; 03-02-06 at 10:23.
Reply With Quote
  #6 (permalink)  
Old 03-02-06, 10:19
lehare lehare is offline
Registered User
 
Join Date: Feb 2006
Posts: 13
i changed the code to

connect to APPLE USER webuser using webuser@
CREATE PROCEDURE insert_event_f
(connector_id_p VARCHAR(40),
object_key_p VARCHAR(80),
object_name_p VARCHAR(40),
object_verb_p VARCHAR(40),
event_priority_p DECIMAL(5),
v_SimilarCounts INTEGER)
LANGUAGE SQL

BEGIN
DECLARE tmp_object_verb VARCHAR(30);
set tmp_object_verb = object_verb_p;

select count(*) INTO v_SimilarCounts
FROM WBIA_EVENTS
WHERE object_name = object_name_p
AND object_verb = object_verb_p
AND object_key = object_key_p
AND event_status = 0;
IF object_verb_p = 'Physical Delete' THEN

DELETE FROM WBIA_EVENTS
WHERE object_name = object_name_p
AND object_key = object_key_p
AND event_status <> 3;
set tmp_object_verb = 'Delete';
END IF;

IF (v_SimilarCounts = 0) THEN

INSERT INTO WBIA_EVENTS
( connector_id,
object_key,
object_name,
object_verb,
event_priority,
event_status)
VALUES
(connector_id_p,
object_key_p,
object_name_p,
tmp_object_verb,
event_priority_p,
0);
END IF;
RETURN(1);

END@

______________________

used the @ [as a terminator], and replaced line 26 from ' != ' to ' <> ' and changed line 14 to (select count(*) INTO etc ...

but i still get EXACTLY the same error

by the way i'm using windows 2000 [fixpac 4], db2 version 8.1.8
Reply With Quote
  #7 (permalink)  
Old 03-02-06, 10:26
Rob den Heijer Rob den Heijer is offline
Registered User
 
Join Date: Feb 2006
Location: Utrecht, Netherlands
Posts: 16
Start eliminating

Maybe it's not the content of line 16; it could be something else.
If you (for test purposes) leave out "AND event_status = 0"
and retry, is it still protesting, and does it now point to line number 15?

Very often the nature of the error message is misleading - please check!
cheers,
Rob.
Reply With Quote
  #8 (permalink)  
Old 03-08-06, 10:02
timseal timseal is offline
Registered User
 
Join Date: May 2002
Location: Philadelphia, PA
Posts: 14
Post the DDL, it could be a type conversion thing.
Reply With Quote
  #9 (permalink)  
Old 03-09-06, 07:35
atinjain05 atinjain05 is offline
Registered User
 
Join Date: Mar 2006
Location: UK
Posts: 8
save below code in a file as file.sql

and run db2 -tvf file.sql

I hope this will work



connect to APPLE USER webuser using webuser;
CREATE PROCEDURE insert_event_f
(connector_id_p VARCHAR(40),
object_key_p VARCHAR(80),
object_name_p VARCHAR(40),
object_verb_p VARCHAR(40),
event_priority_p DECIMAL(5),
v_SimilarCounts DECIMAL)

LANGUAGE SQL

BEGIN
DECLARE tmp_object_verb VARCHAR(30);
set tmp_object_verb = object_verb_p;
set v_SimilarCounts = (select count(*) FROM webuser.WBIA_EVENTS
WHERE object_name = object_name_p
AND object_verb = object_verb_p
AND object_key = object_key_p
AND event_status = 0);
IF object_verb_p = 'Physical Delete' THEN

DELETE FROM webuser.WBIA_EVENTS
WHERE object_name = object_name_p
AND object_key = object_key_p
AND event_status != 3;
set tmp_object_verb = 'Delete';
END IF;

IF (v_SimilarCounts = 0) THEN

INSERT INTO webuser.WBIA_EVENTS
( connector_id,
object_key,
object_name,
object_verb,
event_priority,
event_status)
VALUES
(connector_id_p,
object_key_p,
object_name_p,
tmp_object_verb,
event_priority_p,
0);
END IF;
RETURN(1);
END;
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On