Mandatory Values/LOV Prohibited values [message #550238] |
Sat, 07 April 2012 10:33 |
|
vinni
Messages: 34 Registered: March 2012
|
Member |
|
|
Hello,
I created a list of values for the purpose of showing what unit_codes are selectable for a student's course. Each selected value gets dumped into the text field on my form.
But i was wondering, is there a way to show what unit_codes(values) are mandatory? And is there a way to show which ones are prohibited depending on data inside the database?
|
|
|
Re: Mandatory Values/LOV Prohibited values [message #550241 is a reply to message #550238] |
Sat, 07 April 2012 11:28 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Mandatory unit_codes can be displayed in List of Values; you'd include that information into the SELECT column list. For example (as you didn't provide test case), if UNIT_CODES table contains UNIT_CODE, UNIT_NAME, MANDATORY columns, List of Values would look likeselect unit_code, unit_name, mandatory
from unit_codes
where ...
Prohibited unit_codes should not be displayed at all - in order to do that, you'd include a condition that restricts these values into SELECT statement's WHERE clause, such as
...
where unit_code not in (select unit_code
from prohibited_unit_codes
where ...
)
The above is just an idea; actual solution probably depends on information you know (but we do not).
|
|
|
Re: Mandatory Values/LOV Prohibited values [message #550242 is a reply to message #550241] |
Sat, 07 April 2012 12:00 |
|
vinni
Messages: 34 Registered: March 2012
|
Member |
|
|
My apologies, I should have been WAAAYY more specific. There are no fields on my database to show whether unit codes are mandatory or prohibited.
Below is my units table. The unit codes from this table.....
Create table Units(
unit_code varchar2 (11) constraint pk_Units primary key,
unit_name varchar2(50) not null;
... will be selected into this table as follows...
Create table listofinserts(
insertion_id number constraint pk_listofinserts primary key,
person_id number(8) constraint fk_Persons references Persons (person_id),
unit_code varchar2(11) constraint fk_Units references Units (unit_code));
...... but in some cases a unit_code may not be selectable because the person will require a 'pass' in one or more
prerequisite units
and heres my grades table which i showed in another message some time ago
Create table Grades(
grade_code number constraint pk_Grades primary key,
grade varchar(4) check (result in ('fail','pass')),
person_id number,
unit_code varchar2,
CONSTRAINT fk_Persons FOREIGN KEY (person_id) REFERENCES Persons (person_id),
CONSTRAINT fk_Units FOREIGN KEY (unit_code) REFERENCES Units (unit_code));
for the moment im more concerned with prohibiting specific values on my LOV from being selected... is there a way?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Mandatory Values/LOV Prohibited values [message #550263 is a reply to message #550261] |
Sat, 07 April 2012 15:49 |
|
vinni
Messages: 34 Registered: March 2012
|
Member |
|
|
heres some sample data in my prerequisites table
INSERT INTO Prerequisites (preunit_code, unit_code)
VALUES
('MATHS010101', 'MATHS020202');
INSERT INTO Prerequisites (preunit_code, unit_code)
VALUES
('MUSIC010101', 'MUSIC020202');
**those rnadom numbers are there to make it easier to define which unit is more advanced
now those "preunit_code"s are also "unit_codes" for the units table. and it will be those that are used in the grades table just to state what grade a person got in that unit.
some sample data for my grades table:
INSERT INTO Grades (grade_code, grade, person_id, unit_code)
VALUES
(Grades_seq.NEXTVAL, 'pass','12345678','MUSIC010101');
INSERT INTO Grades (result_id, result, person_id, module_id)
VALUES
(Grades_seq.NEXTVAL, 'fail','12345678','MATHS010101');
now as shown above the person known as '12345678' cannot select the unit 'MATHS020202' because he/she has a fail in 'MATHS010101'.
[Updated on: Sat, 07 April 2012 15:51] Report message to a moderator
|
|
|
|
|
|
Re: Mandatory Values/LOV Prohibited values [message #550493 is a reply to message #550301] |
Mon, 09 April 2012 15:03 |
|
vinni
Messages: 34 Registered: March 2012
|
Member |
|
|
cheers cookiemonster, and Littlefoot your code works but its not selecting the data i need, as i forgot to mention two things...
1) theres a different table i want to select the modules from and thats a course table (which is a broad structure that offers many units to choose from)
2) some of my units require a pass on TWO or MORE prerequisite units
(for example a unit such as SUPERADVANCED-SCIENCE requires a pass in chemistry and physics , if one or both is a fail then this wont be displayed on the LOV)
Below is where i want to select the units from
(LINK/JUNCTION TABLE)
Create table Courses_Units(
course_code number(3),
unit_code varchar2(11),
PRIMARY KEY (course_code, unit_code),
CONSTRAINT fk_Courses FOREIGN KEY (course_code) REFERENCES Courses (course_code),
CONSTRAINT fk_Units2 FOREIGN KEY (unit_code) REFERENCES Units(unit_code));
SAMPLE DATA
INSERT INTO Courses_Units (course_code, unit_code)
VALUES
(101, 'MUSIC020202');
INSERT INTO Courses_Units (course_code, unit_code)
VALUES
(101, 'MATHS020202');
So how would i go about in making those extra additions to my query?
sorry to disrupt your easter
|
|
|
|
|
Re: Mandatory Values/LOV Prohibited values [message #550962 is a reply to message #550312] |
Fri, 13 April 2012 18:18 |
|
vinni
Messages: 34 Registered: March 2012
|
Member |
|
|
Sorry i just wanted to jump back on the topic about the LOV query...
theres a problem im having as my select statement is completely ignoring my global variable (A.K.A the person_id) and selecting incorrect data
select q.unit_code,
u.unit_name
from prerequisites q,
units u
where q.preunit_code in (select g.unit_code
from grades g,
persons p
where g.grade = 'pass'
and g.person_id = p.person_id
and p.person_id = global.person_id)--Not selecting the logged in ID
and u.unit_code = q.unit_code
order by u.unit_code
Many thanks
[Updated on: Fri, 13 April 2012 18:19] Report message to a moderator
|
|
|
|
|
|
|
|
|
Re: Mandatory Values/LOV Prohibited values [message #551252 is a reply to message #551247] |
Mon, 16 April 2012 12:51 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
It is difficult to debug code that is incorrectly made up.
In your first query, WHERE keyword (and perhaps something else) is missing.
In your second query, what isfor example? You are selecting into USER_GRADE, and use the same variable in the same SELECT's WHERE clause? Moreover, we are discussing list of values problem (at least, that's what you reported). What does this PL/SQL code have to do with it?
Maybe we'd be happier with LoV query, don't you think?
And, to answer your final question: no, you don't have to declare a global variable twice (unless you erase it).
|
|
|
|
|
Re: Mandatory Values/LOV Prohibited values [message #551263 is a reply to message #551260] |
Mon, 16 April 2012 13:26 |
|
vinni
Messages: 34 Registered: March 2012
|
Member |
|
|
a) ORA-01036: illegal variable name/number
b) My LoV code below, Similar to yours
SELECT Courses_Units.unit_code
FROM Courses_Units, Units
WHERE Units.unit_code NOT IN ('COMPU020202')
AND Courses_Units.unit_code = Units.unit_code
AND course_code = '7777'
UNION
SELECT Courses_Units.unt_code
FROM Courses_Units, Units, Prerequisites
WHERE Units.unit_code = 'COMPU020202'
AND Prerequisites.preunit_code in (select unit_code
from Grades, Persons
where grade = 'pass'
and Grades.person_id = Persons.person_id
and Persons.person_id = :global.user_id
)
AND Prerequisites.unit_code = Units.unit_code
AND Courses_Units.unit_code = Units.units_code
AND course_code = '7777'
GROUP BY Courses_Units.unit_code
HAVING count(*) = 2
[Updated on: Mon, 16 April 2012 13:29] Report message to a moderator
|
|
|
|
|
|
|
Re: Mandatory Values/LOV Prohibited values [message #551285 is a reply to message #551268] |
Mon, 16 April 2012 17:43 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Some things you can try:
1) put a button in the block that has the LOV. In the when-button-pressed trigger put a message to display the global, check it has the correct value.
2) Create a datablock item to hold user_id. Assign it from the global in the WBP trigger mentioned above. Change the LOV to use the datablock item, see if that works.
3) Run a DB trace on the form session to see what query it is trying to send to the DB.
|
|
|
|
|
|