PostgreSQL Source Code: src/interfaces/ecpg/test/expected/sql-sqlda.c File Reference (original) (raw)

179{

180

181

182

183

184

185

186#line 66 "sqlda.pgc"

187 char * stmt1 = "SELECT * FROM t1" ;

188

189#line 67 "sqlda.pgc"

190 char * stmt2 = "SELECT * FROM t1 WHERE id = ?" ;

191

192#line 68 "sqlda.pgc"

193 int rec ;

194

195#line 69 "sqlda.pgc"

196 int id ;

197

198#line 70 "sqlda.pgc"

199

200

201 char msg[128];

202

204

205 strcpy(msg, "connect");

206 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "regress1", 0);

207#line 77 "sqlda.pgc"

208

209if (sqlca.sqlcode < 0) exit (1);}

210#line 77 "sqlda.pgc"

211

212

213 strcpy(msg, "set");

215#line 80 "sqlda.pgc"

216

217if (sqlca.sqlcode < 0) exit (1);}

218#line 80 "sqlda.pgc"

219

220

221 strcpy(msg, "create");

222 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "create table t1 ( id integer , t text , d1 numeric , d2 float8 , c char ( 10 ) , big bigint )", ECPGt_EOIT, ECPGt_EORT);

223#line 90 "sqlda.pgc"

224

225if (sqlca.sqlcode < 0) exit (1);}

226#line 90 "sqlda.pgc"

227

228

229 strcpy(msg, "insert");

230 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "insert into t1 values ( 1 , 'a' , 1.0 , 1 , 'a' , 1111111111111111111 ) , ( 2 , null , null , null , null , null ) , ( 3 , 'c' , 0.0 , 3 , 'c' , 3333333333333333333 ) , ( 4 , 'd' , 'NaN' , 4 , 'd' , 4444444444444444444 ) , ( 5 , 'e' , 0.001234 , 5 , 'e' , 5555555555555555555 )", ECPGt_EOIT, ECPGt_EORT);

231#line 98 "sqlda.pgc"

232

233if (sqlca.sqlcode < 0) exit (1);}

234#line 98 "sqlda.pgc"

235

236

237 strcpy(msg, "commit");

238 { ECPGtrans(__LINE__, NULL, "commit");

239#line 101 "sqlda.pgc"

240

241if (sqlca.sqlcode < 0) exit (1);}

242#line 101 "sqlda.pgc"

243

244

245

246

248

249 strcpy(msg, "prepare");

250 { ECPGprepare(__LINE__, NULL, 0, "st_id1", stmt1);

251#line 108 "sqlda.pgc"

252

253if (sqlca.sqlcode < 0) exit (1);}

254#line 108 "sqlda.pgc"

255

256

257 strcpy(msg, "declare");

258

259#line 111 "sqlda.pgc"

260

261

262 strcpy(msg, "open");

263 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur1 cursor for $1",

266#line 114 "sqlda.pgc"

267

268if (sqlca.sqlcode < 0) exit (1);}

269#line 114 "sqlda.pgc"

270

271

272

273#line 116 "sqlda.pgc"

274

275

276 rec = 0;

277 while (1)

278 {

279 strcpy(msg, "fetch");

283#line 122 "sqlda.pgc"

284

286#line 122 "sqlda.pgc"

287

288if (sqlca.sqlcode < 0) exit (1);}

289#line 122 "sqlda.pgc"

290

291

292 printf("FETCH RECORD %d\n", ++rec);

294 }

295

296

297#line 128 "sqlda.pgc"

298

299

300 strcpy(msg, "close");

302#line 131 "sqlda.pgc"

303

304if (sqlca.sqlcode < 0) exit (1);}

305#line 131 "sqlda.pgc"

306

307

308 strcpy(msg, "deallocate");

310#line 134 "sqlda.pgc"

311

312if (sqlca.sqlcode < 0) exit (1);}

313#line 134 "sqlda.pgc"

314

315

317

318

319

321

322 strcpy(msg, "prepare");

323 { ECPGprepare(__LINE__, NULL, 0, "st_id2", stmt1);

324#line 143 "sqlda.pgc"

325

326if (sqlca.sqlcode < 0) exit (1);}

327#line 143 "sqlda.pgc"

328

329

330 strcpy(msg, "declare");

331

332#line 146 "sqlda.pgc"

333

334

335 strcpy(msg, "open");

336 { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "declare mycur2 cursor for $1",

339#line 149 "sqlda.pgc"

340

341if (sqlca.sqlcode < 0) exit (1);}

342#line 149 "sqlda.pgc"

343

344

345 strcpy(msg, "fetch");

349#line 152 "sqlda.pgc"

350

351if (sqlca.sqlcode < 0) exit (1);}

352#line 152 "sqlda.pgc"

353

354

356 rec = 0;

358 {

360 printf("FETCH RECORD %d\n", ++rec);

362

366 }

367

368 strcpy(msg, "close");

370#line 168 "sqlda.pgc"

371

372if (sqlca.sqlcode < 0) exit (1);}

373#line 168 "sqlda.pgc"

374

375

376 strcpy(msg, "deallocate");

378#line 171 "sqlda.pgc"

379

380if (sqlca.sqlcode < 0) exit (1);}

381#line 171 "sqlda.pgc"

382

383

384

385

386

387

388

389

393

396

397 printf("EXECUTE RECORD 4\n");

398

399 id = 4;

400

402

403 strcpy(msg, "prepare");

404 { ECPGprepare(__LINE__, NULL, 0, "st_id3", stmt2);

405#line 193 "sqlda.pgc"

406

407if (sqlca.sqlcode < 0) exit (1);}

408#line 193 "sqlda.pgc"

409

410

411 strcpy(msg, "execute");

417#line 196 "sqlda.pgc"

418

419if (sqlca.sqlcode < 0) exit (1);}

420#line 196 "sqlda.pgc"

421

422

424

425 strcpy(msg, "deallocate");

427#line 201 "sqlda.pgc"

428

429if (sqlca.sqlcode < 0) exit (1);}

430#line 201 "sqlda.pgc"

431

432

435

436

437

438

439

440 { ECPGconnect(__LINE__, 0, "ecpg1_regression" , NULL, NULL , "con2", 0);

441#line 210 "sqlda.pgc"

442

443if (sqlca.sqlcode < 0) exit (1);}

444#line 210 "sqlda.pgc"

445

446

447

448

449

450

454

457

458 printf("EXECUTE RECORD 4\n");

459

460 id = 4;

461

463

464 strcpy(msg, "prepare");

465 { ECPGprepare(__LINE__, "con2", 0, "st_id4", stmt2);

466#line 230 "sqlda.pgc"

467

468if (sqlca.sqlcode < 0) exit (1);}

469#line 230 "sqlda.pgc"

470

471

472 strcpy(msg, "execute");

478#line 233 "sqlda.pgc"

479

480if (sqlca.sqlcode < 0) exit (1);}

481#line 233 "sqlda.pgc"

482

483

485

486 strcpy(msg, "commit");

487 { ECPGtrans(__LINE__, "con2", "commit");

488#line 238 "sqlda.pgc"

489

490if (sqlca.sqlcode < 0) exit (1);}

491#line 238 "sqlda.pgc"

492

493

494 strcpy(msg, "deallocate");

496#line 241 "sqlda.pgc"

497

498if (sqlca.sqlcode < 0) exit (1);}

499#line 241 "sqlda.pgc"

500

501

504

505 strcpy(msg, "disconnect");

507#line 247 "sqlda.pgc"

508

509if (sqlca.sqlcode < 0) exit (1);}

510#line 247 "sqlda.pgc"

511

512

513

514

515 strcpy(msg, "drop");

517#line 252 "sqlda.pgc"

518

519if (sqlca.sqlcode < 0) exit (1);}

520#line 252 "sqlda.pgc"

521

522

523 strcpy(msg, "commit");

524 { ECPGtrans(__LINE__, NULL, "commit");

525#line 255 "sqlda.pgc"

526

527if (sqlca.sqlcode < 0) exit (1);}

528#line 255 "sqlda.pgc"

529

530

531 strcpy(msg, "disconnect");

533#line 258 "sqlda.pgc"

534

535if (sqlca.sqlcode < 0) exit (1);}

536#line 258 "sqlda.pgc"

537

538

539 return 0;

540}

bool ECPGdisconnect(int lineno, const char *connection_name)

bool ECPGconnect(int lineno, int c, const char *name, const char *user, const char *passwd, const char *connection_name, int autocommit)

bool ECPGdo(const int lineno, const int compat, const int force_indicator, const char *connection_name, const bool questionmarks, const int st, const char *query,...)

bool ECPGtrans(int lineno, const char *connection_name, const char *transaction)

char * ECPGprepared_statement(const char *connection_name, const char *name, int lineno)

bool ECPGprepare(int lineno, const char *connection_name, const bool questionmarks, const char *name, const char *variable)

bool ECPGdeallocate(int lineno, int c, const char *connection_name, const char *name)

static void dump_sqlda(sqlda_t *sqlda)

struct sqlda_struct * desc_next