我正在尝试在 Oracle 中执行与此等效的 SQL。基本上,我需要将给定列中的值放入变量中,然后使用这些变量来查询表
DECLARE @transID INT
,@pol_no varchar(20)
SELECT @pol_no = 'xxx'
SELECT @transID = p.transID
FROM policy_dimension p
WHERE p.pol_no = @pol_no
SELECT pd.*
FROM property_dimension pd
WHERE pd.trans_id = @transID
我试过这个
DECLARE
policy_no VARCHAR2(20);
transaction_id int;
BEGIN
:policy_no := '20P0000175';
SELECT pd_transaction_id
INTO transaction_id
FROM policy_dimension p
WHERE p.pd_policy_no = :policy_no
AND ROWNUM = 1
ORDER BY pd_transaction_id desc;
BEGIN
SELECT *
FROM property_dimension pd
WHERE pd.pd_transaction_id = :transaction_id;
END;
END;
/