当前位置: 动力学知识库 > 问答 > 编程问答 >

oracle - Passing Parameter from SQL-File to procedure

问题描述:

Sadly I don't know the exact names for each part, probably I can explain it:

We have a SQL-File, which is defined like this:

declare

l_exec boolean := true;

l_print boolean := false;

---

begin

dbms_output.enable;

for t in (

And so on. We use this to create some Triggers etc. in our Oracle-Database.

Now this File grew to much and I need to split it up.

So I created a Main-File, which is looking like this:

SET SERVEROUTPUT on

set feedback off

DEFINE l_exec = TRUE;

DEFINE l_print = FALSE;

ACCEPT ora_instance PROMPT "Zielinstanz angeben [123|...]: " DEFAULT somedefault

CONNECT somelogins

PROMPT -- GENERATING CODE --

@file1 l_print, l_exec

This would work fine, but I'd like to pass the l_exec and l_print to each file. I read in some other Threads passing the parameters like this is ok. But the problem is: I not only need to pass it from file to file, but I need to pass it to the Procedure-Block after begin.

I'm not sure if I made it understandable, but I'd like to use the variable I pass at @file1 in the begin block of the Files.

Is this kindahow possible? I googled alot about SQLPlus, but didn't find a solution so far.

Thanks as always and a nice week

Matthias

网友答案:

Ok, so if your main file has the call to your sub-file:

...
CONNECT somelogins

PROMPT  -- GENERATING CODE --
@file1 l_print, l_exec

then your sub-file can use the parameters in a positional manner thus:

declare
l_print boolean := &1;
l_exec  boolean := &2;
---  
begin
dbms_output.enable;
for t in (
分享给朋友:
您可能感兴趣的文章:
随机阅读: