我有firebird数据库,并创建使用它的java项目。通过使用GenerationTool我生成数据库结构。当我尝试这样的执行语句时,一切正常。
Result<Record1<Integer>> toStations = create.select(STATIONS.STATION_ID).
from(STATIONS).
where(STATIONS.CITY_ID.equal(create.select(CITIES.CITY_ID).
from(CITIES).
where(CITIES.CITY_NAME.equal(to)))).fetch();
但是我无法执行存储过程。我有存储过程:
create or alter procedure Find_Schemes (
FROM_STATION ID not null,
TO_STATION ID not null)
returns (
SCHEME_ID ID)
as
begin
for select SCHEME_ID
from SCHEMES S
where PATH_ID = (select PATH_ID
from PATHES P
where PATH_ID = S.PATH_ID and
(select LIST_POS
from PATHES_STATIONS
where PATH_ID = P.PATH_ID and
STATION_ID = :FROM_STATION) < (select LIST_POS
from PATHES_STATIONS
where PATH_ID = P.PATH_ID and
STATION_ID = :TO_STATION))
into :SCHEME_ID
do
begin
suspend;
end
end
^
我试着像这样执行他
Result result = (Result) Routines.findSchemes(7,22);
System.out.println(result);
但是我有例外而不能将其转换为(结果);
然后我尝试这样做,但这不起作用因为findSchemes需要String参数,但在我的程序中只有Integer参数:
Result result = create.select(FIND_SCHEMES(7,22));
如何使用JOOQ执行Firebird程序?
答案 0 :(得分:1)
通过输入随机命令3小时后就可以了。
Result result = create.selectFrom(Routines.findSchemesWithInfo(7, 22)).fetch();
System.out.println(result);
+---------+----------+---------------+--------+-----------+-----------+------------+-------+
|SCHEME_ID|START_CITY|END_CITY |DISTANCE|TRAVEL_TIME|COMFORT_LVL|HAND_LUGGAGE|LUGGAGE|
+---------+----------+---------------+--------+-----------+-----------+------------+-------+
| 1|Київ |Миколаїв | 189| 193|Преміум | {null}| {null}|
| 2|Київ |Кіровоград | 189| 193|Преміум | {null}| {null}|
| 3|Київ |Кіровоград | 189| 193|Преміум | {null}| {null}|
| 4|Київ |Дніпропетровськ| 189| 193|Преміум | {null}| {null}|
+---------+----------+---------------+--------+-----------+-----------+------------+-------+