Subject | Re: [firebird-support] Re: how to accessing table in another database from stored procedure |
---|---|
Author | Yohanes Ongky Setiadji |
Post date | 2010-08-26T07:31:57Z |
This is what I do:
I have 2 database:
TEST and TEST_SYSTEM
in TEST_SYSTEM I create a stored procedure:
CREATE OR ALTER PROCEDURE GET_USERID
RETURNS (
USERID CHAR(10))
AS
BEGIN
SELECT a.USERID
FROM SYSUSER a
WHERE a.SQLID = CURRENT_USER
INTO :USERID;
SUSPEND;
END
and I create a store procedure in database TEST to call it:
CREATE OR ALTER PROCEDURE GET_USERID
RETURNS (
USERID CHAR(10))
AS
BEGIN
EXECUTE STATEMENT ('SELECT USERID FROM SYSUSER WHERE SQLID = :a')
(a := CURRENT_USER)
ON EXTERNAL DATA SOURCE 'localhost:TEST_SYSTEM'
AS USER 'SYSDBA' PASSWORD 'test'
INTO :USERID;
SUSPEND;
END
To connect to the database using:
n = SQLSTRINGCONNECT('Driver=Firebird/InterBase(r)
driver;UID=SYSDBA;PWD=test;DBNAME=TEST')
then
First I tried to execute:
SQLEXEC(n, 'SET TRANSACTION WAIT LOCK TIMEOUT 1') -> SUCCESS
SQLEXEC(n, 'EXECUTE PROCEDURE DO_SYSLOG') -> FAIL
SQLEXEC(n, 'ROLLBACK') -> SUCCESS
SQLDISCONNECT(n) -> SUCCESS
and then I tried another test without SET TRANSACTION...
SQLEXEC(n, 'EXECUTE PROCEDURE DO_SYSLOG') -> SUCCESS
SQLEXEC(n, 'ROLLBACK') -> SUCCESS
SQLDISCONNECT(n) -> SUCCESS
Why the command SET TRANSACTION WAIT LOCK TIMEOUT 1 make the command EXECUTE
PROCEDURE failed?
Any suggestion to solve it?
Thanks,
Ongky
I have 2 database:
TEST and TEST_SYSTEM
in TEST_SYSTEM I create a stored procedure:
CREATE OR ALTER PROCEDURE GET_USERID
RETURNS (
USERID CHAR(10))
AS
BEGIN
SELECT a.USERID
FROM SYSUSER a
WHERE a.SQLID = CURRENT_USER
INTO :USERID;
SUSPEND;
END
and I create a store procedure in database TEST to call it:
CREATE OR ALTER PROCEDURE GET_USERID
RETURNS (
USERID CHAR(10))
AS
BEGIN
EXECUTE STATEMENT ('SELECT USERID FROM SYSUSER WHERE SQLID = :a')
(a := CURRENT_USER)
ON EXTERNAL DATA SOURCE 'localhost:TEST_SYSTEM'
AS USER 'SYSDBA' PASSWORD 'test'
INTO :USERID;
SUSPEND;
END
To connect to the database using:
n = SQLSTRINGCONNECT('Driver=Firebird/InterBase(r)
driver;UID=SYSDBA;PWD=test;DBNAME=TEST')
then
First I tried to execute:
SQLEXEC(n, 'SET TRANSACTION WAIT LOCK TIMEOUT 1') -> SUCCESS
SQLEXEC(n, 'EXECUTE PROCEDURE DO_SYSLOG') -> FAIL
SQLEXEC(n, 'ROLLBACK') -> SUCCESS
SQLDISCONNECT(n) -> SUCCESS
and then I tried another test without SET TRANSACTION...
SQLEXEC(n, 'EXECUTE PROCEDURE DO_SYSLOG') -> SUCCESS
SQLEXEC(n, 'ROLLBACK') -> SUCCESS
SQLDISCONNECT(n) -> SUCCESS
Why the command SET TRANSACTION WAIT LOCK TIMEOUT 1 make the command EXECUTE
PROCEDURE failed?
Any suggestion to solve it?
Thanks,
Ongky
On Thu, Aug 26, 2010 at 1:52 PM, hvlad <hvlad@...> wrote:
>
>
>
>
> --- In firebird-support@yahoogroups.com<firebird-support%40yahoogroups.com>,
> "y_ongky_s" wrote:
> >
> > I found that when i run query with "EXECUTE STATEMENT" with another
> > database in stored procedure from
> > ISQL or another SQL manager the result is true like expected.
> > But when I use ODBC in my application to run a query with EXECUTE
> > STATEMENT in it then always
> > result error with message:
> >
> > Internal error when using clumplet API: attempt to store data in
> > dataless clumplet.
> >
> >
> > I use Firebird 2.5 RC3 and Firebird ODBC driver v2.
> >
> > Is this error cause be ODBC driver?
>
> What if you run query without EXECUTE STATEMENT via ODBC ?
> Show your connection string and transaction parameters.
>
> Also look at firebird.log and make sure you use latest snapshot build of
> Firebird.
>
> Regards,
> Vlad
>
>
>
[Non-text portions of this message have been removed]