|
Posted by --CELKO-- on 04/22/07 19:24
>> I am writing a function which will take two parameters. One the field [sic] to be returned from a table and second parameter is the ID of the record [sic] to be returned. <<
You got nothing right in this code. Erland is nicer about it, but
that is real message.
1) fields and records are nothing like columns and rows. That is
basic SQL.
2) You have not looked at ISO-11179 rules for data elements. At least
get rid of that silly "tbl-" and learn why even Microsoft has dropped
camelCase. And things like a "year_id" make no sense; Years are
already unique entities and have a name; they do not need an id. You
might give them a name, like the Chinese Zodiac, but that is
reaching. But a year in the context of a student is an attribute for
attending school, graduation, etc.
Also, never put the data type in a data element name like Paul did;
This is SQL and not 1960's BASIC for a 16KB PC.
3) The whole idea of what you are trying to do is a violation of
coupling and cohesion -- remember them in your first software
engineering class? You should name this nightmare something like
"Britney Spears, Squids or Automobiles" so that people will know that
you have no idea what it does until run time.
Think for a second about how uselessly vague the name
"getScholarYearData" is. Which data?
4) If you REALLY want to learn, first get some books and courses --
you really need that SE course before any SQL or RDBMS course.
Please post DDL, so that people do not have to guess what the keys,
constraints, Declarative Referential Integrity, data types, etc. in
your schema are. Sample data is also a good idea, along with clear
specifications. It is very hard to debug code when you do not let us
see it.
A bad design leads to these insane and impossible to maintain kludges
you are being offered to get you out of the way. It is easier than
trying to fill in an IT education in a posting.
Navigation:
[Reply to this message]
|