Domanda

All,

I want to execute a DDL(Data Definition Language) from C code.

What are the alternatives to do this?

È stato utile?

Soluzione

One option is to use dynamic ESQL with PRO*C:

EXEC SQL EXECUTE IMMEDIATE
     "CREATE TABLE dyn1 (col1 VARCHAR2(4))";

Another option is to use system to run SQL*Plus. On a Linux type system it could look something like this:

<write sql command(s) to sql file>
system("cat mycommands.sql | sqlplus dbuser/password@myDatabase");

or this:

system("echo 'drop table myTable' | sqlplus dbuser/password@myDatabase");

If you are already using PRO*C I would recommend the PRO*C approach, because it gives much better control over error handling.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top