-----Original Message-----
Thank you Sivakumar. ExecStatusType PQresultStatus(const PGresult *res); Will it return code or message.If i want to use this what should be the return value of my function?
This will return whether your query was executed successfully or not.
Onemore doubt.. char *PQresultErrorField(const PGresult *res, int fieldcode); What is the use of this?What is the difference between the previous one and this? PG_DIAG_SQLSTATE--If i use this as my fieldcode will it take care of all my error values. Sorry for my basic questions.As i am very new to this i don't know how to handle errors in this. This will return more detailed info regarding why the query execution was not successful based on the fieldcode.
For example If I execute select * from pg_databasesas (table does not exist)
PQresStatus (PQresultStatus (res)) will return PGRES_FATAL_ERROR
Whereas
PQresultErrorField (res, PG_DIAG_SQLSTATE) will return 42P01 which corresponds to "undefined table". PQresultErrorField (res, PG_ DIAG_MESSAGE_PRIMARY) will return relation "pg_databasesa" does not exist.
Note that the above API's will return information regarding result set object only.
Normally we will be defining some errormessages according to the error codes return by the PQErrorMessage function.
I really wonder if PQErrorMessage returns error codes. AFAIK it returns error messages.
When i am using this even i declare my function as void..it is returning the errormessage. So..what iam planning is if i have some error codes returning from any of my postgresql function i can define myown message for that and i can send it as a return value to the main right! Please tell me how can i handle this?
Why do you want to define your own error messages when the appropriate error message is returned from PostgreSQL Server?
Please feel free to correct me
Thanks&Regards, Sandhya
|