X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 25AEFD1B93F for ; Tue, 23 Sep 2003 21:12:53 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 48026-10 for ; Tue, 23 Sep 2003 18:12:24 -0300 (ADT) Received: from pcslink.com (pcslink.com [208.145.64.10]) by svr1.postgresql.org (Postfix) with ESMTP id 52F3ED1CA00 for ; Tue, 23 Sep 2003 18:12:21 -0300 (ADT) Received: (from ryan@localhost) by pcslink.com (8.9.3/8.9.2) id OAA63228 for pgsql-interfaces@postgresql.org; Tue, 23 Sep 2003 14:12:07 -0700 (MST) (envelope-from ryan) Date: Tue, 23 Sep 2003 11:12:07 -1000 From: Ryan Mooney To: pgsql-interfaces@postgresql.org Subject: ECPG insert into table name as a variable Message-ID: <20030923211207.GB13521@pcslink.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.3.25i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/60 X-Sequence-Number: 4478 I was doing testing on an app and wanted to make a table name a variable so I can change it via a config file (instead of re-compile/relink). like so: EXEC SQL INSERT INTO :tname (host, point, type, cooked) VALUES (:host, :name, :type, :cooked); This fails ecpg preprocess with "ERROR: syntax error at or near ":tname" whereas if the table name is specified statically it works fine, like: EXEC SQL INSERT INTO tname (host, point, type, cooked) VALUES (:host, :name, :type, :cooked); When I tried hacking the resulting C code (as a test exercise) like: { ECPGdo(__LINE__, 0, 1, NULL, "insert into ? ( host , point , type , cooked ) values ( ? , ? , ? , ? )", ECPGt_char,&(tname),(long)0,(long)1,1*sizeof(char), ECPGt_char,&(host),(long)0,(long)1,1*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(name),(long)0,(long)1,1*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(type),(long)1,(long)1,1*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,&(cooked),(long)1,(long)1,1*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(starttime),(long)30,(long)1,30*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_char,(interval),(long)30,(long)1,30*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, it got all funny and didn't work very well (well ok it didn't work at all): pg.pgc:129 SQL Insert failed: Invalid statement name (null) in line 124. So, I was wondering am I just missing some obvious way to do this, or is this not supported at all? Thanks -- >-=-=-=-=-=-=-<>-=-=-=-=-=-<>-=-=-=-=-=-<>-=-=-=-=-=-<>-=-=-=-=-=-=-< Ryan Mooney ryan@pcslink.com <-=-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-><-=-=-=-=-=-=->