Subject | Re: [ib-support] Need help with a query |
---|---|
Author | Helen Borrie |
Post date | 2002-08-23T13:32:04Z |
At 09:57 AM 23-08-02 -0300, you wrote:
You don't give details of the SP but one guess is it is querying your
CLIENT table and perhaps CLIENTORDER has a dependency on the CLIENT table also?
If this is the case, it might be possible to get around the context clash
by aliasing the CLIENT table inside the stored procedure. For example, if
your stored procedure does something like
...
SELECT FIRSTNAME, LASTNAME FROM CLIENT
WHERE CLIENTNO = :client_no
INTO :first_name, :last_name
...
change the query to
...
SELECT c.FIRSTNAME, c.LASTNAME FROM CLIENT c
WHERE c.CLIENTNO = :client_no
INTO :first_name, :last_name
...
If this won't work, another way to deal with it might be to include CLIENT
in the query and use the separate context alias there instead:
SELECT DISTINCT
iv.INSURANCECONO,
co.INSURANCE_TOTAL,
co.INSURANCEBALDUE,
c1.CLIENTNO,
co.ORDERNO,
co.INVOICEDATE,
i.COMPANYNAME,
(SELECT FULLNAME FROM CLIENTFULLNAME_1(2, :c1.CLIENTNO)) AS
C_FULLNAME
FROM Invoice iv
JOIN ClientOrder co ON (i.orderno=co.orderno)
join CLIENT c1 on co.CLIENTNO=c1.CLIENTNO
JOIN INSURANCE i ON (i.COMPANYNO=iv.INSURANCECONO)
WHERE ((co.INSURANCE_TOTAL <> 0) AND
(co.INVOICEDATE <= :"End Date"))
Order By iv.INSURANCECONO
Or (one more) maybe the DISTINCT restriction is interfering with the
subselect and you need to replace it with FIRST 1...
heLen
>Hi,Daniel,
>
>This is something unusual. For the record, I'm using Firebird 1.0.0.794
>(Official release 1.0)
>
>Here's the error message:
>
>"ISC ERROR CODE:335544343
>
>ISC ERROR MESSAGE:
>invalid request BLR at offset 205
>context already in use (BLR error)"
>
>Here's the query:
>
>SELECT DISTINCT
> INVOICE.INSURANCECONO,
> CLIENTORDER.INSURANCE_TOTAL,
> CLIENTORDER.INSURANCEBALDUE,
> CLIENTORDER.CLIENTNO,
> CLIENTORDER.ORDERNO,
> CLIENTORDER.INVOICEDATE,
> INSURANCE.COMPANYNAME,
> (SELECT FULLNAME FROM CLIENTFULLNAME_1(2, CLIENTORDER.CLIENTNO)) AS
>C_FULLNAME
>FROM Invoice
> INNER JOIN ClientOrder
> ON (INVOICE.orderno=CLIENTorder.orderno)
> INNER JOIN INSURANCE
> ON (INSURANCE.COMPANYNO=INVOICE.INSURANCECONO)
>WHERE ((CLIENTORDER.INSURANCE_TOTAL <> 0) AND
>(CLIENTORDER.INVOICEDATE <= :"End Date"))
>Order By INVOICE.INSURANCECONO
>
>The problem started after inserting the "(SELECT FULLNAME FROM
>CLIENTFULLNAME_1(2, CLIENTORDER.CLIENTNO)) AS C_FULLNAME" line in the
>query. I've used this line in other queries with
>success. "CLIENTFULLNAME_1" is a stored procedure. I can even change
>CLIENTORDER.CLIENTNO to an integer value without any success. I've tried
>running this query in QuickDesk and IB_SQL without success.
You don't give details of the SP but one guess is it is querying your
CLIENT table and perhaps CLIENTORDER has a dependency on the CLIENT table also?
If this is the case, it might be possible to get around the context clash
by aliasing the CLIENT table inside the stored procedure. For example, if
your stored procedure does something like
...
SELECT FIRSTNAME, LASTNAME FROM CLIENT
WHERE CLIENTNO = :client_no
INTO :first_name, :last_name
...
change the query to
...
SELECT c.FIRSTNAME, c.LASTNAME FROM CLIENT c
WHERE c.CLIENTNO = :client_no
INTO :first_name, :last_name
...
If this won't work, another way to deal with it might be to include CLIENT
in the query and use the separate context alias there instead:
SELECT DISTINCT
iv.INSURANCECONO,
co.INSURANCE_TOTAL,
co.INSURANCEBALDUE,
c1.CLIENTNO,
co.ORDERNO,
co.INVOICEDATE,
i.COMPANYNAME,
(SELECT FULLNAME FROM CLIENTFULLNAME_1(2, :c1.CLIENTNO)) AS
C_FULLNAME
FROM Invoice iv
JOIN ClientOrder co ON (i.orderno=co.orderno)
join CLIENT c1 on co.CLIENTNO=c1.CLIENTNO
JOIN INSURANCE i ON (i.COMPANYNO=iv.INSURANCECONO)
WHERE ((co.INSURANCE_TOTAL <> 0) AND
(co.INVOICEDATE <= :"End Date"))
Order By iv.INSURANCECONO
Or (one more) maybe the DISTINCT restriction is interfering with the
subselect and you need to replace it with FIRST 1...
heLen