Re: PL/pgSQL syntax for strings

Поиск
Список
Период
Сортировка
От Edward Grabczewski
Тема Re: PL/pgSQL syntax for strings
Дата
Msg-id 9rt4jd$u4r$1@news.tht.net
обсуждение исходный текст
Ответ на Re: PL/pgSQL syntax for strings  (Roberto Mello <rmello@cc.usu.edu>)
Список pgsql-sql
Sorry about the function not makig sense. It's only half-baked until I get
this string thing sorted out. I left the hard-coded numerical values there
for testing purposes only - so I guess it confused everyone. As it happens
the syntax of the posted function actually works. Even the backslashes! Now
the trick is to incorporate the variables into the string. I've looked at
the documentation a few times and I've experimented but failed to get the
right syntax so far - which is why I thought I'd ask for some help. :-)

Below is what the function will eventually look like when it uses the proper
variables: I guessed that the single quote needs to be double quoted:

''''('' x1 '','' z1 ''), ('' x2 '','' z2 '')''''

or something like that. Should this work?

Eddy


CREATE TABLE rtest (                                    xz BOX,                                    yz BOX,
                     xy BOX);
 

CREATE INDEX rtest_xz_index ON rtest USING RTREE (xz bigbox_ops);
CREATE INDEX rtest_yz_index ON rtest USING RTREE (yz bigbox_ops);
CREATE INDEX rtest_xy_index ON rtest USING RTREE (xy bigbox_ops);

DROP FUNCTION threedpoint (float,float,float, float,float,float);
CREATE FUNCTION threedpoint (float,float,float,float,float,float)
RETURNS text
AS 'DECLARE     x1 ALIAS FOR $1;     y1 ALIAS FOR $2;     z1 ALIAS FOR $3;     x2 ALIAS FOR $4;     y2 ALIAS FOR $5;
z2 ALIAS FOR $6;   BEGIN     INSERT INTO rtest(xz,yz,xy)     VALUES ( '(x1,z1), (x2,z2)',
'(y1,y2),(y2,z2)',                       '(x1,y1), (x2,y2)');     RETURN null;   END;'
 
LANGUAGE 'plpgsql';

SELECT threedpoint(100,200,300,400,500,600);






В списке pgsql-sql по дате отправления:

Предыдущее
От: Bhuvan A
Дата:
Сообщение: SELECT statement during transaction
Следующее
От: Tom Lane
Дата:
Сообщение: Re: table permissions