Subject | DSQL Behaviour |
---|---|
Author | Mark Lawes |
Post date | 2004-04-12T13:19:23Z |
I am having a look at IB Objects via the demo download, mostly for interest sake. I am hoping someone can explain why the following behaviour occurs. Apologies in advance if this is a stupid question.
I am using a DSQL component to run a singleton query which will return the key of a row if a given field matches my input parameter. All the prerequisites like connecting to the database have been performed.
The sql for the DSQL component looks like this:-
SELECT OBJID FROM TABLE_ACCOUNTS WHERE ACCOUNT_NAME = :NEWNAME
OBJID is the primary key value.
I prepare the query.
Then I set the parameter to a value to search for using:-
ParamByName('NEWNAME').AsString := AccName where AccName is a simple string containing the searched for account name.
I then execute the DSQL by calling the Execute method.
If there is a matching row then I get property RowsSelected = 1
If there is no matching row an exception occurs:-
'Attempt to fetch past the last record in a record stream'
This exception occurs during the Execute as far as I can tell. My next statement which looks at the value of RowsSelected is never executed.
What I expected to happen was that the value of the RowsSelected property would be = 0 rather than an exception.
Is this expected behaviour or have I missed something ? If expected behaviour then can I expect an exception to occur if I run SQL in other components that generate no selected rows ?
Mark Lawes
[Non-text portions of this message have been removed]
I am using a DSQL component to run a singleton query which will return the key of a row if a given field matches my input parameter. All the prerequisites like connecting to the database have been performed.
The sql for the DSQL component looks like this:-
SELECT OBJID FROM TABLE_ACCOUNTS WHERE ACCOUNT_NAME = :NEWNAME
OBJID is the primary key value.
I prepare the query.
Then I set the parameter to a value to search for using:-
ParamByName('NEWNAME').AsString := AccName where AccName is a simple string containing the searched for account name.
I then execute the DSQL by calling the Execute method.
If there is a matching row then I get property RowsSelected = 1
If there is no matching row an exception occurs:-
'Attempt to fetch past the last record in a record stream'
This exception occurs during the Execute as far as I can tell. My next statement which looks at the value of RowsSelected is never executed.
What I expected to happen was that the value of the RowsSelected property would be = 0 rather than an exception.
Is this expected behaviour or have I missed something ? If expected behaviour then can I expect an exception to occur if I run SQL in other components that generate no selected rows ?
Mark Lawes
[Non-text portions of this message have been removed]