Re: Embed SQL in C - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: Embed SQL in C
Date
Msg-id 20050307040807.GA23291@winnie.fuhr.org
Whole thread Raw
In response to Embed SQL in C  (GMX <baldauf_m@gmx.at>)
Responses Re: Embed SQL in C
List pgsql-novice
On Wed, Mar 02, 2005 at 06:46:10PM +0100, GMX wrote:

> I need a C-program that goes something like this:

Why the requirement to use C?  Many tasks are easier in and can be
adequately written with higher-level languages like Perl, Python,
Ruby, Tcl, etc.

> 1) Check how much devices are in the database and look up the IP and
> the Port from them from the database.

Make an appropriate SELECT query against the table that contains
this information.  If you need help with SQL in general or with
PostgreSQL in particular, see the Tutorial and other parts of the
the PostgreSQL documentation.

http://www.postgresql.org/docs/

> 2) Connect to the computer using the IP and the Port and send a
> certain string to this computer.

This isn't a PostgreSQL issue.  Use an appropriate library/module
or write the socket code yourself.  The socket programming bible
is _UNIX Network Programming_, Volume 1, by W. Richard Stevens.

> [the computer echoes to this certain string with another string that
> contains 3 values]
>
> 3) The received string should be split and each value should be
> written in the right field of the SQL database.

Split the string using whatever facilities your programming language
provides and do an INSERT or UPDATE into the desired table.  PostgreSQL
also has some string-handling functions -- see "String Functions and
Operators" in the "Functions and Operators" chapter in the documentation.

If you're having a specific problem, then please post what you've
tried, explain what you'd like to happen, and describe what actually
does happen, including the exact text of any errors or warnings.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-novice by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Error in transaction... Log file
Next
From: Michael Fuhr
Date:
Subject: Re: Embed SQL in C