Linker IT Software
Google
Web www.oraxcel.com
menubar-top-links menubar-top-rechts
Home Help Search Login
Welcome, Guest. Please Login.
SQL*XL: Database to Excel bridge litLIB: Excel power functions pack ExcelLock: Locking and securing your valuable Excel spreadsheets encOffice: Protect your Excel file easy and safe encOffice: Protect your Excel file easy and safe
Pages: 1
SQLCode  in VBA (Read 4821 times)
dmacary
YaBB Newbies
*


I Love SQL*XL

Posts: 3
SQLCode  in VBA
16.11.10 at 22:08:09
 
Please forgive me if this has been answered already.  
 
I am trying to retrieve the value of SQLCode that should be returned from Oracle (also SQLERRM if possible).
 
Can you tell me if these are returned in SQL*XL and if so how should I access these values in my VBA program.
 
thanks
Back to top
 
 
  IP Logged
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 75
Re: SQLCode  in VBA
Reply #1 - 17.11.10 at 21:47:04
 
Hi,
 
You can use the following property to retrieve the last database error:
SQLXL.Database.LastServerErr
 
Back to top
 
 

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
dmacary
YaBB Newbies
*


I Love SQL*XL

Posts: 3
Re: SQLCode  in VBA
Reply #2 - 17.11.10 at 22:36:53
 
thank you for your prompt reply.
 
I tried this and always get the value zero even if my select statement is retrieving a row that is known not to exist.
 
Is there some other value that must be set to make this work?  Or have I misunderstood.
 
I am trying to see (for example) if the header record ( a master detail relationship)  exists before I query for the details.
 
again I appreciate your assistance.
Back to top
 
 
  IP Logged
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 75
Re: SQLCode  in VBA
Reply #3 - 18.11.10 at 08:10:56
 
Hi,
 
But then you should not rely on error codes in your application. Can you redesign your code to do the following?
 
Run a SQL command to retrieve a count of the number of master records. When you retrieve 1 you know you can proceed with the detail records. When you retrieve 0 you know there is no master and hence no detail.
 
That SQL could be something like:
select count(*) from your_master_table where id = some_id_value;
Back to top
 
 

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
Pages: 1