gpt4 book ai didi

Oracle Apex Dynamically add dblink to query in Grid using PL/SQL dynamic content(Oracle Apex使用PL/SQL动态内容在Grid中动态添加dblink查询)

转载 作者:bug小助手 更新时间:2023-10-25 14:05:44 25 4
gpt4 key购买 nike



I have an Apex page which selects databases from drop down:

我有一个Apex页面,它从下拉菜单中选择数据库:


All
DBDEV
DBTEST
POCTEST

The IG Query currently is:

IG查询当前为:


  select db_name, description,enable,allow , 
(select database_link from links a where a.db_name = b.db_name) link_db from db_details b;

I need to add another column that compares another similar table in a different schema and returns value Y/N.

我需要添加另一个列,该列比较不同模式中的另一个类似表,并返回值Y/N。


So query needs to be something like:

因此,查询需要类似于:


select db_name, description,enable,allow , 
select case when exists
(select db_name,description_enable,allow from db_details@**db_link** d
where d.db_name=b.db_name
and d.description=b.description
and d.enable=b.enable and d.allow =b.allow)
THEN 'Y' ELSE 'N' END FROM DUAL AS VALIDITY,
(select database_link from links a where a.db_name = b.db_name) link_db
from db_details b;

For the VALIDITY column, the @db_link needs to be the link_db column value that needs to be passed dynamically.

对于有效性列,@db_link需要是需要动态传递的link_db列值。


So if link_db value is TSTDEV, the validity column query should pass dblink as @TSTDV.

因此,如果link_db值为TSTDEV,则有效性列查询应该将dblink作为@TSTDV传递。


Can i please get some guidance on using pl/sql dynamic content which seems to be the only solution for the above?

我能得到一些关于使用pl/SQL动态内容的指导吗?这似乎是解决上述问题的唯一解决方案?


If i have not been explain to properly please let me know and i will share more details.

如果我没有得到适当的解释,请让我知道,我会分享更多的细节。


更多回答

You asked the same question here: stackoverflow.com/questions/77042458/… Question was answered and upvoted. I suggest you continue that thread

您在这里也问了同样的问题:Stackoverflow.com/Questions/77042458/…问题得到了回答,并获得了好评。我建议你继续这条线索

Does this answer your question? Oracle Apex add db link in processing query

这回答了你的问题吗?Oracle Apex在处理查询时添加数据库链接

Actually that was for processing part for inserting rows. Here's it's a different requirement. So how i'd put this as dynamic query in interactive grid is my doubt..

实际上,这是用来加工插行的零件。这是一个不同的要求。因此,我对如何将其作为交互网格中的动态查询表示怀疑。

Logic is similar. Use type "Function Body returning SQL Query"

逻辑是相似的。使用类型“函数体返回SQL查询”

Ok But here i have the dblink value in another column. To pass it do i need the for loop? Sorry i am not very confident with dynamic sql

好的,但我在另一列中有dblink的值。要传递它,我需要使用for循环吗?对不起,我对动态SQL不是很有信心

优秀答案推荐

If the link names rarely change you could hardcode them:

如果链接名称很少更改,您可以对其进行硬编码:


select b.db_name, 
b.description,
b.enable,
b.allo,
from db_details b
left outer join db_details@DBDEV l1 ON b.db_name = l1.db_name
left outer join db_details@DBTEST l1 ON b.db_name = l1.db_name
left outer join db_details@POCTEST l1 ON b.db_name = l1.db_name;

else I would load the data from the tables that are over the dblink in a collection and join to that in your query.

否则,我将从集合中dblink以上的表加载数据,并连接到您的查询中的数据。


Upon further thought... it seems you are only pulling very small amounts of data from the databases over the db link. Would it not make more sense to have a procedure running on page load that fetches the rows from the remoted dbs into a local table ? It would save you a lot of time

经过进一步思考..。您似乎只通过数据库链接从数据库中提取了非常少量的数据。让一个在页面加载上运行的过程将行从远程数据库提取到本地表不是更有意义吗?这会为你节省很多时间


更多回答

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com