Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Help with Pro*C

Help with Pro*C

From: <xiaoluma_at_gmail.com>
Date: 31 Oct 2005 11:35:30 -0800
Message-ID: <1130787330.443800.260500@z14g2000cwz.googlegroups.com>


Hello,
I am trying to learn Pro*C and got stuck in the very begining. I really appreciate any advise.
I have the following simple program SampleSel.pc:

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

void sqlerror();
int oracle_logoff();
EXEC SQL BEGIN DECLARE SECTION;
char *connstr="MyUserID/MyPassword_at_MyDB"; char Acct[4];
EXEC SQL END DECLARE SECTION; void main()
{
  EXEC SQL WHENEVER SQLERROR DO sqlerror();   EXEC SQL WHENEVER SQLWARNING CONTINUE;   printf("Before the connection starts.\n");   printf("Connection string is: %s\n", connstr);   EXEC SQL CONNECT :connstr;
  if(!sqlca.sqlcode)
  {
    printf(stderr,"cannot connet\n");
  }
  EXEC SQL WHENEVER NOTFOUND GOTO notfound;   EXEC SQL SELECT Acct_Num
           INTO Acct
           FROM tblTest
           WHERE Amt>14;
  printf ("After connection string.\n");

.
.
.
.
.
.
.

Then I copied ORACLE demo_proc.mk to the directory and compiled my program as following:
 make -f demo_proc.mk build EXE=SampleSel OBJS=SampleSel.o

I got the following message for compliling: cc -o SampleSel SampleSel.o -L/appl/app/oracle/product/8.1.7/lib/ -lclntsh
`cat /appl/app/oracle/product/8.1.7/lib/sysliblist` -R/appl/app/oracle/product/8.1.7/lib -laio -lm -lthread

I assume it means that everything is all right,

Then I ran it as following: SampleSel
I got the following:
Before the connection starts.
Connection string is: MyUserID/MyPassword_at_MyDB Segmentation fault

I guess the problem is in the EXEC SQL CONNECT :connstr;

Can anyone out there give me any advise?

BTW, I can successfully connect SQLPlus in the same machine using the smae id and password.
Thanks a lot in advance. Received on Mon Oct 31 2005 - 13:35:30 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US