Deutsch English Français Italiano |
<104h2d1$31cae$2@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=C3=B8j?= <arne@vajhoej.dk> Newsgroups: comp.os.vms Subject: Re: VMS x86-64 database server Date: Mon, 7 Jul 2025 14:07:31 -0400 Organization: A noiseless patient Spider Lines: 49 Message-ID: <104h2d1$31cae$2@dont-email.me> References: <104ejo8$2cobv$1@dont-email.me> <686af3b4$0$686$14726298@news.sunsite.dk> <104f0a6$2gn2r$5@dont-email.me> <104f2ic$2h75q$2@dont-email.me> <104fc66$2n4ir$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Mon, 07 Jul 2025 20:07:30 +0200 (CEST) Injection-Info: dont-email.me; posting-host="c90d56ef0511a89ed17d363f636e6129"; logging-data="3191118"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MzCp+/cnptLI4vd8UHxuz1okxWkS2ln4=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:FoHcdw6SYTNOfu4RDo7FLP4beGs= In-Reply-To: <104fc66$2n4ir$2@dont-email.me> Content-Language: en-US On 7/6/2025 10:42 PM, Lawrence D'Oliveiro wrote: > On Sun, 6 Jul 2025 19:58:04 -0400, Arne Vajhøj wrote: >> But in embedded SQL then it is the standard way to do queries. > > Not sure what “embedded SQL” means. I normally use SQL “embedded” in an > app written in some other programming language. Embedded SQL is a thing or was a thing 30-40-50 years ago. Basically you write source code with SQL statements prefixed by EXEC SQL, put it through a pre-compiler to get valid code in whatever language (Cobol, PL/I, C or whatever). Here is C call API code: PGresult *res; res = PQprepare(con, "stmt_selectf1f2fromt1", "SELECT f1,f2 FROM t1", 0, NULL); PQclear(res); res = PQexecPrepared(con, "stmt_selectf1f2fromt1", 0, NULL, NULL, NULL, 0); int nrows = PQntuples(res); for(int i = 0; i < nrows; i++) { int f1 = atoi(PQgetvalue(res, i, 0)); char f2[51]; strcpy(f2, PQgetvalue(res, i, 1)); printf("%d %s\n", f1, f2); } PQclear(res); PQexec(con, "DEALLOCATE stmt_selectf1f2fromt1"); same code as C with embedded SQL: EXEC SQL DECLARE mycursor CURSOR FOR SELECT f1,f2 FROM t1; EXEC SQL OPEN mycursor; for(;;) { EXEC SQL FETCH mycursor INTO :f1, :f2; if(sqlca.sqlcode != 0) break; printf("%d %s\n", f1, f2); } EXEC SQL CLOSE mycursor; Simpler shorter code, because the pre-compiler handle some of the plumbing. Arne