By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,401 Members | 793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,401 IT Pros & Developers. It's quick & easy.

copy command in postgresql

P: 6
Hi kindly correct me the following code
[CREATE OR REPLACE FUNCTION dataimport()
RETURNS void AS
$BODY$
DECLARE

t_name RECORD;

BEGIN
FOR t_name IN
SELECT
c.relname
FROM
pg_catalog.pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE
c.relkind = 'r'
AND n.nspname = 'public'
ORDER BY 1

LOOP

copy t_name.relname from E'C:\\bcp\\'|| t_name.relname||'.txt' using delimiters '|'

END LOOP;

END;
$BODY$
LANGUAGE 'plpgsql';]

i am getting following error
ERROR: syntax error at or near "$1"
LINE 1: copy $1 from E'C:\\bcp\\'|| $2 ||'.txt' using delimiters ...
Feb 28 '11 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 700
Use dynamic query
Expand|Select|Wrap|Line Numbers
  1. execute 'copy '||t_name.relname||' from E''C:\\bcp\\|| t_name.relname||'.txt'' using delimiters ''|'' ';
  2.  
Mar 13 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.