Now I found an problem in ODBC interface about our the demo code of odbc in unicon.
  
  In the function "insertphone()", I could insert one record successfully, 
  but the demo code always return the message "*** couldn't insert person ***"" , 
  I found "&errornumber" = 1114.  
  
  What is the reason?
  
  Song


 
> > 
> > 
> > ------------------------------------------
> > # global variables
> > 
> > global db
> > global user, password
> > 
> > record person(name, phone, address) # database row
> > 
> > procedure main() # main program
> >   write("*** Unicon ODBC phonebook ***\n\n")
> >   login() # get user name and password
> >   # connect to mysql data source and open table "phones"
> >   db := open("myodbc3-test", "o", user, password)
> > 
> >   if &errornumber~=0 then { # error during login
> >     write(&errortext)
> >   }
> >   else {
> >     getdbinfo() # print database information
> >     repeat {
> >       menu() # print menu options 
> >       option := read()
> > 
> >       case option of {
> >         "i": insertphone()
> >         "d": deletephone()
> >         "u": updatephone()
> >         "l": listphones()
> >         "q": break
> >         default: write("*** wrong selection ***")
> >       }
> >     }
> >     close(db) # close table and database connection
> >   }
> >   write("bye")
> > end
> > 
> > #
> > # user information
> > #
> > procedure login()
> >   writes("user: ")
> >   user := read()
> >   writes("password: ")
> >   password := read()
> > end
> > 
> > 
> > #
> > # get database name and version
> > #
> > procedure getdbinfo()
> >   info := dbproduct(db)
> >   write("\nDBMS: ", info["name"])
> >   write("version: ", info["ver"])
> > end
> > 
> > #
> > # display menu options
> > #
> > procedure menu()
> >   write("\nI)nsert")
> >   write("D)elete")
> >   write("U)pdate")
> >   write("L)ist")
> >   write("Q)uit\n")
> > end
> > 
> > #
> > # insert a new record
> > #
> > procedure insertphone()
> >   writes("name: ")
> >   name := read()
> >   writes("phone: ")
> >   ph := read()
> >   writes("address: ")
> >   addr := read()
> >   sql(db, "INSERT INTO phones VALUES(" ||
> >            name || "," || ph || "," || addr || ")")
> >   if &errornumber~= 0 then
> >     write("*** couldn't insert person ***")
> > end
> > 
> > 
> > #
> > # remove a record 
> > #
> > procedure deletephone()
> >    writes("name to remove: ")
> >    name := read()
> > 
> >    # delete row with specified name column
> >    sql(db, "DELETE FROM phones WHERE name='"||name||"'")
> > end
> > 
> > #
> > # update a record
> > #
> > procedure updatephone()
> >   writes("name to update: ")
> >   name := read()
> > 
> >   # select all columns of rows with specified name column
> >   sql(db, "SELECT * FROM phones WHERE name='"||name||"'")
> > 
> >   if row := fetch(db) then { # data found
> >     writes("phone (",row["phone"],"): ")
> >     row["phone"]:=read()
> >     writes("address (",row["address"],"): ")
> >     row["address"]:=read()
> > 
> >     # update row on server
> >     sql(db, "UPDATE phones SET " ||
> >                    "phone='" || row["phone"] || "'" ||
> >                    ",address='" || row["address"] || "'" ||
> >                    " WHERE name='" || row["name"] || "'")
> >   }
> >   else write("\n\n*** person not found ***")
> > end
> > 
> > #
> > # list all people in the database
> > #
> > procedure listphones()
> >   
> >    sql(db, "SELECT * FROM phones") # select all columns and all rows
> > 
> >    while row := fetch(db) do { # while data found
> >       # write row fields
> >       every i:=(1 to *row) do writes("[",row[i],"]")
> >       write()
> >       }
> > end
> > 
?篆zf?+,?膦?o"0抚?疃?j[??{倍??ウ番z{^u?jx?n)?番?У┹C?g??y??
 ?y?z鳙守b?擘g?枝z{Z?h?-zf?)獠谮?'?i????&?bw^;雪e∪???%??(?韬???X?I????+-彩.????a囤l?b槽,㈥???薹?槽??-?棹殁r??�

Reply via email to