Thread: new user
View Single Post
  #6 (permalink)  
Old 01-09-09, 02:00
y.dharmesh y.dharmesh is offline
Registered User
 
Join Date: Jan 2009
Posts: 5
error in procedure

Again Thanks,

Now I an trying to create a function,

I have a table
CREATE TABLE teste_one
( one DECIMAL(10,0),
two DECIMAL(10,0)
)

I have single row and row value is one=3 and two=4 in this table.

CREATE PROCEDURE informix.test
( ones numeric(10,0))

returning numeric(10,0);
BEGIN

DEFINE PSQL_ERROR INTEGER;
DEFINE PISAM_ERROR INTEGER;
DEFINE PERROR_TEXT CHAR(72);
DEFINE PPROC_NAME CHAR(18);
DEFINE PERROR_REMARK VARCHAR(20);
DEFINE PERROR_RET INTEGER;
DEFINE LReturnStatus INTEGER;
DEFINE LDebtorID INTEGER;
DEFINE LAccountID SMALLINT;
DEFINE LPartyType CHAR(1);
DEFINE LPartyID SMALLINT;
DEFINE LPhone1 numeric(10,0);

DEFINE Conditions CHAR(120);


-- Exception block.
ON EXCEPTION SET PSQL_ERROR, PISAM_ERROR, PERROR_TEXT
-- Log into error table
LET PERROR_REMARK = " Database operation failed." ||
" SQLCODE = " || PSQL_ERROR ||
" ISAM_ERROR = " || PISAM_ERROR ||
" ERROR_TEXT = " || PERROR_TEXT;
-- Ignore DebtorID, AccountID in the error log table

RAISE EXCEPTION PSQL_ERROR, PISAM_ERROR, PERROR_TEXT;
END EXCEPTION

SET DEBUG FILE TO "c:/updvbsphonelist.dbg";
TRACE ON;

let LPhone1=0;

if ones=3 then
LET Conditions = " and one= 3 ";
else
LET Conditions = "and one= 5 ";
end if

SELECT two INTO LPhone1 from teste_one where 1=1|| conditions;


return LPhone1;

END;
END PROCEDURE;


it created successfully. But when i use this in sql query I found on error

" 10:55:06 [SELECT - 0 row(s), 0.000 secs] [Error Code: -1213, SQL State: IX000] Character to numeric conversion error
... 1 statement(s) executed, 0 row(s) affected, exec/fetch time: 0.000/0.000 sec [0 successful, 0 warnings, 1 errors]"

Could you please let me know is it possible in informix. if not then please let me know any alternate of this.

Previously I was working in ORACLE and it was possible in ORACLE.
Reply With Quote