How to compile and run Pro*C Sample Program
- The following are the steps required to make and run the program:
- First, we'd like to put in the Oracle database, and Microsoft Visual C++. In Visual C++, we'll create our C program that contains the embedded SQL statements.
- This program will connect with a oracle database.
- The oracle database contains the in-built PROC components. To see whether the PROC has been installed successfully, open the cmd and type the 'proc' command.
- After entering the proc command in prompt , we press enter:
- The above screen shows that the proc has been installed successfully.
- Now, we'll create a C program in Visual C++. Open Visual C++. once we open the Visual C++, the image shown below will appear:
- Click on the File appearing at the top menu. Move the mouse over the New, then click on the Project.
Start Page in Visual c++
- When we click on the project, the screen appears shown below:
- In the above screen, click on the overall appearing at the left-side under the Visual C++ category, then click on the Empty Project. Now, we'd like to provide the name to the present empty project.
- In the above screen, click on the overall appearing at the left-side under the Visual C++ category, then click on the Empty Project. Now, we'd like to supply the name to the present empty project.
- In the above screen, we will see that the workspace of our project has been created. At the leftmost side, we will see the hierarchy of our project which contains External Dependencies, Header Files, Resource files, and Source files.
- Now, we've to feature the library files of Oracle, so right-click on the header files, then keep the mouse cursor over the Add then click on the Existing-item.
Add Existing Item
- Move to the oracle folder which contains precomp as a subdirectory. Click on the precomp.
- When we click on the precomp folder, the screen shown below will appear:
- Click on the lib folder, which is shown within the above screen.
- Now add the 2 object library files, i.e., orasql19, and another one is orasqx19, which is present within the msvc folder.
- When we add the above two library files, our Solution Explorer window would look like:
- In the above screen, the highlighted area shows that both the library files are added successfully in our project.
- Now, we add ASCII text file in our project. To do so, right-click on the source files, keep the mouse cursor over the Add then click on the New item.
Add New Item
- After clicking on the New item, the screen appears as shown below:
- In the above screen, click on the Code that appears at the leftmost side, then click on the C++ File. We even have provided the file name as first with a .pc extension.
- After providing the name to the source file, we click on the Add button.
- In the above screen, we will observe that the workspace for the file that we've added has been created.
- The following is that the code of pc file:
- Open the cmd, and move thereto folder, i.e., E:\Demo\Demo where first.pc file is stored.
Move Thereto Folder
- Now, we use the proc compiler to precompile the first.pc program as shown within the below screenshot:
- In the above screen, we will observe that first.c has been created after compilation of first.pc by Oracle precompiler.
- Now, we add the primary .c enter Visual C++. to feature this file, right-click on the Source files, then keep the mouse cursor on Add then click on the prevailing item. The below screen shows that first.c file has been added in Visual C++.
- After the compilation of first.pc, the code of first.c would be:
- We can run our program by simply clicking on the Debug that appears at the top menu, then click on the start Debugging.
Run The Program