在同一存储过程中重命名2个表

时间:2016-12-07 03:59:22

标签: stored-procedures plsql rename dynamic-sql

我编写了一个存储过程来将表重命名为old,并在同一过程中重命名临时表,以便用户在加载临时表时不会看到空表。每个执行立即执行重命名两个表,但是我得到一个错误,说sql命令没有正确执行。如果我提交每个执行,则该过程运行没有问题。我是否收到此错误,因为我无法在同一程序中将一个程序重命名为另一个程序,或者我还缺少其他什么?

非常感谢任何帮助!

这是我的计划:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char line[4096];

int main(int argc, char *argv[]) {

    int size = atoi(argv[3]); // The number of characters to copy

    FILE *f1 = fopen(argv[1], "r"); // Read from first file
    FILE *f2 = fopen(argv[2], "w"); // Write to second file

    if (f1 == NULL || f2 == NULL) {
        printf("\nThere was an error reading the file.\n");
        exit(1);
    }

    // read whole line
    // note: if the whole line doesn't fit in 4096 bytes,
    // we'll be treating it as multiple 4096-byte lines
    while (fgets(line, sizeof(line), f1) != NULL) {

        // NUL-terminate at "size" bytes
        // (no effect if already less than that)
        line[size] = '\0';

        // write up to newline or NUL terminator
        for (char* p = line; *p && *p != '\n'; ++p) {
            putc(*p, f2);
        }
        putc('\n', f2);

    }

    fclose(f1);
    fclose(f2);
    return 0;
}

0 个答案:

没有答案