Problem with WEB Data Blade 3.3
Posted in 1998
Topics: Stored Procedures & SPL, Server Administration, Triggers, Constraints & Referential Integrity
I've written two stored procedures, and I have two problems:
1/ Can the "sub_string" procedure can be re-written more
simply ? (if you have a solution, but it is not very
important for the moment).
2/ Called with DBACCESS (on Unix), that works well, but in a
<?MISQL> statement, that produces an exception from Informix:
"XIX000:-675:Illegal SQL statement in stored procedure."
What is the problem ????
-- ============================================================
-- Table : AASQA_UTER
-- ============================================================
create table AASQA_UTER
(
IUTER INTEGER not null,
IAASQA INTEGER not null
);
-- ============================================================
-- Index : PK_AASQA_UTER
-- ============================================================
create unique index PK_AASQA_UTER on AASQA_UTER (IUTER asc, IAASQA asc);
{
Notes:
-----
- There are foreign keys on AASQA_UTER (for columns IUTER and IAASQA)
but I don't think it's the problem!
- The table (and the stored procedure) is not is the same database
than the AppPages of the Web DataBlade, in HTML the stored proc
is called: EXECUTE PROCEDURE extprod:WebInsertUter( 4, "28,101" );
}
-- DROP PROCEDURE sub_string;
-- DROP PROCEDURE WebInsertUter;
CREATE PROCEDURE sub_string(chaine CHAR(255), rang INT)
RETURNING char(1);DEFINE c CHAR(1);
IF LENGTH( chaine ) < rang THEN
RETURN " ";
END IF;
if rang = 1 then return chaine[1]; end if;
if rang = 2 then let c = chaine[2]; end if;
if rang = 3 then let c = chaine[3]; end if;
if rang = 4 then let c = chaine[4]; end if;
if rang = 5 then let c = chaine[5]; end if;
if rang = 6 then let c = chaine[6]; end if;
if rang = 7 then let c = chaine[7]; end if;
if rang = 8 then let c = chaine[8]; end if;
if rang = 9 then let c = chaine[9]; end if;
if rang = 10 then let c = chaine[10]; end if;
if rang = 11 then let c = chaine[11]; end if;
if rang = 12 then let c = chaine[12]; end if;
if rang = 13 then let c = chaine[13]; end if;
if rang = 14 then let c = chaine[14]; end if;
if rang = 15 then let c = chaine[15]; end if;
if rang = 16 then let c = chaine[16]; end if;
if rang = 17 then let c = chaine[17]; end if;
if rang = 18 then let c = chaine[18]; end if;
if rang = 19 then let c = chaine[19]; end if;
if rang = 20 then let c = chaine[20]; end if;
if rang = 21 then let c = chaine[21]; end if;
if rang = 22 then let c = chaine[22]; end if;
if rang = 23 then let c = chaine[23]; end if;
if rang = 24 then let c = chaine[24]; end if;
if rang = 25 then let c = chaine[25]; end if;
if rang = 26 then let c = chaine[26]; end if;
{ and so on ... }
if rang = 255 then let c = chaine[255]; end if;
RETURN c;
END PROCEDURE;
CREATE PROCEDURE WebInsertUter( id INT, LST CHAR(255))DEFINE i SMALLINT;
define l smallint;
define v int;
define c char(1);
LET v = 0;
LET l = length(lst);
FOR i = 1 to l
LET c = sub_string(lst,i);
IF c != " " THEN
IF (c != ",") THEN
LET v = v * 10 + c;
ELSE
INSERT INTO aasqa_uter (iaasqa, iuter) VALUES( id, v ); LET v = 0;
END IF;
END IF;
END FOR;
IF v > 0 THEN
INSERT INTO aasqa_uter (iaasqa, iuter) VALUES( id, v ); END IF;
END PROCEDURE;
SELECT * FROM aasqa_uter ;
BEGIN WORK;
DELETE FROM aasqa_uter WHERE iaasqa = 4;
INSERT INTO aasqa_uter (iaasqa, iuter) VALUES (4, 11 );
EXECUTE PROCEDURE WebInsertUter( 4, "28,101" );
COMMIT WORK ;
SELECT * FROM aasqa_uter ;
---------------------------------------------------------------
Thanks a lot for your HELP!
__________________________________________
William REY
csii@iway.fr
http://www.teamlog.fr/
__________________________________________
Related threads
- RE: database market share 2003
- Re: IBM Informix Dynamic Server Version 11.10.UB4TL on SuSE
- US-DC-Senior Sys Eng INFORMIX
- DC Area PowerBuilder Lead Programmer