how to insert record with postgres.ppu - fpc 
Author Message
 how to insert record with postgres.ppu - fpc

situation:

Var si,na:string;
    si1,na1:PChar;
    conn:PPGconn;

readln(si);
readln(na);

PQexec(conn,'INSERT INTO some_table (sii,naa) VALUES ('si,na')');
//this works if I say VALUES(''John'',''Smith'')

or

Stralloc....etc.

StrPcopy(si1,si);
StrPcopy(na1,na);

PQexec(conn,'INSERT INTO some_table (sii,naa) VALUES (si1,na1)');

well the question is how to insert si or na value not directly
eg.John Smith.
any help?
fpc is 1.0.4

tnx



Fri, 08 Aug 2003 23:44:23 GMT  
 how to insert record with postgres.ppu - fpc

Quote:

>situation:

>Var si,na:string;
>    si1,na1:PChar;
>    conn:PPGconn;

>readln(si);
>readln(na);

>PQexec(conn,'INSERT INTO some_table (sii,naa) VALUES ('si,na')');
>//this works if I say VALUES(''John'',''Smith'')

>or

>Stralloc....etc.

>StrPcopy(si1,si);
>StrPcopy(na1,na);

>PQexec(conn,'INSERT INTO some_table (sii,naa) VALUES (si1,na1)');

>well the question is how to insert si or na value not directly
>eg.John Smith.

Depending on what PQExec demands as type for the second param:

If string or ansistring:

VALUES('+si+','+na+')';

Any pchar

construct it entirely in string or ansistring (ansistring if the result can
be larger than 255 chars)

pass it directly or convert to pchar using strpcopy (normal string), or
pchar(s) (in the case of an ansistring)



Mon, 11 Aug 2003 06:32:06 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. fpc postgres.pp & win32

2. fpc & postgres under win32

3. copying data from one record to the next when inserting a new record

4. FPC:problem with printing from fpc programs

5. FPC: translate execvp from c to FPC

6. Inserting new records

7. Duplicate Error on insert record

8. TQuery and editing inserted records

9. Q : SQL and INSERT and Multi-Records

10. Retrieve value of autoincrement field with inserted record

11. REQ: Insert records in Interbase table from Paradox table

12. Inserting records

 

 
Powered by phpBB® Forum Software