- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- postgres - psql error when using a for loop
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2006 02:46 AM
тАО07-19-2006 02:46 AM
postgres - psql error when using a for loop
for LV in 1..10 LOOP
select * from ldev-rg where rg='$lv';
END LOOP;
but when I run it, I get:
psql:blah.sql:3: ERROR: syntax error at or near "for" at character 1
psql:blah.sql:3: LINE 1: for LV in 1..10 LOOP
psql:blah.sql:3: ^
psql:blah.sql:5: ERROR: syntax error at or near "LOOP" at character 5
psql:blah.sql:5: LINE 1: END LOOP;
psql:blah.sql:5: ^
Am I totally missing something here?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2006 02:56 AM
тАО07-19-2006 02:56 AM
Re: postgres - psql error when using a for loop
I don't have much plpgsql experience, but try this:
FOR LV in 1..10 LOOP
SELECT * FROM ldev-rg WHERE rg="$LV";
END LOOP;
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2006 02:57 AM
тАО07-19-2006 02:57 AM
Re: postgres - psql error when using a for loop
xp512-0715-0716=# FOR LV in 1..10 LOOP
xp512-0715-0716-# SELECT * FROM ldev-rg WHERE rg="$LV";
ERROR: syntax error at or near "FOR" at character 1
LINE 1: FOR LV in 1..10 LOOP
^
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2006 03:05 AM
тАО07-19-2006 03:05 AM
Re: postgres - psql error when using a for loop
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2006 03:09 AM
тАО07-19-2006 03:09 AM
Re: postgres - psql error when using a for loop
SELECT COUNT(*) FROM ldev-rg;
PCS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-19-2006 04:04 AM
тАО07-19-2006 04:04 AM
Re: postgres - psql error when using a for loop
xp512-0715-0716=# select count(*) from ldevrg;
count
-------
1491
(1 row)