On Dec 30, 2006, at 4:05 AM, Jacob Palme wrote:
I am trying to use a REALBasic data base for the first time
in my life.
I have succeeded in creating the data base and putting some
records into it using the following code once for each
record:
// Enter record into Table ExpandedEnglishWords
ExpandedEnglishWordsRec = New DatabaseRecord
ExpandedEnglishWordsRec.Column("TheWord") = Word
ExpandedEnglishWordsRec.Column("Abbreviation") = Abbreviation
ExpandedEnglishWordsRec.Column("Pshort") = Pshort
EnglishDictDB.InsertRecord
"ExpandedEnglishWords",ExpandedEnglishWordsRec
EnglishDictDB.Commit
// Enter a new record into OneEntryForEachWord
OneEntryForEachWordRec = New DatabaseRecord
OneEntryForEachWordRec.Column("TheWord") = Word
OneEntryForEachWordRec.Column("QuickAskCount") = "0"
OneEntryForEachWordRec.Column("FAQCount") = "0"
OneEntryForEachWordRec.Column("QueryCount") = "0"
EnglishDictDB.InsertRecord
"OneEntryForEachWord",OneEntryForEachWordRec
EnglishDictDB.Commit
That seems to have worked OK, the database looks like it
should when I use the "Browse" functionality of REALBasic.
When I try to look at the database, I tried to execute
the following two statements:
// First test statement
SelectedRecords = EnglishDictDB.SQLSelect("SELECT * FROM
OneEntryForEachWord WHERE TheWord='$addiction'")
EnglishDictDB.Commit
No need for a COMMIT after a select
// SEcond test statement
SelectedRecords = EnglishDictDB.SQLSelect("SELECT * FROM
OneEntryForEachWord WHERE TheWord='afraid'")
EnglishDictDB.Commit
This did not work. After execution of the first test
statements above, when I look at "SelectedRecords" it says
Name Value
BOF False
EOF False
FieldCount 4
This tells you that it worked, and you got some records
They are contained in the Fields of SelectedRecords. Check the
language reference for how to use a RecordSet
Does this mean that no data was found? How can I get the
contents of the record retrived with the SQLSelect
statement? The REALBasic User guide is rather vague about
how to get the contents of a retrieved record.
When I then continue with execution of the second test
statements above, the application crashes!
Question 1: What did I do wrong so that the first test
statement did not return the contents of the record. I know
that there is a record where "TheWord" has the value
"$addiction".
Question 2: Why did the program crash when I tried to
execute the second test statement?
I have no idea but that definitely should not happen
Question 3: I have entered into the data base more than one
record with "TheWord" = "$addiction". But there only seems
to be one such record in the data base. Why? Is there some
rule that there can only be one record in the data base
with a certain value of an indexed attribute? It works OK
to have the same value in other fields, only not in the
TheWord field, which makes me believe that an indexed field
mmust have unique values, not the same value more than once.
It sounds like the additional inserts may have failed but if you do
not check the error codes this may have failed silently
Question 4: How does one debug SQL statements? REALBasic
has a very good debugger for ordinary code, but for data
bases there does not seem to be any debugger - just
crashing the execution as happended to me does not help
very much in explaining what went wrong!
I've got a small application I wrote that I use to enter my
statements and execute them
For the REAL SQL Database there is SQLiteManager (i think that's the
right name)
RB has no built in debugger
Question 5: The subchapter "Editing Records" in the User
guide does not contain any examples. If there had been an
example, I might have learnt more how to do and maybe
myself understood what I did wrong. Is there any guide to
REALBasic data bases which does contain examples?
There are some samples that other users have done online
Google about for REALbasic Database Samples or something like that
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>