jammula
09-24-2003, 03:38 PM
Hi all,
Forms version 6i and database 8i
I have a situation that I have a Table name "EMP"
I need to do create a multilevel items and display 20 records per page
My layout is execute all records
Checkbox Empno, Empname, Sal, Hiredate and Scrollbar
1
2
3
4
5
6
Delete---Button
If user selects like checkboxes next to 2,3,5
when user press the Delete button those 3 records which are checked should be deleted from database based on Empno
any code is helpful
Thanks
stecal
09-24-2003, 04:23 PM
You can use this code snippet to get an idea how to loop through records - this is from a form that assigns roles to users.
-- Changing a role only
IF (:user_acc.password IS NULL AND failed_validation = FALSE) THEN
good_password := 0;
END IF;
-- Check for at least one User Role assignment
go_block( 'user_roles' );
-- Loop thru records and make sure at least one is checked
First_Record;
LOOP
IF (:user_roles.assigned = 'Y' ) THEN
role_set := TRUE;
END IF;
EXIT when :system.last_record = 'TRUE';
Next_Record;
END LOOP;
-- If all roles were deleted raise Alert
IF (role_set = FALSE ) THEN
RAISE no_role;
END IF;
First_Record;
LOOP -- Loop thru each role assignment
-- If user CHECKS a Role --> box ON
IF ( :user_roles.assigned = 'Y' and :user_roles.old_assigned = 'N') THEN
forms_ddl( 'grant ' || :user_roles.role || ' to ' || :user_acc.user_acc );
IF not Form_Success THEN
MESSAGE ( 'ERROR: GRANT ' || :user_roles.role || ' TO USER '
|| :user_acc.user_acc || ' FAILED !!!' );
RAISE form_trigger_failure;
END IF;
EXIT when :system.last_record = 'TRUE';
Next_Record;
-- If user UNCHECKS box
ELSE
IF ( :user_roles.assigned = 'N' and :user_roles.old_assigned = 'Y' ) THEN
forms_ddl( 'revoke ' || :user_roles.role || ' from ' || :user_acc.user_acc );
IF not Form_Success THEN
MESSAGE ( 'ERROR: REVOKE ' || :user_roles.role || ' FROM USER '
|| :user_acc.user_acc || ' FAILED !!!' );
RAISE form_trigger_failure;
END IF;
END IF;
EXIT when :system.last_record = 'TRUE';
Next_Record;
END IF;
END LOOP;
validate_all_blocks;
change_default_license;
go_item ( 'user_acc.user_acc' );
IF (good_password > 0 OR failed_validation = TRUE OR role_set = FALSE) THEN
MESSAGE ('Account for user ' || :user_acc.user_acc || ' was not modified.');
ELSE
MESSAGE ('Modified user ' || :user_acc.user_acc || ', transaction complete.');
END IF;
ELSE
MESSAGE ( 'ERROR: USER ' || :user_acc.user_acc || ' DOES NOT EXIST !!!' );