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

Home -> Community -> Usenet -> c.d.o.tools -> Re: Pro C Question

Re: Pro C Question

From: Thomas J. Kyte <tkyte_at_us.oracle.com>
Date: 2000/05/01
Message-ID: <8ek4ag$5qt$1@nnrp1.deja.com>#1/1

In article <390B3AE4.98F74909_at_swt.edu>,
  ps54713 <ps54713_at_swt.edu> wrote:
>
> --------------95E7369A1AD6227301617D58
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
>
> Hello,
>
> I have an employees table in my database
> I am trying to write a Pro C program in which i want to list all the
> employees' information present in the data base.
> I am getting an error for the same
> that is:
>
> Oracle Error:
> ORA-01007 : variable not in the select list
>
> This is how my function looks like:
>
> void list_information()
> {
> char employee_name[16];
> int emp_id;
> char hire_date[16];
> char job_type[16];
> int skill_level;
> float salary;
> float commission;
> char home_street[16];
> char home_city[16];
> char phone_number[12];
> struct emp_info * emprec_ptr;
>
> if ((emprec_ptr = (struct emp_info *) malloc (sizeof(struct
 emp_info)))
> == 0)
> {
> fprintf( stderr, "Memory Allocation error. \n");
> exit (EXIT_FAILURE);
> }
>
> EXEC SQL DECLARE employinfo CURSOR FOR SELECT skill_level FROM
> employees;
>
> EXEC SQL OPEN employinfo;
>
> printf("\n\nskill_level");
> printf("\n---------------");
>
> EXEC SQL WHENEVER NOT FOUND DO break;
>
> for(; ;)
> {
> EXEC SQL FETCH employinfo INTO :emprec_ptr;
> printf("%d " , emprec_ptr->skill_level);
> }
>
> EXEC SQL CLOSE employinfo;
> printf("\ndone\n");
>
> return;
> }
>

you do not show us the definition of emp_info but it probably has more then the element skill_level in it. You can only select into a record that has the same exact number of elements as the select list does. You are selecting SKILL_LEVEL in the cursor but I'll bet the struct has more then skill_level in it.

Either change the record to match the cursor or fetch into the SCALAR skill_level variable you have and assign to the record.

--
Thomas Kyte                              tkyte_at_us.oracle.com
Oracle Service Industries
http://osi.oracle.com/~tkyte/index.html
--
Opinions are mine and do not necessarily reflect those of Oracle Corp


Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Mon May 01 2000 - 00:00:00 CDT

Original text of this message

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