Subject | Re: [IBO] TIBOQuery sample? [updated] |
---|---|
Author | Ronan van Riet |
Post date | 2004-01-30T22:28:58Z |
Sorry, list - my email was sent out prematurely.
I am only using the DBGrid as a santiy check. The parameter I am using do
not match so I would never be able to do an INSERT, correct?
But my problem is still there when I am using the following.
My app is a WebHub web application. If the moderator tells me I will kindly
take this discussion to the WebHub list.
The following procedure is called by WebHub's TWebDataScan, which calls the
<TDataset>.open, which in turn calls:
procedure TDataModule2.IBO_QRY_GET_MY_PROJECTSBeforeOpen(DataSet: TDataSet);
// we are using dataset cloning so we MUST 'go through'
webdatasource.dataset
begin
with TIBOQuery(wdsGET_MY_PROJECTS.DataSet), pWebApp do begin
if Active then Close;
if not Prepared then Prepare;
ParamByName('wwwCON_ID').Value := Literal['CST_CON_ID'];
end;
end;
A WebHub TWebaction component is responsible for the insert
procedure TDataModule2.waProjectExplorerNewProject(Sender: TWebTreeview;
value1, value2: String);
with IBO_QRY_GET_MY_PROJECTS do begin
if not prepared then prepare;
ParamByName('wwwROW_ID').Value := '-1'; // dummy we are doing an
INSERT
ParamByName('wwwCON_ID').Value := Literal['CST_CON_ID'];
ParamByName('wwwDESC_TEXT').Value := value1;
ParamByName('wwwProjectType').Value := Literal['sbProjectType'];
try
tWebTreeview(sender).treeview.SaveFileToBlob(a0,
TIB_ColumnBlob(ParamByName('wwwCAD')));
except
// RVR 07JAN2003 exception handling!
end;
if not assigned(ParamByName('wwwCAD')) then
ParamByName('wwwCAD').Clear; //ensures empty blob is null
try
tWebTreeview(sender).treeview.SaveTreeviewToBlob(tWebTreeview(sender).treevi
ew, TIB_ColumnBlob(ParamByName('wwwProject')));
except
// RVR 07JAN2003 exception handling!
end;
if not assigned(ParamByName('wwwProject')) then
ParamByName('wwwProject').Clear; //ensures empty blob is null
end;
IBO_QRY_GET_MY_PROJECTS.Insert;
end;
Thanks,
Ronan van Riet
I am only using the DBGrid as a santiy check. The parameter I am using do
not match so I would never be able to do an INSERT, correct?
But my problem is still there when I am using the following.
My app is a WebHub web application. If the moderator tells me I will kindly
take this discussion to the WebHub list.
The following procedure is called by WebHub's TWebDataScan, which calls the
<TDataset>.open, which in turn calls:
procedure TDataModule2.IBO_QRY_GET_MY_PROJECTSBeforeOpen(DataSet: TDataSet);
// we are using dataset cloning so we MUST 'go through'
webdatasource.dataset
begin
with TIBOQuery(wdsGET_MY_PROJECTS.DataSet), pWebApp do begin
if Active then Close;
if not Prepared then Prepare;
ParamByName('wwwCON_ID').Value := Literal['CST_CON_ID'];
end;
end;
A WebHub TWebaction component is responsible for the insert
procedure TDataModule2.waProjectExplorerNewProject(Sender: TWebTreeview;
value1, value2: String);
with IBO_QRY_GET_MY_PROJECTS do begin
if not prepared then prepare;
ParamByName('wwwROW_ID').Value := '-1'; // dummy we are doing an
INSERT
ParamByName('wwwCON_ID').Value := Literal['CST_CON_ID'];
ParamByName('wwwDESC_TEXT').Value := value1;
ParamByName('wwwProjectType').Value := Literal['sbProjectType'];
try
tWebTreeview(sender).treeview.SaveFileToBlob(a0,
TIB_ColumnBlob(ParamByName('wwwCAD')));
except
// RVR 07JAN2003 exception handling!
end;
if not assigned(ParamByName('wwwCAD')) then
ParamByName('wwwCAD').Clear; //ensures empty blob is null
try
tWebTreeview(sender).treeview.SaveTreeviewToBlob(tWebTreeview(sender).treevi
ew, TIB_ColumnBlob(ParamByName('wwwProject')));
except
// RVR 07JAN2003 exception handling!
end;
if not assigned(ParamByName('wwwProject')) then
ParamByName('wwwProject').Clear; //ensures empty blob is null
end;
IBO_QRY_GET_MY_PROJECTS.Insert;
end;
Thanks,
Ronan van Riet
----- Original Message -----
From: "Ronan van Riet" <ronanvanriet@...>
To: <IBObjects@yahoogroups.com>
Sent: Friday, January 30, 2004 11:07 PM
Subject: Re: [IBO] TIBOQuery sample?
> 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
>