小编Ale*_*kin的帖子

执行立即更改序列不工作

我坚持这个非常简单的脚本.它不像我期望的那样工作.

declare
 st VARCHAR(1024);
begin
  for x in (SELECT sequence_name FROM USER_SEQUENCES) loop
      st := 'ALTER SEQUENCE ' || x.sequence_name ||  ' INCREMENT BY 1000';
      execute immediate st;
      st := 'select ' || x.sequence_name ||  '.nextval from dual';
      execute immediate st;
      st := 'ALTER SEQUENCE ' || x.sequence_name ||  ' INCREMENT BY 1';
      execute immediate st;
  end loop;
end;
/
Run Code Online (Sandbox Code Playgroud)

当我运行它时它似乎根本不起作用 - 我的所有序列都保持不变,并且它们没有被动态语句增加一千.如果我nextval在匿名阻止之前和之后检查,差异只有1,而不是1001.

如果我更换execute immediatedbms_output.put_line,并执行生成的命令手动序列被改变,因为我想.

我错过了什么?

oracle plsql sequence execute-immediate

3
推荐指数
1
解决办法
4950
查看次数

如何从Windows运行ZooInspector

这是我做的:

  • 下载Apache ZooKeeper 3.4.6(.tar文件),解压缩到C:\ cygwin\home\user\zookeeper-3.4.6 \
  • Ran Ant位于ZooKeeper文件夹的根目录下(C:\ cygwin\home\user\zookeeper-3.4.6)
  • 导航到C:\ cygwin\home\user\zookeeper-3.4.6\contrib\ZooInspector \
  • 蚂蚁,我也得到了以下错误:

输出:

Buildfile: C:\cygwin\home\Jean\zookeeper-3.4.6\contrib\ZooInspector\build.xml

BUILD FAILED
C:\cygwin\home\user\zookeeper-3.4.6\contrib\ZooInspector\build.xml:19: Cannot find C:\cygwin\home\user\zookeeper-3.4.6\contrib\build-contrib.xml imported from C:\cygwin\home\user\zookeeper-3.4.6\contrib\ZooInspector\build.xml

Total time: 0 seconds
Run Code Online (Sandbox Code Playgroud)

这使我没有.cmd.sh文件来执行.为什么build-contrib.xml文件不存在?

另外,我注意到似乎有一个已编译的ZooInspector JAR文件:zookeeper-3.4.6-ZooInspector.jar.但是,尝试使用以下命令运行它也会导致失败:

$ java -cp zookeeper-3.4.6-ZooInspector.jar:lib/* org.apache.zookeeper.inspector.ZooInspector
Error: Could not find or load main class org.apache.zookeeper.inspector.ZooInspector
Run Code Online (Sandbox Code Playgroud)

这有点令人沮丧 - 设置ZooKeeper服务器很简单,但由于某种原因,我无法弄清楚如何运行这个独立的GUI.我错过了什么?

java windows apache-zookeeper

2
推荐指数
1
解决办法
4969
查看次数

阐明python del如何工作于列表和切片

阅读文档:

del:删除目标列表会从左到右递归删除每个目标。

您能否阐明为什么此代码可以正常工作?

a = [1,2,3]
c = a[:]

del c
print a
del a[:]
print a
Run Code Online (Sandbox Code Playgroud)

打印:

[1, 2, 3]

[]
Run Code Online (Sandbox Code Playgroud)

如果切片是指向原始列表中相同元素的新列表,那么为什么删除切片的变量赋值不会使之为a空,以及为什么删除未引用的切片会删除的元素a

UPD

# -*- coding: utf-8 -*-

a = [1,2,3]
c = a[:]

def list_info(lst):
    print "list id: {}".format(id(lst))
    print "list of item ids:"
    for item in lst:
        print "id: {}; value: {}".format(id(item), item)
    print ""

list_info(a)
list_info(c)
list_info(a[:])
Run Code Online (Sandbox Code Playgroud)

印刷品:

list id: 26945296
list of item ids:
id: 23753600; value: 1
id: 23753588; value: …
Run Code Online (Sandbox Code Playgroud)

python list slice

2
推荐指数
1
解决办法
159
查看次数

程序行为在不同系统上是不同的.为什么?

这是我的程序代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace YourGold
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome to YourGold App! \n------------------------");
            Console.WriteLine("Inesrt your gold: ");
            int gold;
            while (!int.TryParse(Console.ReadLine(), out gold))
            {
                Console.WriteLine("Please enter a valid number for gold.");
                Console.WriteLine("Inesrt your gold: ");
            }
            Console.WriteLine("Inesrt your time(In Hours) played: ");
            float hours;
            while (!float.TryParse(Console.ReadLine(), out hours))                
                    {
                        Console.WriteLine("Please enter a valid number for hours.");
                        Console.WriteLine("Inesrt your hours played: ");
                    }
                    float time = ((int)hours) * 60 …
Run Code Online (Sandbox Code Playgroud)

c#

1
推荐指数
1
解决办法
118
查看次数

ruby regex dotall没有dotall/s标志

大家.

我想我在ruby正则表达式中缺少一些东西.

似乎我不能使用,%r/match code/s因为Ruby只有/m,这不允许我搜索我的匹配线忽略新的线符号.

我现在需要的是:

line 1 : a b c
line 2 : a b
line 3 : c
line 4 : a
line 5 : b c
Run Code Online (Sandbox Code Playgroud)

我需要在这里找到三场比赛

1. a b c
2. a b (new line) c
3. a ( new line ) b c
Run Code Online (Sandbox Code Playgroud)

这可以通过使用/ s标志来完成,但是/ s标志用于Ruby中的编码,而/ m标志只是给了我这一个与所有文本的匹配

a b c 
a b ( new line ) c
a ( new line ) b c
Run Code Online (Sandbox Code Playgroud)

当我搜索这样的表达式时 %r/a.*c/m

我将不胜感激任何信息.

ruby regex

0
推荐指数
1
解决办法
947
查看次数

为什么我不能通过覆盖.to_s或在String上初始化来改变puts"string"的输出?

我已经在String类中替换了一个方法to_s,但正如我所看到的,当我运行时puts "string",ruby调用的不是to_s方法.

def add_method(cls)
  cls.class_eval do
    def initialize
      self.new('you hacked')
    end

    def to_s
      'you hacked'
    end
  end
end

add_method String

puts "zxzxzzx"
puts "zxzxzzx".to_s
Run Code Online (Sandbox Code Playgroud)

哪个输出:

>> zxzxzzx
>> you hacked
Run Code Online (Sandbox Code Playgroud)

如何替换这种隐式初始化?

ruby

-1
推荐指数
1
解决办法
52
查看次数