[SQL] How to declare cursor if tablename is a variable?

2007-03-14 Thread hu js

See this:
“CREATE or replace function geo_polygon(tablename varchar) RETURNS integer 
AS $$

DECLARE
   objectid varchar;
   tab varchar;
   x1 float;
   y1 float;
   
   obj_num integer;

   point_num integer;

   polygonstr varchar;
   
   cur_obj CURSOR FOR SELECT mrc_xy_position FROM tablename;
   cur_point CURSOR FOR SELECT x,y FROM tablename where mrc_xy_position = 
objectid;


BEGIN   
…….“


Error if call the function. Neither to use “execute” . Who can solve it? 
Thanks!


_
享用世界上最大的电子邮件系统― MSN Hotmail。  http://www.hotmail.com  



---(end of broadcast)---
TIP 9: In versions below 8.0, the planner will ignore your desire to
  choose an index scan if your joining column's datatypes do not
  match


[SQL] How to use serial variable to insert into muiti-recrods?

2007-09-06 Thread hu js

run:
"CREATE TABLE xxx
(
id serial NOT NULL,
name character varying
);
insert into xxx select default values,place_name from air_bui;"

fail:
"ERROR: syntax error at or near "default"
SQL state: 42601
Character: 24"

How can I do?

Bill Gates

_
与联机的朋友进行交流,请使用 MSN Messenger:  http://messenger.msn.com/cn  



---(end of broadcast)---
TIP 3: Have you checked our extensive FAQ?

  http://www.postgresql.org/docs/faq