Here is simple function, that I pu into dll (it's on
NT):
extern "C" void __declspec(dllexport) os_cmd(char *cmd_string, short cmd_string_indicator, short cmd_string_length, int e_mode, short e_mode_indicator, int *ret_val) { int exec_mode; char *args[10]; char *l_buffer; char *pdest; char *pdest1; int result; int l_ch = ' '; /* TAB */ int i = 0; int nI; for (nI = 0; nI < 10; nI++) args[nI] = NULL; l_buffer = (char *)calloc(cmd_string_length + 1, sizeof(char)); strncpy(l_buffer, cmd_string, cmd_string_length); l_buffer[cmd_string_length] = '\0'; pdest1 = l_buffer; while ((pdest = strchr(pdest1, l_ch)) != NULL) { result = pdest - pdest1; args[i] = (char *)calloc(result + 1, sizeof(char)); strncpy(args[i++], pdest1, result); pdest1 = pdest + 1; } args[i] = (char *)calloc(strlen(pdest1) + 1, sizeof(char)); strncpy(args[i++], pdest1, strlen(pdest1)); args[i] = NULL;
if (e_mode == SyncMode) exec_mode = _P_WAIT; else exec_mode = _P_NOWAIT; if (_spawnv(exec_mode, args[0], args) == -1) { if (errno == E2BIG) *ret_val = 1; else if (errno == EINVAL) *ret_val = 2; else if (errno == ENOENT) *ret_val = 3; else if (errno == ENOEXEC) *ret_val = 4; else if (errno == ENOMEM) *ret_val = 5; else *ret_val = 6; } else *ret_val = 0; for (nI = 0; nI <= i-1; nI++) free(args[nI]); free(l_buffer); }
and PL/SQL wrapper: -- Executes OS command -- 'p-mode': 0 - sync, 1 - async. -- If there are parameters to pass, they should be separated by TABs. -- To run internal DOS command use 'cmd /C <your_command>' PROCEDURE exec_os_cmd( cmd_string IN varchar2, e_mode IN BINARY_INTEGER, ret_val OUT BINARY_INTEGER) IS external library externDDM NAME "os_cmd" LANGUAGE C PARAMETERS (cmd_string STRING, cmd_string INDICATOR, cmd_string LENGTH, e_mode INT, e_mode INDICATOR, ret_val INT); 'externDDM' is the name of the library I create:
create library externDDM as
'D:\ORANT\BIN\ext_ddm.dll';
Please read oracle docs for more details.
|
Title: RE: How to do a bitwise OR from SQL*Plus
- How to do a bitwise OR from SQL*Plus Orr, Steve
- Re: How to do a bitwise OR from SQL*Plus Connor McDonald
- Re: How to do a bitwise OR from SQL*Plus Vladimir Begun
- RE: How to do a bitwise OR from SQL*Plus Mercadante, Thomas F
- RE: How to do a bitwise OR from SQL*Plus Orr, Steve
- RE: How to do a bitwise OR from SQL*Plus Greg Solomon
- Re: How to do a bitwise OR from SQL*Plus Igor Neyman
- RE: How to do a bitwise OR from SQL*Plus Nirmal Kumar Muthu Kumaran
- RE: How to do a bitwise OR from SQL*Plus Igor Neyman
- RE: How to do a bitwise OR from SQL*Plus Jared . Still
- RE: How to do a bitwise OR from SQL*Plus Kempf, Reed
- Re: How to do a bitwise OR from SQL*Plus Stephane Faroult