Re: Stored Procedures in c
Posted by: cadd78 cadd
Date: July 27, 2010 12:34PM

Hi thanks for having interest. Here is the code. NOne ofthe insert is working
if i hardcode myprocinsert it works but it is not working for variabl;es.

/* Program to insert data in MYSQL */
#include<stdio.h>
#include<stdlib.h>
#include<mysql.h>
#include<string.h>


int main(int argc, char **argv)
{
MYSQL *conn;
char *server = "localhost";
char *user = "root";
char *password ="1234"; /* set me first */
int a=101;
int b=10;
int c =10;


conn=mysql_init(NULL);

if(conn==NULL){
printf("Error %u :%s\n", mysql_errno(conn), mysql_error(conn));
exit(1);
}

/* Connect to database */
if(mysql_real_connect(conn,server,user,password,"db",0,NULL,0) == NULL) {
printf("Error %u : %s /n",mysql_errno(conn), mysql_error(conn));
exit(1);
}
/* send SQL query */
//_query(conn,"insert into Sensor_Update values(100,100,100)");

// Calling a stored procedure

if(mysql_query(conn,"insert into Sensor_Update values(@a,@b,@c)")!=0)
{
printf("%s \n ",mysql_error(conn));
}

if(mysql_query(conn,"CALL myprocInsert(@a,@b,@c)")!=0)
{
printf("%s \n ",mysql_error(conn));
}

//call myprocInsert(@a,@b,@c);

mysql_close(conn);


}

Options: ReplyQuote


Subject
Views
Written By
Posted
1100
July 26, 2010 01:43PM
506
July 27, 2010 03:40AM
Re: Stored Procedures in c
518
July 27, 2010 12:34PM
496
August 02, 2010 05:23AM
593
August 02, 2010 09:27AM
488
August 02, 2010 01:25PM
502
August 02, 2010 02:37PM
519
August 02, 2010 03:08PM
452
August 03, 2010 05:41AM
535
August 03, 2010 08:57AM
496
August 04, 2010 06:46AM
530
August 04, 2010 09:22AM
536
August 04, 2010 12:31PM
470
August 04, 2010 03:28PM
579
August 04, 2010 05:34PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.