获取数据库中的所有ID

时间:2017-05-15 14:41:09

标签: sql oracle plsql

我希望从具有ID字段的所有列中获取数据库中的所有ID。 到目前为止我的脚本是:

P → PL | L
L → N; | M; | C
N → print E
M → print "W"
W → TW | ε
C → if E {P} | if E {P} else {P}
E → (EOE) | V (note: this has a variable O)
O → + | - | *
V → 0 | 1 | 2 | 3 (note: this has a terminal 0 (zero))
T → a | b | c | d

我收到错误cmake_minimum_required(VERSION 3.4.1) # OpenCV stuff include_directories(D:\\opencv-3.2.0-android-sdk\\OpenCV-android-sdk\\sdk\\native\\jni\\include) add_library( lib_opencv SHARED IMPORTED ) set_target_properties(lib_opencv PROPERTIES IMPORTED_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libopencv_java3.so) add_compile_options(-std=c++11) # Creates and names a library, sets it as either STATIC # or SHARED, and provides the relative paths to its source code. # You can define multiple libraries, and CMake builds them for you. # Gradle automatically packages shared libraries with your APK. add_library( # Sets the name of the library. native-lib # Sets the library as a shared library. SHARED # Provides a relative path to your source file(s). src/main/cpp/native-lib.cpp) # Searches for a specified prebuilt library and stores the path as a # variable. Because CMake includes system libraries in the search path by # default, you only need to specify the name of the public NDK library # you want to add. CMake verifies that the library exists before # completing its build. find_library( # Sets the name of the path variable. log-lib # Specifies the name of the NDK library that # you want CMake to locate. log ) # Specifies libraries CMake should link to your target library. You # can link multiple libraries, such as libraries you define in the # build script, prebuilt third-party libraries, or system libraries. target_link_libraries( # Specifies the target library. native-lib -ljnigraphics lib_opencv # Links the target library to the log library # included in the NDK. ${log-lib} ) 。究竟是什么问题?欢迎任何帮助:)

2 个答案:

答案 0 :(得分:2)

在您的代码中tname是一个引用游标结果集的记录,即命名空间而不是属性。修复如下:

BEGIN
    FOR tname IN (select table_name 
                   from all_tab_columns 
                   where column_name = 'ID' and owner='PACC_USER') 
    LOOP
       EXECUTE IMMEDIATE 
       'select unique id from ' || tname.table_name ;
    END LOOP;
End; 

有人希望名为ID的列在不需要unique关键字的情况下返回唯一行,但我们生活在困难时期。

您的代码需要选择结果:PL / SQL不是T-SQL,它需要目标变量。因此,让我们更多地改进您的代码。

declare 
    ids_nt sys.dbms-debug_vc2coll;
BEGIN
    FOR tname IN (select table_name 
                   from all_tab_columns 
                   where column_name = 'ID' and owner='PACC_USER') 
    LOOP
       EXECUTE IMMEDIATE 
           'select unique id from ' || tname.table_name
           bulk collect into ids_nt;
       dbms_output.put_line('IDS for table '|| tname.table_name);
       for idx in ids_nt.first() .. ids_nt.last loop
           dbms_output.put_line(ids_nt(idx));
       end loop;
    END LOOP;
End; 

也许这不是你想用ID做的事情。如果是这样,请编辑您的问题以澄清您的意图。

答案 1 :(得分:-2)

  

从all_tab_column中选择column_name,表名,其中up​​per(column_name)= upper(' Id');