Subject Re: [IBO] TIBOQuery sample?
Author Ronan van Riet
Hello Helen,

First of all let me thank you very much for posting the example for
TIBOQuery !! I ran it and saw it works fine.

Now I am trying to adapt your code and I am only able to get a dataset
returned. I manually inserted a record and it is being shown in the DBGrid.
I cannot INSERT any record. The error message I get is 'Invalid custom DML
reference WWWROW_ID.

I have defined all (for SELECT and INSERT) the input parameters in Delphi

But what is causing the Invalid custom DML reference WWWROW_ID?

I hope you can help me. Please let me know if you need anything clarified.

Kind regards and thanks,
Ronan van Riet

The INSERTSQL I want to use is

EXECUTE PROCEDURE INS_OR_UPD_OR_DEL_E_PROJECT('N', :WWWROW_ID, :WWWCON_ID,
:WWWDESC_TEXT, :WWWCAD, :WWWPROJECT, :WWWPROJECTTYPE)

I have the DDL for that SP defined as

CREATE PROCEDURE INS_OR_UPD_OR_DEL_E_PROJECT(
WWWDEL CHAR(1),
WWWROW_ID INTEGER,
WWWCON_ID INTEGER,
WWWDESC_TEXT VARCHAR(255),
WWWCAD BLOB SUB_TYPE 0 SEGMENT SIZE 80,
WWWPROJECT BLOB SUB_TYPE 0 SEGMENT SIZE 80,
WWWPROJECTTYPE VARCHAR(30))
RETURNS (
O_ROW_ID INTEGER)
AS
DECLARE VARIABLE ID INTEGER;
BEGIN
IF (:WWWDEL = 'Y') THEN -- really an UPDATE
UPDATE E_PROJECT
SET ACTIVE_FLG = 'N'
WHERE ROW_ID = :wwwROW_ID;
ELSE
BEGIN -- INSERT
IF (EXISTS (
SELECT 1 FROM E_PROJECT
WHERE ROW_ID = :wwwROW_ID)) THEN
UPDATE E_PROJECT
SET PROJECT = :wwwPROJECT
WHERE ROW_ID = :wwwROW_ID;
ELSE
IF (wwwROW_ID IS NULL) THEN BEGIN
id = GEN_ID(GEN_E_PROJECT_ROW_ID, 1);

INSERT INTO E_PROJECT (CREATED_BY, LAST_UPD_BY, CST_CON_ID,
DESC_TEXT, CAD, PROJECT, PROJECTTYPE)
VALUES (:wwwCON_ID, :wwwCON_ID, :wwwCON_ID, :wwwDESC_TEXT, :wwwCAD,
:wwwPROJECT, :wwwPROJECTTYPE);
end
ELSE
INSERT INTO E_PROJECT (ROW_ID, CREATED_BY, LAST_UPD_BY, CST_CON_ID,
DESC_TEXT, CAD, PROJECT, PROJECTTYPE)
VALUES (:id, :wwwCON_ID, :wwwCON_ID, :wwwCON_ID, :wwwDESC_TEXT, :wwwCAD,
:wwwPROJECT, :wwwPROJECTTYPE);
O_ROW_ID = id;
END
END

My SQL for the select looks like

SELECT O_ROW_ID, O_CREATED, O_CREATED_BY, O_LAST_UPD, O_LAST_UPD_BY,
O_PROJECTTYPE, O_DESC_TEXT, O_STAGE, O_CALCDATE
FROM GET_MY_PROJECTS(:WWWCON_ID)

My DDL for the select looks like

CREATE PROCEDURE GET_MY_PROJECTS(
WWWCON_ID INTEGER)
RETURNS (
O_ROW_ID INTEGER,
O_CREATED DATE,
O_CREATED_BY VARCHAR(50),
O_LAST_UPD DATE,
O_LAST_UPD_BY VARCHAR(50),
O_PROJECTTYPE VARCHAR(30),
O_DESC_TEXT VARCHAR(10),
O_STAGE INTEGER,
O_CALCDATE INTEGER)
AS
BEGIN
-- IF (WWWROW_ID = -1) THEN BEGIN
/* FOR SELECT prj.ROW_ID,
prj.created, creator.fst_name || ' ' || creator.last_name,
prj.last_upd, updator.fst_name || ' ' || updator.last_name,
prj.projecttype, prj.desc_text, prj.stage, prj.calcdate
FROM E_PROJECT prj,
E_CONTACT creator,
E_CONTACT updator
WHERE prj.created_by = creator.row_id
AND prj.last_upd_by = updator.row_id
AND prj.cst_con_id = :WWWCON_ID
AND prj.Active_FLG = 'Y'
ORDER BY prj.last_upd desc
INTO :o_ROW_ID, :o_created, :o_created_by, :o_last_upd, :o_Last_Upd_by,
:o_projecttype, :o_desc_text, :o_stage, :o_Calcdate DO
SUSPEND;
/*
END
ELSE BEGIN
*/
SELECT prj.ROW_ID,
prj.created, creator.fst_name || ' ' || creator.last_name,
prj.last_upd, updator.fst_name || ' ' || updator.last_name,
prj.projecttype, prj.desc_text, prj.stage, prj.calcdate
FROM E_PROJECT prj,
E_CONTACT creator,
E_CONTACT updator
WHERE prj.created_by = creator.row_id
AND prj.last_upd_by = updator.row_id
AND prj.cst_con_id = :wwwCON_ID
AND prj.Active_FLG = 'Y'
ORDER BY prj.last_upd desc
INTO :o_ROW_ID, :o_created, :o_created_by, :o_last_upd, :o_Last_Upd_by,
:o_projecttype, :o_desc_text, :o_stage, :o_Calcdate;
SUSPEND;
-- END
END