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 -> Re: Help with Pro*C

Re: Help with Pro*C

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Mon, 31 Oct 2005 20:45:59 +0100
Message-ID: <43667476$0$7342$636a55ce@news.free.fr>

<xiaoluma_at_gmail.com> a écrit dans le message de news: 1130787330.443800.260500_at_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.
|

Try to declare Acct with a numeric type if you want to retrieve a number.

Regards
Michel Cadot Received on Mon Oct 31 2005 - 13:45:59 CST

Original text of this message

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