This discussion is archived
8 Replies Latest reply: Jul 10, 2013 12:43 AM by GoodfireGeorge RSS

Is it possible to execute Response Files from a C/C++ API Client ?

GoodfireGeorge Newbie
Currently Being Moderated

I found nothing relevant on the Documentation, not even name reference to C C++ or API

 

Instead the standard way of executing a response file from the cmd/shell,

Is it possible to execute Response Files from a C/C++ API Client e.g. through the OCI ? ( On Windows )

 

My target is calling dbca and netca from inside a C/C++ API tool and not starting different applications (batches)

  • 1. Re: Is it possible to execute Response Files from a C/C++ API Client ?
    sybrand_b Guru
    Currently Being Moderated

    Why?

    Why don't you outline your real business case as opposed to the various solutions/hacks you attempted.

     

    Evidently Oracle databases are not created on the fly.

    Evidently when you know how to call a commandline from C, your question is redundant,

    you just abuse this forum to avoid reading any documentation.

     

    Calling dbca from a C API has BAD IDEA  written all over it.

    Typically there is one (1) Oracle database on a server, and you seem to treat Oracle like a toy product like Mickeysoft Jakkes.

     

    -----------

    Sybrand Bakker

    Senior Oracle DBA

  • 2. Re: Is it possible to execute Response Files from a C/C++ API Client ?
    GoodfireGeorge Newbie
    Currently Being Moderated

    Evenings Mr. Bakker - I'm sorry for yesterday, hope you saw my reply to the other thread already https://forums.oracle.com/message/11098892#11098892

     

    For sure, thats the reason it wasnt implemented yet as a functionality, but its under consideration if it can prove possible and reliable. Then it could be provided as an extra functionality for anyone who doesnt like following manuals.

     

    Its not a good idea by Software Design call the CMD from a C API starting a different API if you can avoid it.

     

    I've searched tghe documentation on this but found no refference at all.

     

    You mean calling DBCA from C can spawn errors very easily eh? Hmm I ll have to consider this also.

    ( The alternative then is creating the DB with SQL/SQL*Plus commands. If that's more reliable then it might also be easier to do it in C. But this would require a new thread )

     

    Thank you for bothering

    - Can I add you on facebook?

  • 3. Re: Is it possible to execute Response Files from a C/C++ API Client ?
    EdStevens Guru
    Currently Being Moderated

    GoodfireGeorge wrote:

     

    I found nothing relevant on the Documentation, not even name reference to C C++ or API

     

    Instead the standard way of executing a response file from the cmd/shell,

    Is it possible to execute Response Files from a C/C++ API Client e.g. through the OCI ? ( On Windows )

     

    My target is calling dbca and netca from inside a C/C++ API tool and not starting different applications (batches)

    Maybe its a language issue, but given the drift of what you've described in your now several threads on this subject I suspect it is a real issue of understanding.

     

    You keep asking about "executing a response file."

     

    "response files" are, by definition, not "executed".  You execute some utility (in this case, the utility is dbca) and pass that utility the name of a response file, which supplies the utility with run-time values.

     

    What was wrong with the solution that CSM.DBA gave in one of your other threads?  Best method for silent-auto DBCA : response file OR dbca scripts ?

  • 4. Re: Is it possible to execute Response Files from a C/C++ API Client ?
    GoodfireGeorge Newbie
    Currently Being Moderated

    Nothing, was considering just alternatives

    "response files" are, by definition, not "executed".  You execute some utility (in this case, the utility is dbca) and pass that utility the name of a response file, which supplies the utility with run-time values.

    Ohh...
    So either you do it with SQL/SQL*PLUS commands, either you call DBCA no matter if silent passing inline the parameters, or through a response files ( And of course there are the templates always)


    And calling DBCA from inside C maybe through some OCI call can easily generate errors.

    Thus its not good software design either, and its always worst than calling a cmd batch.

     

    Thank you so much


    P.S.

    Irelative to this thread

    For my project needs so seems better to open OCI Session and start sending the SQL*Plus script commands.

    I'll have to configure a Network Service through SQL Plus commands, too, - have to look the doc on that. Its a 2nd step to DB config.

    But all P.S. irelative to this thread. just reference it.

  • 5. Re: Is it possible to execute Response Files from a C/C++ API Client ?
    BillyVerreynne Oracle ACE
    Currently Being Moderated

    DBCA, sqlplus, rman, etc are all executables. They do not have IPC type interfaces to my knowledge. No DDE. No message queues. No shared memory file. Etc.

     

    The OCI interface is for communicating with the Oracle OCI client DLL - and via it, with an Oracle server.

     

    The only way to call/communicate with something like a sqlplus executable is create a new and separate process for that executable. On Win32, that is typically done using the CreateProcess() call.

     

    The process will have a window handle (e.g. console window for sqlplus). Via the window handle you can send key strokes to the application using the SendMessage() call. Cannot offhand recall how to get the window handle from a process id, but there is a FindWindow() call that can be used.

     

    If you want to read the text output from the sqlplus process - that would not be easy. You would need to hook into its display device context to trap the text output I think.. or install a debug hook to trap the calls (in which case your s/w will likely trigger a virus signature from a running anti-virus service).

     

    On a Unix/Linux kernel I would instead redirect stdin to a FIFO pipe and stdout to a FIFO pipe - allowing my executable the ability to both write to the "keyboard" of sqlplus, and read from the "display device" of sqlplus. But this will only work for console s/w. And I doubt that this can easily be done using Win32, as Windows is a GUI environment without the same std/stdout/stderr device support that is on Unix/Linux.

     

    Bottom line. What you want to do has nothing to do with Oracle, or the OCI - but everything to do with how to create an external process and then communicate with that process.

  • 6. Re: Is it possible to execute Response Files from a C/C++ API Client ?
    GoodfireGeorge Newbie
    Currently Being Moderated

    Hmm I see, thank you.

     

    So I cant call DBCA or SQLPlus through C/C++ API through OCI, just send SQL statements to the Server.

     

    Ok thank you, If to create a new database I won't need SQL Plus comands, I will do it through C++ API through OCI.

    Except if I miss something and you can execute SQL Plus Commands like SQL from a C C++ API.


    P.S.

    Irelevant to the thread : As for the 2nd part of Net Service config, I will call a Windows batch since there is no other way.

  • 7. Re: Is it possible to execute Response Files from a C/C++ API Client ?
    BillyVerreynne Oracle ACE
    Currently Being Moderated

    If the intention is to send SQL and/or PL/SQL to the server from C/C++, then sqlplus is not needed. No proxy required. Just OCI calls for creating and using a client-server connection to the Oracle Server.

  • 8. Re: Is it possible to execute Response Files from a C/C++ API Client ?
    GoodfireGeorge Newbie
    Currently Being Moderated

    Ahh ok so I can only execute SQL and PL/SQL commands from C/C++ through OCI.

    But you can't execute SQL*PLUS commands, and of course not Command Line commands - unless you create a process to cmd which is a different thing.

     

    Thank you very much. I'm sorry for confusing the forum through this fragmented proccess-threads.

    When I finish it I will create a non-question Thread gathering all, for the community's knowledge base.

    I hope there will be enough replies-contributions to SEO rank it for future cases.

     

    P.S.

    Irelevant to this thread:

    Thus in my scenario I might be able creating a DB with the generated scripts from DBCA if no SQL Plus commands are involved.

    But for the 2nd step of creating the Net Service, I will have to call cmd as a 2nd proccess.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points