I'm pulling my hair out:
Maintaining an existing/legacy app that uses the TMyQuery components. I'm getting a "Field not found" error with the following code:
q_LifeSafety.Insert;
q_LifeSafety.FieldByName('WORKORDER_ID').AsInteger := AWorkOrderID; //<--Field 'WORKORDER_ID' not found
...
q_LifeSafety.Post;
although there is existing code for another TMyQuery component and table that follows this same pattern and works just fine.
q_LifeSafety is a TMyQuery component that has the following Insert statement:
INSERT INTO pm_data.workorders_islms
(ID, WORKORDER_ID, ILSM_MATRIX_CELL, CREATED, CREATED_BY)
VALUES
(:ID, :WORKORDER_ID, :ILSM_MATRIX_CELL, :CREATED, :CREATED_BY)
The error occurs with or without the ID values being there (ID is an autoinc field).
Field not found
-
- Posts: 6
- Joined: Mon 09 Jan 2006 17:05
- Location: Waterford, WI
-
- Posts: 6
- Joined: Mon 09 Jan 2006 17:05
- Location: Waterford, WI
It is:Ikar wrote:Please specify q_LifeSafety.SQL property value.
SELECT count(id) FROM pm_data.workorders_islms
WHERE WORKORDER_ID = :WORKORDER_ID
But once I call select, the Insert statement should be used, right? The SQLInsert statement is:
INSERT INTO workorders_islms
(ID, WORKORDER_ID, ILSM_MATRIX_CELL, CREATED, CREATED_BY)
VALUES
(:ID, :WORKORDER_ID, :ILSM_MATRIX_CELL, :CREATED, :CREATED_BY)
> SELECT count(id) FROM pm_data.workorders_islms
> WHERE WORKORDER_ID = :WORKORDER_ID
This statement really doesn't return WORKORDER_ID field.
> But once I call select, the Insert statement should be used, right?
No, in most cases you should write SELECT * FROM pm_data.workorders_islms in SQL property and leave SQLInsert blank. You can read details in MyDAC help or see in MyDAC demos.
> WHERE WORKORDER_ID = :WORKORDER_ID
This statement really doesn't return WORKORDER_ID field.
> But once I call select, the Insert statement should be used, right?
No, in most cases you should write SELECT * FROM pm_data.workorders_islms in SQL property and leave SQLInsert blank. You can read details in MyDAC help or see in MyDAC demos.
-
- Posts: 6
- Joined: Mon 09 Jan 2006 17:05
- Location: Waterford, WI
This seems bizarre to me. Thanks for your help, but I've replaced the whole shebang with a Firebird table, and it works as I'm accustomed.Ikar wrote:> SELECT count(id) FROM pm_data.workorders_islms
> WHERE WORKORDER_ID = :WORKORDER_ID
This statement really doesn't return WORKORDER_ID field.
I wasn't expecting it to. I want to see if there is such a record. If the value returned is 0, a record with that workorder_id exists.
> But once I call select, the Insert statement should be used, right?
No, in most cases you should write SELECT * FROM pm_data.workorders_islms in SQL property and leave SQLInsert blank. You can read details in MyDAC help or see in MyDAC demos.