Field not found

Field not found

Postby clayshannon » Mon 09 Jan 2006 17:12

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).
clayshannon
 
Posts: 6
Joined: Mon 09 Jan 2006 17:05
Location: Waterford, WI

Postby clayshannon » Mon 09 Jan 2006 17:27

On second check, the ID field is NOT autoinc--I set it as such, but it in actually is not--and will apparently not allow me now to make it such. I don't know if this has anything to do with the problem...
clayshannon
 
Posts: 6
Joined: Mon 09 Jan 2006 17:05
Location: Waterford, WI

Postby Ikar » Tue 10 Jan 2006 09:04

Please specify q_LifeSafety.SQL property value.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Postby clayshannon » Tue 10 Jan 2006 14:21

Ikar wrote:Please specify q_LifeSafety.SQL property value.


It is:

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)
clayshannon
 
Posts: 6
Joined: Mon 09 Jan 2006 17:05
Location: Waterford, WI

Postby Ikar » Tue 10 Jan 2006 16:23

> 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.
Ikar
 
Posts: 1693
Joined: Thu 28 Oct 2004 13:56

Postby clayshannon » Tue 10 Jan 2006 16:27

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.


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.
clayshannon
 
Posts: 6
Joined: Mon 09 Jan 2006 17:05
Location: Waterford, WI


Return to MySQL Data Access Components