gpt4 book ai didi

oracle - DBMS_METADATA.GET_DDL 过程可以纠正不良缩进吗?

转载 作者:行者123 更新时间:2023-12-04 03:41:28 24 4
gpt4 key购买 nike

这是获取 DDL 或过程并使其美观的命令:

EXEC DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM , 'PRETTY' , TRUE);
SELECT DBMS_METADATA.GET_DDL('PROCEDURE', UPPER('LOOPPROC'), 'MYSCHEMA') FROM DUAL;

这是与输入完全相同的输出,就好像上面将 PRETTY 设置为 FALSE 一样。

  CREATE OR REPLACE EDITIONABLE PROCEDURE "MYLANID"."LOOPPROC" (inval NUMBER) 

IS

tmpvar NUMBER;
tmpvar2 NUMBER;
total NUMBER;

BEGIN

tmpvar := 0;
tmpvar2 := 0;
total := 0;

FOR lcv IN 1 .. inval

LOOP

total := 2 * total + 1 - tmpvar2;
tmpvar2 := tmpvar;
tmpvar := total;

END LOOP;

IF inval = 1 THEN
DBMS_OUTPUT.put_line ('IN IF TRUE branch, inval = ' || inval);
DBMS_OUTPUT.put_line ('IN IF TRUE branch, inval is still = ' || inval);
ELSE
DBMS_OUTPUT.put_line ('IN ELSE, inval = ' || inval);
END IF;


DBMS_OUTPUT.put_line ('TOTAL IS: ' || total);

END loopproc;

请注意 IF - THE - ELSE 子句如何像蛇河一样缩进。

有没有办法让程序更常规地缩进?

最佳答案

I’m also open to open source that can be called from .net. I’m considering as a last resort to use Selenium to take advantage of free web sites that do sql formatting but only as a last resort.

思路:SQL Developer 已经内置了formatting capabilities并允许设置多个选项。

然后使用:Command-Line Interface for SQL Developer :

For certain operations, you can invoke SQL Developer from the command line as an alternative to the graphical user interface. To use the command-line interface, go to the sqldeveloper\sqldeveloper\bin folder or sqldeveloper/sqldeveloper/bin directory under the location where you installed SQL Developer, and enter sdcli.

C:\sqldeveloper\sqldeveloper\bin>sdcli

Available features:

format: Format Task

调用:

 sdcli format input=<here goes file>

我可以想象构建以下批处理脚本/管道:

  1. 从 Oracle 获取对象定义
  2. 保存为文件
  3. 使用sdcli格式
  4. 读回文件内容

关于oracle - DBMS_METADATA.GET_DDL 过程可以纠正不良缩进吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65961660/

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