Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages
Started by Valence
Mon, 28 May 2007 17:57
Odd ball odbc problem
Author: Valence
Date: Mon, 28 May 2007 17:57
Date: Mon, 28 May 2007 17:57
16 lines
1302 bytes
1302 bytes
I suspect this is something fundamental I'm missing:
SQLExecDirect does not return an error for the following SQL:
<snip>
declare @test int
set @test = 1
raiserror('Test Error',16,1)
<\snip>
It seems that if the error occurs on the first line, then the error is
returned. If the error occurs after the first action, it is not. That is to
say that SQLGetDiagField tells me that there is no error as well as
SQLExecDirect returns SQL_SUCCESS.
Any ideas?
Thanks.
Re: Odd ball odbc problem
Author: Valence
Date: Mon, 28 May 2007 18:18
Date: Mon, 28 May 2007 18:18
30 lines
1980 bytes
1980 bytes
It should also be noted that the same code:
declare @test int
set @test = 1
raiserror('Test Error',16,1)
Does not return an error when Query1->ExecSQL is called.
Also, the following code does not return an error:
<sql>
declare @pcb_id int
select top 1 @pcb_id = pcb_id from myTable order by [datetime] desc
if @pcb_id is not null begin
insert into marriageTable (pcb_id,myValue) Values (@pcb_id, 123)
if (@@ERROR!=0) update marriageTable set myValue=123 where pcb_id =
@pcb_id
end
else raiserror('Not Found',16,1)
<\sql>
There is a unique key on pcb_id in marriageTable. This should return an
error if there is no pcb_id in myTable, but since the select succeeds, there
is no error reported. The second pcb_id of the same value causes an error
and is noted long enough for the update to succeed, but this error is not
remembered or reported. There is no information available through
SQLGetDiagField.
SQL Server 2000 on 2003. Client is Win XP.
Thoughts? I kinda' suspect the driver.
Re: Odd ball odbc problem
Author: Valence
Date: Mon, 28 May 2007 20:37
Date: Mon, 28 May 2007 20:37
34 lines
1869 bytes
1869 bytes
Ok,
Got it.
The ExecDirect is covering up the error, but only because the SQLMoreResults
needs to be called to get passed the output of the first line which does
nothing.
More results then returns the insert error the next time. So it is necessary
to "walk" through the results of the query one result set at a time.
That is what seems logical in 20/20 hind sight.
Thanks.
V.
"Valence" <valence.crearer@Itron.com> wrote in message
news:465b1803$1@newsgroups.borland.com...
>I suspect this is something fundamental I'm missing:
>
> SQLExecDirect does not return an error for the following SQL:
> <snip>
> declare @test int
> set @test = 1
> raiserror('Test Error',16,1)
> <\snip>
>
> It seems that if the error occurs on the first line, then the error is
> returned. If the error occurs after the first action, it is not. That is
> to say that SQLGetDiagField tells me that there is no error as well as
> SQLExecDirect returns SQL_SUCCESS.
>
> Any ideas?
> Thanks.
>
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads