目录中的多个sql文件,这些文件又在unix脚本中使用

时间:2017-05-22 08:20:36

标签: sql shell unix scripting sqlplus

我在目录 / tmp / SQL_QUERY 中有一个脚本说 sql_result.sh ,它只是在同一个位置调用sql脚本并执行sql命令。 代码:

sqlplus -S $MY_UN/$MY_PW@$MY_DB <<!
set serveroutput on;
@/tmp/SQL_QUERY/sql_file1
quit
!

但是,如果我在该目录中说了2个SQL文件 sql_file1.sql sql_file1.sql_new 。我的unix脚本会选择哪个sql脚本?怎么样和为什么?

由于

1 个答案:

答案 0 :(得分:0)

简答:通常sql_file1.sql

默认扩展名为.SQL,如@ file_name[.ext] Represents the script you wish to run. If you omit ext, SQL*Plus assumes the default command-file extension (normally SQL). For information on changing the default extension, see the SUFFIX variable of the SET command. 中所述:

SET

正如它所说,您可以使用Sets the default file extension that SQL*Plus uses in commands that refer to scripts. SUFFIX does not control extensions for spool files. Example To change the default command-file extension from the default, .SQL to .UFI, enter SET SUFFIX UFI If you then enter @EXAMPLE SQL*Plus will look for a file named EXAMPLE.UFI instead of EXAMPLE.SQL. 命令更改使用的扩展名,或者您可以在脚本中明确指定扩展名。

docs命令说:

SET

(请注意,您的LOGIN文件中可能存在using System; using UIKit; namespace SingleViewApp { public partial class ViewController : UIViewController { int count = 0; int countFrom = 8; int guess; bool run = false; int number =0; public ViewController(IntPtr handle) : base(handle) { Random random = new Random(); number = random.Next(1, 1001); } public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. textView.Text = $"Can you guess my number in {countFrom} or less tries? Number: "; } public override void DidReceiveMemoryWarning() { base.DidReceiveMemoryWarning(); // Release any cached data, images, etc that aren't in use. } partial void EnterButton_TouchUpInside(UIButton sender) { try { guess = Convert.ToInt32(guessInput.Text); if (guess == number && count <= 8) { textView.Text = $"Congrats, you won! Guessed in {count + 1} guesses."; } else if (guess != number && count >= 8) { textView.Text = $"You lose! The number was {number}."; } else if (guess == (number - 25)) { textView.Text = "A hint: The number is higher than that!"; } else if (guess == (number + 25)) { textView.Text = "A hint: The number is lower than that!"; } else if (guess <= (number - 50)) { textView.Text = "A hint: The number is higher than that!"; } else if (guess == (number + 50)) { textView.Text = "A hint: The number is lower than that!"; } else if (guess == (number - 75)) { textView.Text = "A hint: The number is higher than that!"; } else if (guess == (number + 75)) { textView.Text = "A hint: The number is lower than that!"; } else if (guess == (number - 100)) { textView.Text = "A hint: The number is higher than that!"; } else if (guess == (number + 100)) { textView.Text = "A hint: The number is lower than that!"; } else if (guess >= (number - 2) && guess <= (number + 2)) { textView.Text = "You're practically there (2) !"; } else if (guess >= (number - 5) && guess <= (number + 5)) { textView.Text = "You're very close (5) !"; } else if (guess >= (number - 13) && guess <= (number + 13)) { textView.Text = "You are close (13) !"; } else if (guess >= (number - 25) && guess <= (number + 25)) { textView.Text = "It's warmer."; } else if (guess >= (number - 50) && guess <= (number + 50)) { textView.Text = "It's warm."; } else if (guess >= (number - 75) && guess <= (number + 75)) { textView.Text = "It's not too far anymore!"; } else if (guess >= (number - 100) && guess <= (number + 100)) { textView.Text = "You are not quite there!"; } else if (guess <= (number - 150)) { textView.Text = "You are too low!"; } else if (guess >= (number + 150)) { textView.Text = "You are too high!"; } else if (guess > number) { textView.Text = "It's lower."; } else if (guess < number) { textView.Text = "It's higher."; } count++; countFrom--; } catch (FormatException e) { textView.Text = "Wrong input!"; } } } 命令。)