
DB-LIB question ( newbie question )
|> Could somebody tell me what is wrong with the following code ?
|> When I run it, all I get is my prompt back. The table has the entry
|> 'niranjan', 'T&F' in it.
|>
|> I compile the program as
|> cc -I/sybase/include -L/sybase/lib example.c -lsybdb
|>
|> The version is sybase 10.1
Instead of doing
dbcmd(dbproc, "use tempdb");
Try
dbuse(dbproc, "tempdb");
Read up on "dbuse" in the Open Client manual. Use that to establish the
database you want your application to use.
|> Also how does one get back a single row as a string. I need to
|> delete trailing blanks from each field ? Any suggestion ?
|>
|> i.e
|>
|> while ( there are rows ) {
|> fetch a row
|> remove trailing blanks
|> }
You could do it in the SELECT statement you send to the server. For
example,
SELECT RTRIM(col1), RTRIM(col2) ...
FROM tablename
Hope this helps.
Teresa Larson
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
| Teresa A. Larson - Hughes STX Corporation |
| NASA/GSFC Code 933.0 voice: (301) 286-7867 |
| Greenbelt, Maryland 20771 fax: (301) 286-1777 |
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~+
Standard disclaimer ...