Result set returns only one record
Posted: 08.08.2007, 16:35
A very silly question and something that I have done which worked and now it seems that I am completely stumped when trying to do the same thing again.
On the database I have a stored procedure (FetchRoles) which looks like this:
[font=Courier New]PROCEDURE FetchRoles(
UserId CHAR(10))
RETURNS(
RoleCode CHAR(8),
RoleDesc VARCHAR(25))
AS
BEGIN
FOR
SELECT user_role, user_code
FROM user_roles, app_users
WHERE user_role.role_code = app_users.user_code
AND app_user.user_id = :UserId
AND app_user.user_status = ‘Active’
DO
SUSPEND;
END^;[/font]
When calling the procedure using ZStoredProcedure (ZEOSLIB 6.6.1) with the following code the ResultSet returned contains only one record. In the database itself there are three records. The Delphi code looks like this:
The DataModule contains all the components (in this case the TZConnection component and a TZStoredProcedure component).
[font=Courier New]
with datamod.spFetchRoles do
begin
Close;
Params[0].Value := editUserName.Text;
Open;
DbcResultSet.First
comboRoles.Items.Add(DbcResultSet.GetString(2));
while not DbcResultSet.Last do
begin
comboRoles.Items.Add(DbcResultSet.GetString(2));
DbcResultSet.Next;
end;
end;[/font]
The combo box has only one item within the list whereas the database has three entries that matches the UserName parameter. Is there something I am missing trying to get all the records? Again, any help would be greatly appreciated.
On the database I have a stored procedure (FetchRoles) which looks like this:
[font=Courier New]PROCEDURE FetchRoles(
UserId CHAR(10))
RETURNS(
RoleCode CHAR(8),
RoleDesc VARCHAR(25))
AS
BEGIN
FOR
SELECT user_role, user_code
FROM user_roles, app_users
WHERE user_role.role_code = app_users.user_code
AND app_user.user_id = :UserId
AND app_user.user_status = ‘Active’
DO
SUSPEND;
END^;[/font]
When calling the procedure using ZStoredProcedure (ZEOSLIB 6.6.1) with the following code the ResultSet returned contains only one record. In the database itself there are three records. The Delphi code looks like this:
The DataModule contains all the components (in this case the TZConnection component and a TZStoredProcedure component).
[font=Courier New]
with datamod.spFetchRoles do
begin
Close;
Params[0].Value := editUserName.Text;
Open;
DbcResultSet.First
comboRoles.Items.Add(DbcResultSet.GetString(2));
while not DbcResultSet.Last do
begin
comboRoles.Items.Add(DbcResultSet.GetString(2));
DbcResultSet.Next;
end;
end;[/font]
The combo box has only one item within the list whereas the database has three entries that matches the UserName parameter. Is there something I am missing trying to get all the records? Again, any help would be greatly appreciated.