从Oracle版本获取编号

时间:2015-12-08 11:21:56

标签: oracle oracle11g

我对如何从Oracle版本中获取数字感兴趣?

volatile int curWordStartIndex; //I use this global variable to communication between the progressChanged event and findBit, called from the DoWork event

private void Form1_Load(object sender, EventArgs e)
{
    backgroundWorker1.WorkerReportsProgress = true;
}

private void button1_Click(object sender, EventArgs e)
{
    //As far as richTextBox1.TextLength provokes a cross-thread error, I pass it as an argument
    backgroundWorker1.RunWorkerAsync(richTextBox1.TextLength);
}

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
    findBit((int)e.Argument);
}

private void findBit(int textLength)
{
    string[] words = new string[] { "word1", "word2", "word3", "word4", "word5" };
    foreach (string word in words)
    {
        int startIndex = 0;
        while (startIndex < textLength)
        {
            //Rather than performing the actions affecting the GUI thread here, I pass all the variables I need to
            //the ProgressChanged event through ReportProgress and perform the modifications there.
            backgroundWorker1.ReportProgress(0, new object[] { word, startIndex, Color.Yellow });
            if (curWordStartIndex == -1) break;

            startIndex += curWordStartIndex + word.Length;
        }
    }
}

private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
    object[] curVars = (object[])e.UserState;

    richTextBox1.SuspendLayout(); 

    string word = (string)curVars[0];
    int startIndex = (int)curVars[1];
    Color curColor = (Color)curVars[2];
    curWordStartIndex = richTextBox1.Find(word, startIndex, RichTextBoxFinds.None);

    if (curWordStartIndex != -1)
    {
        richTextBox1.SelectionStart = curWordStartIndex;
        richTextBox1.SelectionLength = word.Length;
        richTextBox1.SelectionBackColor = curColor;
    }

    richTextBox1.ResumeLayout();
}

2 个答案:

答案 0 :(得分:3)

有很多方法。

您可以在 V $ INSTANCE 视图中查看VERSION

SQL> SELECT version FROM V$INSTANCE;

VERSION
-----------------
12.1.0.1.0

您可以在 PRODUCT_COMPONENT_VERSION 视图中查看VERSION

SQL> SELECT VERSION
  2  FROM PRODUCT_COMPONENT_VERSION
  3  WHERE product LIKE '%Oracle Database%';

VERSION
--------------------------------------------
12.1.0.1.0

您可以使用 DBMS_DB_VERSION 包:

SQL> set serveroutput on
SQL> BEGIN
  2    DBMS_OUTPUT.PUT_LINE(DBMS_DB_VERSION.VERSION || '.' || DBMS_DB_VERSION.RELEASE);
  3  END;
  4  /
12.1

PL/SQL procedure successfully completed.

更新要将产品和版本作为单独的列获取,您可以执行以下操作:

SQL> SELECT product AS edition,
  2         version
  3  FROM PRODUCT_COMPONENT_VERSION
  4  WHERE product LIKE '%Oracle Database%';

EDITION                                  VERSION
---------------------------------------- ----------
Oracle Database 12c Enterprise Edition   12.1.0.1.0

答案 1 :(得分:2)

只是为了好玩,使用您提出的查询:

select 
   banner, 
   regexp_substr(banner,'[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*') version,
   substr(banner,1, instr(banner,'Release')-2) edition
from v$version 
where banner like 'Oracle%';

PS:我不会在常见对话中使用该版本的第5部分。其他许多人都是这样做的。