pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rugge <davidrugge@mindspring.com>
To: pgsql-sql@hub.org
Subject: Converting a Sybase SQL script to a PostgreSQL script
Date: Sun, 2 Aug 1998 20:52:58 -0400
Message-ID: <l03102800b1eaac407da3@[209.86.35.150]> (raw)
In-Reply-To: <199808020300.XAA17823@hub.org>

I am trying to use PostgreSQL and The Practical SQL Handbook to learn SQL.
The book comes with a sample database on a CD for their demo version of
SQLAnywhere. They also include a script file with the SQL commands to
create and populate the sample database.  I've managed to make a few minor
changes in the datatypes and syntax of the commands to get most of the
script to work, but psql gives errors on a few sections when I run the
script using \i.  Can anyone explain what I need to do to fix these errors
so that I can get the sample database working?

Here is the create statement for the problematic table:

create table titles

	(title_id char(6) not null,

	title varchar(80) not null,

	type char(12),

	pub_id char(4),

	price money,

	advance money,

	ytd_sales int4,

	contract boolean not null,

	notes varchar(200),

	pubdate date)

;

grant select on titles to public

;



Here is a truncated transcript of the errors:

insert into titles
values ('PC8888', 'Secrets of Silicon
Valley',
'popular_comp', '1389', $20.00, $8000.00, 4095,1,
'Muckraking
reporting on the world''s largest computer hardware and software
manufacturers.',
'06/12/85')
;
ERROR:  parser: parse error at or near
"00"
insert into titles
values ('BU1032', 'The Busy Executive''s Database
Guide',
'business', '1389', $19.99, $5000.00, 4095, 1,
'An overview of
available database systems with emphasis on common business applications.
Illustrated.',
'06/12/85')
;
ERROR:  parser: parse error at or near
"99"

/*  other inserts into titles deleted */

/* I don't understand why
these creates don't work.  They appear to be */
/* syntactically correct...
*/

create view currentinfo (PUB#, TYPE, INCOME,
        AVG_PRICE,
AVG_SALES)
as
select pub_id, type, sum(price * ytd_sales),
  avg(price),
avg(ytd_sales)
from titles
group by pub_id, type
;
ERROR:  parser: parse
error at or near "("

create view cities (Author, Authorcity, Pub,
Pubcity)
as
select au_lname, authors.city, pub_name, publishers.city
from
authors, publishers
where authors.city = publishers.city
;
ERROR:  parser:
parse error at or near "("

create view accounts (title, advance,
gross_sales)
as
select title_id, advance, price * ytd_sales
from
titles
where price > $15
  and advance > $5000
;
ERROR:  parser: parse
error at or near "("
create view categories(Category, Average_Price)
as
select type, avg(price)
from titles
group by type
;
ERROR:  parser: parse
error at or near "("



-David Rugge
http://www.mindspring.com/~davidrugge/index.html





Message-ID: <l03102800b1eaac407da3@[209.86.35.150]>
Permalink:  ../l03102800b1eaac407da3@%5B209.86.35.150%5D/
Also on:    postgresql.org/message-id/l03102800b1eaac407da3@[209.86.35.150]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: davidrugge@mindspring.com, pgsql-sql@hub.org
  Subject: Re: Converting a Sybase SQL script to a PostgreSQL script
  In-Reply-To: <l03102800b1eaac407da3@[209.86.35.150]>
  References: <199808020300.XAA17823@hub.org> <l03102800b1eaac407da3@[209.86.35.150]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox