Add 0.98.

This commit is contained in:
Bruce Momjian 1999-10-30 16:18:54 +00:00
parent dbdb80baca
commit e0852543e2
188 changed files with 17109 additions and 0 deletions

82
src/bin/pgaccess/README Normal file
View File

@ -0,0 +1,82 @@
---------------------------------------------------------------------------
Copyright (c) 1994-7 Regents of the University of California
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose, without fee, and without a written agreement
is hereby granted, provided that the above copyright notice and this
paragraph and the following two paragraphs appear in all copies.
IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS TO
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
---------------------------------------------------------------------------
PGACCESS 0.98 29 August 1999
================================
I dedicate this program to my little daughters Ana-Maria and Emilia and to my
wife for their understanding. I hope they will forgive me for spending so many
time far from them.
1. How to INSTALL ?
You will need a Tcl/Tk package, at least Tcl 7.6 and Tk 4.2, recommended
Tcl/Tk 8.x
For Unix users, unpack the pgaccess-xxx.tar.gz archieve in you preferred
directory (usually /usr/local).
Check where your "wish" program is and modify (if needed) the file
/usr/local/pgaccess/pgaccess and set variables PGACCESS_HOME and
PATH_TO_WISH to the appropriate directories.
Include the /usr/local/pgaccess directory into your PATH or make a
symbolic link to it wherever you want (in PATH directories).
Example:
$ ln -s /usr/local/pgaccess/pgaccess /usr/bin/pgaccess
You will find also some documentation and FAQ in the doc directory.
2. Usage
You run it with the command:
pgaccess [database]
[database] is optional.
3. Bug reporting
First of all : operating system, PostgreSQL version,Tcl/Tk version.
A more detailed story of what have you done when error occurred.
Tcl/Tk stops usually with a error message and there is a button there
"Stack Trace" and if you press it, you will see a detailed information
about the procedure containing the error. Please send it to me.
Some information about table structure, no. of fields, records would
be also good.
===========================================================================
You would find always the latest version at http://www.flex.ro/pgaccess
Please feel free to e-mail me with any suggestion or bug description
that will help to improve it.
Constantin Teodorescu <teo@flex.ro>

View File

@ -0,0 +1,39 @@
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (X11; I; Linux 2.0.30 i586) [Netscape]">
<TITLE>PgAccess - Copyright notice</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<TT>---------------------------------------------------------------------------</TT>
<BR><TT></TT>&nbsp;
<BR><TT></TT>&nbsp;<TT></TT>
<P><TT>Copyright (c) 1994-7 Regents of the University of California</TT><TT></TT>
<P><TT>Permission to use, copy, modify, and distribute this software and
its</TT>
<BR><TT>documentation for any purpose, without fee, and without a written
agreement</TT>
<BR><TT>is hereby granted, provided that the above copyright notice and
this</TT>
<BR><TT>paragraph and the following two paragraphs appear in all copies.</TT><TT></TT>
<P><TT>IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
PARTY FOR</TT>
<BR><TT>DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
INCLUDING</TT>
<BR><TT>LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS</TT>
<BR><TT>DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
OF THE</TT>
<BR><TT>POSSIBILITY OF SUCH DAMAGE.</TT><TT></TT>
<P><TT>THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,</TT>
<BR><TT>INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY</TT>
<BR><TT>AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER
IS</TT>
<BR><TT>ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS
TO</TT>
<BR><TT>PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.</TT>
</BODY>
</HTML>

View File

@ -0,0 +1,233 @@
CREATE SEQUENCE "cities_id_seq" start 7 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
SELECT nextval ('cities_id_seq');
CREATE TABLE "pga_queries" (
"queryname" character varying(64),
"querytype" character,
"querycommand" text,
"querytables" text,
"querylinks" text,
"queryresults" text,
"querycomments" text);
CREATE TABLE "pga_forms" (
"formname" character varying(64),
"formsource" text);
CREATE TABLE "pga_scripts" (
"scriptname" character varying(64),
"scriptsource" text);
CREATE TABLE "pga_reports" (
"reportname" character varying(64),
"reportsource" text,
"reportbody" text,
"reportprocs" text,
"reportoptions" text);
CREATE TABLE "phonebook" (
"name" character varying(32),
"phone_nr" character varying(16),
"city" character varying(32),
"company" bool,
"continent" character varying(16));
CREATE TABLE "pga_layout" (
"tablename" character varying(64),
"nrcols" int2,
"colnames" text,
"colwidth" text);
CREATE TABLE "pga_schema" (
"schemaname" character varying(64),
"schematables" text,
"schemalinks" text);
REVOKE ALL on "pga_schema" from PUBLIC;
GRANT ALL on "pga_schema" to PUBLIC;
CREATE TABLE "cities" (
"id" int4 DEFAULT nextval('"cities_id_seq"') NOT NULL,
"name" character varying(32) NOT NULL,
"prefix" character varying(16) NOT NULL);
REVOKE ALL on "cities" from PUBLIC;
GRANT UPDATE,DELETE,SELECT,RULE on "cities" to "fane";
GRANT ALL on "cities" to "liviu";
CREATE FUNCTION "getcityprefix" (int4 ) RETURNS varchar AS 'select prefix from cities where id = $1 ' LANGUAGE 'SQL';
COPY "pga_queries" FROM stdin;
Query that can be saved as view S select * from phonebook where continent='usa' \N \N \N \N
\.
COPY "pga_forms" FROM stdin;
Phone book pb 28 {FS {}} 444x307+284+246 {label label1 {33 10 68 28} {} Name {} label1 flat #000000 #d9d9d9 1 n} {entry name_entry {87 9 227 27} {} entry2 DataSet(.pb.qs,name) name_entry sunken #000000 #fefefe 1 n} {label label3 {33 37 73 52} {} Phone {} label3 flat #000000 #d9d9d9 1 n} {entry entry4 {87 36 195 54} {} entry4 DataSet(.pb.qs,phone_nr) entry4 sunken #000000 #fefefe 1 n} {label label5 {33 64 78 82} {} City {} label5 flat #000000 #d9d9d9 1 n} {entry entry6 {87 63 195 81} {} entry6 DataSet(.pb.qs,city) entry6 sunken #000000 #fefefe 1 n} {query qs {3 6 33 33} {} query7 {} qs flat {} {} 1 n} {button button8 {174 177 246 203} {namespace eval DataControl(.pb.qs) {\
\ setSQL "select oid,* from phonebook where name ~* '$what' order by name"\
\ open\
\ set nrecs [getRowCount]\
\ updateDataSet\
\ fill .pb.allnames name\
\ bind .pb.allnames <ButtonRelease-1> {\
\ set ancr [.pb.allnames curselection]\
\ if {$ancr!=""} {\
\ \ DataControl(.pb.qs)::moveTo $ancr\
\ \ DataControl(.pb.qs)::updateDataSet\
\ }\
\ }\
}} {Start search} {} button8 raised #000000 #d9d9d9 1 n} {button button9 {363 276 433 300} {DataControl(.pb.qs)::close\
DataControl(.pb.qs)::clearDataSet\
set nrecs {}\
set what {}\
destroy .pb\
} Exit {} button9 raised #000000 #d9d9d9 2 n} {button button10 {291 237 313 257} {namespace eval DataControl(.pb.qs) {\
\ moveFirst\
\ updateDataSet\
}\
} |< {} button10 ridge #000092 #d9d9d9 2 n} {button button11 {324 237 346 257} {namespace eval DataControl(.pb.qs) {\
\ movePrevious\
\ updateDataSet\
}\
} << {} button11 ridge #000000 #d9d9d9 2 n} {button button12 {348 237 370 257} {namespace eval DataControl(.pb.qs) {\
\ moveNext\
\ updateDataSet\
}} >> {} button12 ridge #000000 #d9d9d9 2 n} {button button13 {381 237 403 257} {namespace eval DataControl(.pb.qs) {\
\ moveLast\
\ updateDataSet\
}\
} >| {} button13 ridge #000088 #d9d9d9 2 n} {checkbox checkbox14 {33 87 126 105} {} {Is it a company ?} DataSet(.pb.qs,company) checkbox14 flat #000000 #d9d9d9 1 n} {radio usa {63 108 201 120} {} U.S.A. DataSet(.pb.qs,continent) usa flat #000000 #d9d9d9 1 n} {radio europe {63 126 204 141} {} Europe DataSet(.pb.qs,continent) europe flat #000000 #d9d9d9 1 n} {radio africa {63 144 210 159} {} Africa DataSet(.pb.qs,continent) africa flat #000000 #d9d9d9 1 n} {entry entry18 {129 180 169 198} {} entry18 what entry18 sunken #000000 #fefefe 1 n} {label label19 {108 219 188 234} {} {records found} {} label19 flat #000000 #d9d9d9 1 n} {label label20 {90 219 105 234} {} { } nrecs label20 flat #000000 #d9d9d9 1 n} {label label21 {3 252 33 267} {} OID= {} label21 flat #000000 #d9d9d9 1 n} {label label22 {39 252 87 267} {} { } pbqs(oid) label22 flat #000000 #d9d9d9 1 n} {button button23 {9 276 79 300} {set oid {}\
catch {set oid $DataSet(.pb.qs,oid)}\
if {[string trim $oid]!=""} {\
sql_exec noquiet "update phonebook set name='$DataSet(.pb.qs,name)', phone_nr='$DataSet(.pb.qs,phone_nr)',city='$DataSet(.pb.qs,city)',company='$DataSet(.pb.qs,company)',continent='$DataSet(.pb.qs,continent)' where oid=$oid"\
} else {\
tk_messageBox -title Error -message "No record is displayed!"\
}\
\
} Update {} button23 raised #000000 #d9d9d9 1 n} {button button24 {210 276 280 300} {set thisname $DataSet(.pb.qs,name)\
if {[string trim $thisname] != ""} {\
\ sql_exec noquiet "insert into phonebook values (\
\ \ '$DataSet(.pb.qs,name)',\
\ \ '$DataSet(.pb.qs,phone_nr)',\
\ \ '$DataSet(.pb.qs,city)',\
\ \ '$DataSet(.pb.qs,company)',\
\ \ '$DataSet(.pb.qs,continent)'\
\ )"\
\ tk_messageBox -title Information -message "A new record has been added!"\
} else {\
\ tk_messageBox -title Error -message "This one doesn't have a name?"\
}\
\
} {Add record} {} button24 raised #000000 #d9d9d9 1 n} {button button25 {141 276 204 300} {DataControl(.pb.qs)::clearDataSet\
# clearcontrols stillinitialise\
# incorectly booleans controls to {}\
# so I force it to 'f' (false)\
set DataSet(.pb.qs,company) f\
focus .pb.name_entry} {Clear all} {} button25 raised #000000 #d9d9d9 1 n} {listbox allnames {249 6 435 231} {} listbox26 {} allnames sunken #000000 #fefefe 1 n} {label label27 {33 252 90 267} {} {} DataSet(.pb.qs,oid) label27 flat #000000 #d9d9d9 1 n} {label label28 {3 182 128 197} {} {Find name containing} {} {} flat #000000 #d9d9d9 1 n}
Full featured form full 21 {FS {set entrydemo {nice}\
set color {no color selected}}} 377x418+50+130 {label label1 {3 396 165 411} {} {Status line} {} {} sunken #000000 #d9d9d9 2 n} {label label2 {171 396 369 411} {} {Grooved status line} {} {} groove #000098 #d9d9d9 2 f} {label label3 {108 9 270 31} {} { Full featured form} {} {} ridge #000000 #d9d9d9 4 {Times 16 bold italic}} {button button4 {15 210 144 243} {.full.lb insert end {it's} a nice demo form} {Java style button} {} {} groove #6161b6 #d9d9d9 2 b} {label label5 {15 42 115 58} {} {Java style label} {} {} flat #6161b6 #d9d9d9 1 b} {entry entry6 {123 39 279 60} {} entry6 entrydemo {} groove #000000 #fefefe 2 {Courier 13}} {listbox lb {12 69 147 201} {} listbox8 {} {} ridge #000000 #ffffc8 2 n} {button button9 {18 264 39 282} {} 1 {} {} flat #000000 #d9d9d9 1 n} {button button10 {48 264 68 282} {} 2 {} {} flat #000000 #d9d9d9 1 n} {button button11 {78 264 234 282} {} {and other hidden buttons} {} {} flat #000000 #d9d9d9 1 n} {text txt {153 69 372 201} {} text12 {} {} sunken #000000 #d4ffff 1 n} {button button13 {150 210 369 243} {.full.txt tag configure bold -font {Helvetica 12 bold}\
.full.txt tag configure italic -font {Helvetica 12 italic}\
.full.txt tag configure large -font {Helvetica -14 bold}\
.full.txt tag configure title -font {Helvetica 12 bold italic} -justify center\
.full.txt tag configure link -font {Helvetica -12 underline} -foreground #000080\
.full.txt tag configure code -font {Courier 13}\
.full.txt tag configure warning -font {Helvetica 12 bold} -foreground #800000\
\
# That't the way help files are written\
\
.full.txt delete 1.0 end\
.full.txt insert end {Centered title} {title} "\
\
You can make different " {} "portions of text bold" {bold} " or italic " {italic} ".\
Some parts of them can be written as follows" {} "\
SELECT * FROM PHONEBOOK" {code} "\
You can also change " {} "colors for some words " {warning} "or underline them" {link} } {Old style button} {} {} raised #000000 #d9d9d9 2 n} {checkbox checkbox14 {48 297 153 309} {} different {} {} flat #00009c #d9d9d9 1 b} {checkbox checkbox15 {48 321 156 336} {} {fonts and} {} {} flat #cc0000 #d9d9d9 1 i} {checkbox checkbox16 {48 345 156 360} {} colors {} {} flat #00b600 #dfb2df 1 f} {radio radio17 {207 297 330 315} {} {red , rosu , rouge} color red flat #9c0000 #d9d9d9 1 n} {radio radio18 {207 321 324 333} {} {green , verde , vert} color green flat #009000 #d9d9d9 1 n} {radio radio19 {207 345 327 363} {} {blue , albastru, bleu} color blue flat #000000 #d9d9d9 1 n} {label selcolor {210 369 345 384} {} {} color {} flat #000000 #d9d9d9 1 n} {button button21 {285 258 363 285} {destroy .full} Exit {} {} raised #7c0000 #dfdbb8 1 b}
Working with Tables namespace f3 13 {3 4 5 6 7 9 10 11 12 13} 377x263+59+127 {radio usa {36 24 138 36} {} USA selcont} {radio europe {36 45 141 60} {} Europe selcont} {radio africa {36 66 147 81} {} Africa selcont} {label label6 {9 99 339 114} {} {Select one of the above continents and press} {}} {button button7 {270 93 354 117} {Tables::open phonebook "continent='$selcont'" $selorder} {Show them} {}} {button button9 {66 189 312 213} {Tables::design phonebook} {Show me the phonebook table structure} {}} {button button10 {141 228 240 252} {destroy .f3} {Close the form} {}} {button button11 {93 141 282 165} {Tables::open phonebook "company=true"} {Show me only the companies} {}} {radio name {183 24 261 36} {} {Order by name} selorder} {radio phone_nr {183 45 267 57} {} {Order by phone number} selorder}
The simplest form mf 5 {FS {set thename {}}} 306x136+82+146 {label label {42 45 99 60} {} Name {} label flat #000000 #d9d9d9 1 {Helvetica 12 bold italic}} {entry ename {120 42 219 63} {} entry2 thename ename sunken #000000 #fefefe 1 n} {button button3 {6 96 108 129} {set thename Teo} {Set the name} {} button3 raised #000000 #d9d9d9 1 n} {button button4 {192 96 300 129} {destroy .mf} {Close the form} {} button4 raised #000000 #d9d9d9 1 n} {button button5 {114 96 186 129} {set thename {}} {Clear it} {} button5 raised #000000 #d9d9d9 1 n}
A simple demo form asdf 14 {FS {set color none}} 370x310+50+75 {label label1 {15 36 99 57} {} {Selected color} {} label1 flat #000000 #d9d9d9 1} {entry entry2 {111 36 225 54} {} entry2 color entry2 sunken #000000 #fefefe 1} {radio red {249 21 342 36} {} {Red as cherry} color red flat #900000 #d9d9d9 1} {radio green {249 45 342 60} {} {Green as a melon} color green flat #008800 #d9d9d9 1} {radio blue {249 69 342 84} {} {Blue as the sky} color blue flat #00008c #d9d9d9 1} {button button6 {45 69 198 99} {set color spooky} {Set a weird color} {} button6 ridge #0000b0 #dfbcdf 2} {label label7 {24 129 149 145} {} {The checkbox's value} {} label7 flat #000000 #d9d9d9 1} {entry entry8 {162 127 172 145} {} entry8 cbvalue entry8 sunken #000000 #fefefe 1} {checkbox checkbox9 {180 126 279 150} {} {Check me :-)} cbvalue checkbox9 flat #000000 #d9d9d9 1} {button button10 {219 273 366 303} {destroy .asdf} {Close that simple form} {} button10 raised #000000 #d9d9d9 1} {button button11 {219 237 366 267} {Forms::open "Phone book"} {Open my phone book} {} button11 raised #000000 #d9d9d9 1} {listbox lb {12 192 162 267} {} listbox12 {} lb sunken #000000 #fefefe 1} {button button13 {12 156 162 186} {.asdf.lb insert end red green blue cyan white navy black purple maroon violet} {Add some information} {} button13 raised #000000 #d9d9d9 1} {button button14 {12 273 162 303} {.asdf.lb delete 0 end} {Clear this listbox} {} button14 raised #000000 #d9d9d9 1}
Working with listboxes f2 5 {FS {set thestudent ""}} 257x263+139+147 {listbox lb {6 6 246 186} {} listbox1 {} lb sunken #000000 #ffffd4 1} {button button2 {9 234 124 258} {# Populate the listbox with some data\
#\
\
foreach student {John Bill Doe Gigi} {\
\ .f2.lb insert end $student\
}\
\
\
\
# Binding the event left button release to the\
# list box\
\
bind .f2.lb <ButtonRelease-1> {\
\ set idsel [.f2.lb curselection]\
\ if {$idsel!=""} {\
\ \ set thestudent [.f2.lb get $idsel]\
\ }\
}\
\
# Cleaning the variable thestudent\
\
set thestudent {}} {Show students} {} button2 groove #000000 #d9d9d9 2} {button button3 {132 234 247 258} {destroy .f2} {Close the form} {} button3 groove #000000 #d9d9d9 1} {label label4 {9 213 119 228} {} {You have selected} {} label4 flat #000000 #d9d9d9 1} {label label5 {129 213 219 228} {} {} thestudent label5 flat #00009a #d9d9d9 1}
Invoices inv 0 {FS {frame .inv.f\
place .inv.f -x 5 -y 100 -width 500 -height 300\
set wn [Tables::getNewWindowName]\
Tables::createWindow .inv.f\
set PgAcVar(mw,.inv.f,updatable) 0\
set PgAcVar(mw,.inv.f,layout_found) 0\
set PgAcVar(mw,.inv.f,layout_name) ""\
Tables::selectRecords .inv.f "select * from cities"\
}} 631x439+87+84
\.
COPY "pga_scripts" FROM stdin;
How are forms keeped inside ? Tables::open pga_forms\
\
\
\
Opening a table with filters Tables::open phonebook "name ~* 'e'" "name desc"\
\
\
Autoexec Mainlib::tab_click Forms\
Forms::open {Full featured form}\
\
\
\.
COPY "pga_reports" FROM stdin;
My phone book phonebook set PgAcVar(report,tablename) "phonebook" ; set PgAcVar(report,y_rpthdr) 21 ; set PgAcVar(report,y_pghdr) 47 ; set PgAcVar(report,y_detail) 66 ; set PgAcVar(report,y_pgfoo) 96 ; set PgAcVar(report,y_rptfoo) 126 ; .pgaw:ReportBuilder.c create text 10 35 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -anchor nw -text {name} -tags {t_l mov ro} ; .pgaw:ReportBuilder.c create text 10 52 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -anchor nw -text {name} -tags {f-name t_f rg_detail mov ro} ; .pgaw:ReportBuilder.c create text 141 36 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -anchor nw -text {city} -tags {t_l mov ro} ; .pgaw:ReportBuilder.c create text 141 51 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -anchor nw -text {city} -tags {f-city t_f rg_detail mov ro} ; .pgaw:ReportBuilder.c create text 231 35 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -anchor nw -text {phone_nr} -tags {t_l mov ro} ; .pgaw:ReportBuilder.c create text 231 51 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -anchor nw -text {phone_nr} -tags {f-phone_nr t_f rg_detail mov ro} \N \N
\.
COPY "phonebook" FROM stdin;
FIAT 623463445 t europe
Gelu Voican 01-32234 Bucuresti f europe
Radu Vasile 01-5523423 Bucuresti f europe
MUGADUMBU SRL +92 534662634 Cairo t africa
Jimmy Page 66323452 f europe
IBM 623346234 \N t usa
John Doe +44 35 2993825 Washington f usa
Bill Clinton +44 35 9283845 New York f usa
Monica Levintchi +44 38 5234526 Dallas f usa
Bill Gates +42 64 4523454 Los Angeles f usa
COMPAQ 623462345 \N t usa
SUN 784563253 \N t usa
DIGITAL 922644516 \N t usa
Frank Zappa 6734567 Montreal f usa
Constantin Teodorescu +40 39 611820 Braila f europe
Ngbendu Wazabanga 34577345 f africa
Mugabe Kandalam 7635745 f africa
Vasile Lupu 52345623 Bucuresti f europe
Gica Farafrica +42 64 4523454 Los Angeles f usa
Victor Ciorbea 634567 Bucuresti f europe
\.
COPY "pga_layout" FROM stdin;
pga_forms 2 formname formsource 82 713
Usaisti 5 name phone_nr city company continent 150 150 150 150 150
q1 5 name phone_nr city company continent 150 150 150 150 150
view_saved_from_that_query 5 name phone_nr city company continent 150 150 150 150 150
phonebook 5 name phone_nr city company continent 150 105 80 66 104
Query that can be saved as view 5 name phone_nr city company continent 150 150 150 150 150
pg_database 4 datname datdba encoding datpath 150 150 150 150
pg_language 5 lanname lanispl lanpltrusted lanplcallfoid lancompiler 150 150 150 150 150
cities 3 id name prefix 60 150 150
3 id name prefix 125 150 150
3 id name prefix 150 150 150
3 id name prefix 150 150 150
3 id name prefix 150 150 150
\.
COPY "pga_schema" FROM stdin;
Simple schema cities 10 10 phonebook 201.0 84.0 {cities name phonebook city}
\.
COPY "cities" FROM stdin;
3 Braila 4039
4 Galati 4036
5 Dallas 5362
6 Cairo 9352
1 Bucuresti 4013
7 Montreal 5325
\.
CREATE UNIQUE INDEX "cities_id_key" on "cities" using btree ( "id" "int4_ops" );

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -0,0 +1,232 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
</head>
<body bgcolor="#FEFEDF">
<h2>
PgAccess developer API</h2>
<hr>
<br>Starting with PgAccess 0.98 I am planning to make available a complete
API for the PgAccess developers. I plan to make PgAccess not just an administrative
tool, but also a tool for easy build of small applications.
<p>That's why PgAccess 0.98 has been internally restructured, every main
module of PgAccess has became a namespace (see Tcl namespaces) in order&nbsp;
to hide the variables and internal procedures to the user. Also, all the
global variables that have been used before were grouped under a single
big associative array called <b>PgAcVar</b> (PgAccess variables) so they
should not interfere with user defined global variables.
<br>&nbsp;
<br>&nbsp;
<p><b><font size=+1>Global variables available</font></b>
<br>&nbsp;
<center><table BORDER=0 WIDTH="100%" NOSAVE >
<tr NOSAVE>
<td ALIGN=LEFT VALIGN=TOP NOSAVE><b>PgAcVar</b></td>
<td>The main global associative array that hold together various information
needed by PgAccess. User should <b><font color="#FF0000">NOT</font></b>
alter it under any circumstances.</td>
</tr>
<tr NOSAVE>
<td VALIGN=TOP NOSAVE><b>CurrentDB</b></td>
<td>The handler of the current opened database. Can be used for database
operations as selects or command execution.</td>
</tr>
<tr NOSAVE>
<td ALIGN=LEFT VALIGN=TOP NOSAVE><b>Messages</b></td>
<td NOSAVE>The associative array that holds the translation for the current
language. Loaded from the appropriate language file from lib/languages
directory</td>
</tr>
<tr NOSAVE>
<td ALIGN=LEFT VALIGN=TOP NOSAVE><b>PGACCESS_HOME</b></td>
<td>Keep the system directory of PgAccess root installation</td>
</tr>
</table></center>
<br>&nbsp;
<p><b><font size=+1>Window naming convention</font></b>
<p>Every toplevel window defined by PgAccess has the following naming convention.
Every window name starts with <tt>.pgaw</tt> (PgAccess window) followed
by a colon and a name. <i>Example:</i>
<blockquote><tt>.pgaw:User , .pgaw:About , .pgaw:ImportExport</tt></blockquote>
<b><font size=+1>Namespaces available</font></b>
<p>For every tab from the main database window there is a namespace defined
(Tables, Queries, Views, Functions, Sequences, Reports, Forms, Scripts,
Users, Schema). Every namespace has by default the following&nbsp; procedures:
<ul>
<li>
<tt>new</tt>&nbsp; , no parameter needed</li>
<li>
<tt>open</tt> , need a single parameter, the object name</li>
<li>
<tt>design</tt> , need a single parameter, the object name</li>
</ul>
You can use these procedures if you want to produce the same efects as
clicking on the desired tab and then on the "New", "Open" or "Design" buttons
from the main database window.
<br><i>Example:</i>
<blockquote><tt>Tables::open "customers"</tt>
<br><tt>Queries::open "Invoices received"</tt>
<br><tt>Forms::open "Add new invoice"</tt></blockquote>
The <tt>Tables::open</tt> procedure accepts two optional parameters, filter
and order.
<br><i>Example:</i>
<blockquote><tt>Tables::open "phonebook" "name ~* 'joe'" "age desc"</tt></blockquote>
will open a table view window with predefined filter "name ~* 'joe'" and
ordered by descending age.
<p>There is also a special namespace called Database.&nbsp; Here are some
procedures and functions defined for this namespace available to the user:
<br>&nbsp;
<table BORDER NOSAVE >
<tr BGCOLOR="#FFCCFF" NOSAVE>
<td NOSAVE><b>Name</b></td>
<td NOSAVE><b>Parameters</b></td>
<td><b>Type</b></td>
<td><b>Returns</b></td>
<td NOSAVE><b>Description</b></td>
</tr>
<tr>
<td><b>vacuum</b></td>
<td>none</td>
<td>procedure</td>
<td>nothing</td>
<td>vacuums the current database</td>
</tr>
<tr ALIGN=LEFT VALIGN=TOP NOSAVE>
<td><b>getTablesList</b></td>
<td>none</td>
<td>function</td>
<td>list</td>
<td NOSAVE>returns the list of tables from the current database</td>
</tr>
<tr ALIGN=LEFT VALIGN=TOP NOSAVE>
<td><b>executeUpdate</b></td>
<td>sqlcmd</td>
<td>function</td>
<td>integer</td>
<td NOSAVE>execute the sqlcmd command on the current database returning
1 if no errors ocurred or 0 if the command failed</td>
</tr>
</table>
<p><b><font size=+1>Global functions available</font></b>
<br>&nbsp;
<table BORDER NOSAVE >
<tr BGCOLOR="#99FFCC" NOSAVE>
<td><b>Name</b></td>
<td><b>Parameters</b></td>
<td NOSAVE><b>Description</b></td>
</tr>
<tr ALIGN=LEFT VALIGN=TOP NOSAVE>
<td><b>setCursor</b></td>
<td>type</td>
<td NOSAVE>Set the cursor for all PgAccess windows, type of cursor can
be WAIT or CLOCK or WATCH for the hourglass , anything else (or none) to
return to the normal cursor shape</td>
</tr>
<tr ALIGN=LEFT VALIGN=TOP NOSAVE>
<td><b>parameter</b></td>
<td>msg</td>
<td NOSAVE>Shows a modal input dialog with the msg message, wait for user
to enter the data and returns it as a string</td>
</tr>
<tr>
<td><b>showError</b></td>
<td>msg</td>
<td>Shows a modal dialog window with an error message</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

View File

@ -0,0 +1,29 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
<base target="right">
</head>
<body bgcolor="#00FFFF">
<img SRC="ball.gif" ><a href="main.html">What is PgAccess?</a>
<br><img SRC="ball.gif" ><a href="whatsnew.html">What's new?</a>
<br><img SRC="ball.gif" ><a href="features.html">Features</a>
<br><img SRC="ball.gif" ><a href="screenshots.html">Screenshots</a>
<br><img SRC="ball.gif" ><a href="faq.html">FAQ</a>
<br><img SRC="ball.gif" ><a href="documentation.html">Documentation</a>
<br><img SRC="ball.gif" ><a href="todo.html">To-Do list</a>
<br><img SRC="ball.gif" ><a href="download.html">Download</a>
<br>&nbsp;
<p><br>
<center>
<p><a href="http://www.linux.org"><img SRC="linux1.gif" BORDER=0 ></a></center>
<p><b>Other links</b>
<br><img SRC="ball.gif" ><a href="http://www.postgresql.org">PostgreSQL</a>
<br><img SRC="ball.gif" ><a href="http://www.neuron.com/stewart/vtcl/index.html">Visual Tcl</a>
<br><img SRC="ball.gif" ><a href="http://www.scriptics.com">Tcl/Tk</a>
<br><img SRC="ball.gif" ><a href="http://www.linux.org">Linux</a>
<br><img SRC="ball.gif" ><a href="http://www.java.ro/vtclava/index.html">vTcLava</a>
</body>
</html>

View File

@ -0,0 +1,39 @@
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.03 [en] (X11; I; Linux 2.0.30 i586) [Netscape]">
<TITLE>PgAccess - Copyright notice</TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<TT>---------------------------------------------------------------------------</TT>
<BR><TT></TT>&nbsp;
<BR><TT></TT>&nbsp;<TT></TT>
<P><TT>Copyright (c) 1994-7 Regents of the University of California</TT><TT></TT>
<P><TT>Permission to use, copy, modify, and distribute this software and
its</TT>
<BR><TT>documentation for any purpose, without fee, and without a written
agreement</TT>
<BR><TT>is hereby granted, provided that the above copyright notice and
this</TT>
<BR><TT>paragraph and the following two paragraphs appear in all copies.</TT><TT></TT>
<P><TT>IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
PARTY FOR</TT>
<BR><TT>DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
INCLUDING</TT>
<BR><TT>LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS</TT>
<BR><TT>DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED
OF THE</TT>
<BR><TT>POSSIBILITY OF SUCH DAMAGE.</TT><TT></TT>
<P><TT>THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,</TT>
<BR><TT>INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY</TT>
<BR><TT>AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER
IS</TT>
<BR><TT>ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATIONS
TO</TT>
<BR><TT>PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.</TT>
</BODY>
</HTML>

View File

@ -0,0 +1,19 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
</head>
<body bgcolor="#FEFEDF">
<h2>
Documentation</h2>
<hr WIDTH="100%">
<p>Still need to be written. Some information can be found in the help
included in the main program.
<p>Jim Lemon &lt;Jim.Lemon@uts.EDU.AU> has started writing a <a href="tutorial/index.html">tutorial</a>.
Thought it is based on earlier versions than 0.98 it is a beginning after
all, isn't it ?
</body>
</html>

View File

@ -0,0 +1,42 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
</head>
<body bgcolor="#FEFEDF">
<h2>
Download</h2>
<hr>
<br>The primary site for PgAccess downloads is:
<ul><a href="ftp://ftp.flex.ro/pub/pgaccess">ftp://ftp.flex.ro/pub/pgaccess</a>
<ul>
<li>
<a href="ftp://ftp.flex.ro/pub/pgaccess/pgaccess-0.98.tar.gz">Unix tar.gz
file</a></li>
<li>
<a href="ftp://ftp.flex.ro/pub/pgaccess/pgaccess-0.98.zip">Windows .zip
file</a></li>
</ul>
</ul>
<p>Another one (just with a little bit faster, try this one first) would
be :
<ul><a href="ftp://speedy.flex.ro/pub/pgaccess">ftp://speedy.flex.ro/pub/pgaccess</a>
<ul>
<li>
<a href="ftp://speedy.flex.ro/pub/pgaccess/pgaccess-0.98.tar.gz">Unix tar.gz
file</a></li>
<li>
<a href="ftp://speedy.flex.ro/pub/pgaccess/pgaccess-0.98.zip">Windows .zip
file</a></li>
</ul>
</ul>
<br>&nbsp;
</body>
</html>

View File

@ -0,0 +1,85 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.12 i586) [Netscape]">
</head>
<body bgcolor="#FEFEDF">
<h2>
PgAccess - FAQ</h2>
<hr>
<br><b>1. When I run PgAccess I got a message complaining about the crypt
library! What should I do?</b>
<blockquote>Versions of PostgreSQL prior to 6.5.1 couldn't reliably detect
the presence of the crypt library on RedHat 5.x systems. That's why the
libpgtcl library does not include reference to crypt. You will need to
get a proper copy of libpgtcl.so library or to compile one. Go to the postgresql
source directory into src/interfaces/libpgtcl and edit Makefile adding
-lcrypt to the end of the line SHLIB_LINKS. Make clean and make again.
Your libpgtcl.so is now prepare to run PgAccess. I strongly recommend you
to upgrade to PostgreSQL 6.5.1 where this problem has been solved.</blockquote>
<b>2. I cannot connect to a database from another machine</b>
<blockquote>There may be two problems here. First of all, PgAccess running
on the localhost is using two PostgreSQL dependent libraries, libpq and
libpgtcl. Each of them are compiled for a specific PostgreSQL version.
If the PostgreSQL version running on your server is different you might
experience problems. The other problem is related to access rights. On
the PostgreSQL server, in data directory there is a file pg_hba.conf that
will grant access rights to users based on host authentication. Ask your
database administrator to check if your workstation is listed there with
the appropriate access rights. Try for the beginning the 'trust' mode,
allowing full access to the databases.</blockquote>
<b>3. I am experiencing core dumps when trying to run PgAccess. Is PgAccess
broken?</b>
<blockquote>No. There were NEVER reported crashes because of PgAccess.
All of them were related to bad libraries usage. The most frequent was
the installing of a new PostgreSQL on a RedHat 5.x server where the postgresql-clients
rpm still exists. So, PgAccess was trying to use the old libpgtcl.so library
suitable for an older version of PostgreSQL. Before installing a new PostgreSQL
(either by compiling it ot by rpm packages) remove ANY TRACE of old PostgreSQL.
PgAccess is fully relying on libpgtcl library in order to get access to
the database so when you are experiencing that kind of problems, double-check
libpq and libpgtcl libraries.</blockquote>
<b>4. When I try to run PgAccess I get the following error : Application
initialization failed: couldn't connect to display ""</b>
<blockquote>That kind of error was reported on some Linux RedHat 5.x systems
when user has su - to root and tried to run PgAccess. Some unknown errors
in login scripts are not defining the DISPLAY environment and the wish
application cannot connect to the X display. Try typing <tt>export DISPLAY=localhost:0.0</tt>
and run PgAccess again.</blockquote>
<b>5. Cannot run PgAccess on a Windows machine.</b>
<blockquote>In order to use PgAccess on Windows you must have installed
two libraries libpq.dll and libpgtcl.dll suitable for your Tcl/Tk package
and your PostgreSQL server. Note that libraries that work with Tcl/Tk 8.0.x
won't work with Tcl/Tk 8.1.x and libraries that work with 6.4.2 backend
won't work with 6.5.x. So, you must properly identify your Tcl/Tk package
version and your PostgreSQL version and download from the Downloads section
(or pick from the win32/dll directory of PgAccess distribution) the right
files. Copy them into your Windows/System directory and try again. Also,
you should be able to access over the network the machine running the PostgreSQL
server (try ping-ing it) and have the proper access rights to the database.</blockquote>
<b>6. How much costs PgAccess?</b>
<blockquote>PgAccess is a free tool. You won't have to pay anything in
order to use it. It is protected by the following <a href="copyright.html">copyright</a>
as PostgreSQL is. I cannot guarantee technical support but I will try to
answer to your questions as much as I can.</blockquote>
<b>7. I want to translate PgAccess messages for xxx language. What should
I do?</b>
<blockquote>In the PgAccess distribution in lib/languages directory there
are files with messages translated for different languages. Copy one of
them and name it after your native language and then start editing it translating
all the messages. Save it into the same directory and that's all. Don't
forget to send me a copy in order to include it into the standard distribution.</blockquote>
<p><br><b>8. I am receiving the following error: <tt>message invalid command
name "namespace" while executing "namespace eval Mainlib</tt>&nbsp; ..."</b>
<blockquote>That means 100% that you have an older version of Tcl/Tk that
don't recognize namespaces command. Please upgrade to Tcl/Tk 8.0.x minimum</blockquote>
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
</body>
</html>

View File

@ -0,0 +1,52 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
</head>
<body bgcolor="#FEFEDF">
<b>Tables</b>
<br>- opening multiple tables for viewing, max. n records (changed by preferences
menu)
<br>- column resizing, dragging the vertical grid line (better in table
space rather than in the table header)
<br>- text wrap in cells - layout saved for every table
<br>- import/export to external files (SDF,CSV)
<br>- filter capabilities (enter filter like (price>3.14)
<br>- sort order capabilities (enter manually the sort field(s))
<br>- editing in place
<br>- improved table generator assistant
<br>- improved field editing
<br><b>Queries</b>
<br>- define , edit and stores "user defined queries"
<br>- store queries as views
<br>- execution of queries with optional user input parameters ( select
* from invoices where year=[parameter "Year of selection"] )
<br>- viewing of select type queries result
<br>- query deleting and renaming
<br>- visual query builder with drag &amp; drop capabilities. For any of
you who had installed the Tcl/Tk plugin for Netscape Navigator, you can
see it at work <a href="qbtclet.html">clicking here</a>
<br><b>Sequences</b>
<br>- defines sequences, delete them and inspect them
<br><b>Functions</b>
<br>- define, inspect and delete functions in SQL, plpgsql and pgtcl languages
<br><b>Reports</b>
<br>- design and display simple reports from tables
<br>- fields and labels, font changing, style and size
<br>- saves and loads report description from database
<br>- show report previews, sample postscript output file
<br><b>Forms</b>
<br>- open user defined forms
<br>- form design module available
<br>- query widget available, controls bound to query results
<br>- <a href="forms.html">click here</a> for a description of forms and
how they can be used
<br><b>Scripts</b>
<br>- define, modify and call user defined scripts
<br><b>Users</b>
<br>- define and modify user information
<p><b><a href="api.html">PgAccess API</a></b> for developing small applications
<br>&nbsp;
</body>
</html>

View File

@ -0,0 +1,216 @@
\connect - teo
CREATE SEQUENCE "cities_id_seq" start 7 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
SELECT nextval ('cities_id_seq');
CREATE TABLE "pga_queries" (
"queryname" character varying(64),
"querytype" character,
"querycommand" text,
"querytables" text,
"querylinks" text,
"queryresults" text,
"querycomments" text);
CREATE TABLE "pga_forms" (
"formname" character varying(64),
"formsource" text);
CREATE TABLE "pga_scripts" (
"scriptname" character varying(64),
"scriptsource" text);
CREATE TABLE "pga_reports" (
"reportname" character varying(64),
"reportsource" text,
"reportbody" text,
"reportprocs" text,
"reportoptions" text);
CREATE TABLE "phonebook" (
"name" character varying(32),
"phone_nr" character varying(16),
"city" character varying(32),
"company" bool,
"continent" character varying(16));
CREATE TABLE "pga_layout" (
"tablename" character varying(64),
"nrcols" int2,
"colnames" text,
"colwidth" text);
CREATE TABLE "pga_schema" (
"schemaname" character varying(64),
"schematables" text,
"schemalinks" text);
REVOKE ALL on "pga_schema" from PUBLIC;
GRANT ALL on "pga_schema" to PUBLIC;
CREATE TABLE "cities" (
"id" int4 DEFAULT nextval('"cities_id_seq"') NOT NULL,
"name" character varying(32) NOT NULL,
"prefix" character varying(16) NOT NULL);
CREATE FUNCTION "getcityprefix" (int4 ) RETURNS varchar AS 'select prefix from cities where id = $1 ' LANGUAGE 'SQL';
COPY "pga_queries" FROM stdin;
Query that can be saved as view S select * from phonebook where continent='usa' \N \N \N \N
\.
COPY "pga_forms" FROM stdin;
Working with Tables namespace f3 13 {3 4 5 6 7 9 10 11 12 13} 377x263+59+127 {radio usa {36 24 138 36} {} USA selcont} {radio europe {36 45 141 60} {} Europe selcont} {radio africa {36 66 147 81} {} Africa selcont} {label label6 {9 99 339 114} {} {Select one of the above continents and press} {}} {button button7 {270 93 354 117} {Tables::open phonebook "continent='$selcont'" $selorder} {Show them} {}} {button button9 {66 189 312 213} {Tables::design phonebook} {Show me the phonebook table structure} {}} {button button10 {141 228 240 252} {destroy .f3} {Close the form} {}} {button button11 {93 141 282 165} {Tables::open phonebook "company=true"} {Show me only the companies} {}} {radio name {183 24 261 36} {} {Order by name} selorder} {radio phone_nr {183 45 267 57} {} {Order by phone number} selorder}
A simple demo form asdf 14 {FS {set color none}} 370x310+50+75 {label label1 {15 36 99 57} {} {Selected color} {} label1 flat #000000 #d9d9d9 1} {entry entry2 {111 36 225 54} {} entry2 color entry2 sunken #000000 #fefefe 1} {radio red {249 21 342 36} {} {Red as cherry} color red flat #900000 #d9d9d9 1} {radio green {249 45 342 60} {} {Green as a melon} color green flat #008800 #d9d9d9 1} {radio blue {249 69 342 84} {} {Blue as the sky} color blue flat #00008c #d9d9d9 1} {button button6 {45 69 198 99} {set color spooky} {Set a weird color} {} button6 ridge #0000b0 #dfbcdf 2} {label label7 {24 129 149 145} {} {The checkbox's value} {} label7 flat #000000 #d9d9d9 1} {entry entry8 {162 127 172 145} {} entry8 cbvalue entry8 sunken #000000 #fefefe 1} {checkbox checkbox9 {180 126 279 150} {} {Check me :-)} cbvalue checkbox9 flat #000000 #d9d9d9 1} {button button10 {219 273 366 303} {destroy .asdf} {Close that simple form} {} button10 raised #000000 #d9d9d9 1} {button button11 {219 237 366 267} {Forms::open "Phone book"} {Open my phone book} {} button11 raised #000000 #d9d9d9 1} {listbox lb {12 192 162 267} {} listbox12 {} lb sunken #000000 #fefefe 1} {button button13 {12 156 162 186} {.asdf.lb insert end red green blue cyan white navy black purple maroon violet} {Add some information} {} button13 raised #000000 #d9d9d9 1} {button button14 {12 273 162 303} {.asdf.lb delete 0 end} {Clear this listbox} {} button14 raised #000000 #d9d9d9 1}
Working with listboxes f2 5 {FS {set thestudent ""}} 257x263+139+147 {listbox lb {6 6 246 186} {} listbox1 {} lb sunken #000000 #ffffd4 1} {button button2 {9 234 124 258} {# Populate the listbox with some data\
#\
\
foreach student {John Bill Doe Gigi} {\
\ .f2.lb insert end $student\
}\
\
\
\
# Binding the event left button release to the\
# list box\
\
bind .f2.lb <ButtonRelease-1> {\
\ set idsel [.f2.lb curselection]\
\ if {$idsel!=""} {\
\ \ set thestudent [.f2.lb get $idsel]\
\ }\
}\
\
# Cleaning the variable thestudent\
\
set thestudent {}} {Show students} {} button2 groove #000000 #d9d9d9 2} {button button3 {132 234 247 258} {destroy .f2} {Close the form} {} button3 groove #000000 #d9d9d9 1} {label label4 {9 213 119 228} {} {You have selected} {} label4 flat #000000 #d9d9d9 1} {label label5 {129 213 219 228} {} {} thestudent label5 flat #00009a #d9d9d9 1}
The simplest form mf 5 {FS {set thename {}}} 306x136+82+146 {label label {42 45 99 60} {} Name {} label flat #000000 #d9d9d9 1 {Helvetica 12 bold italic}} {entry ename {120 42 219 63} {} entry2 thename ename sunken #000000 #fefefe 1 n} {button button3 {6 96 108 129} {set thename Teo} {Set the name} {} button3 raised #000000 #d9d9d9 1 n} {button button4 {192 96 300 129} {destroy .mf} {Close the form} {} button4 raised #000000 #d9d9d9 1 n} {button button5 {114 96 186 129} {set thename {}} {Clear it} {} button5 raised #000000 #d9d9d9 1 n}
Full featured form full 21 {FS {set entrydemo {nice}\
set color {no color selected}}} 377x418+50+130 {label label1 {3 396 165 411} {} {Status line} {} {} sunken #000000 #d9d9d9 2 n} {label label2 {171 396 369 411} {} {Grooved status line} {} {} groove #000098 #d9d9d9 2 f} {label label3 {108 9 270 31} {} { Full featured form} {} {} ridge #000000 #d9d9d9 4 {Times 16 bold italic}} {button button4 {15 210 144 243} {.full.lb insert end {it's} a nice demo form} {Java style button} {} {} groove #6161b6 #d9d9d9 2 b} {label label5 {15 42 115 58} {} {Java style label} {} {} flat #6161b6 #d9d9d9 1 b} {entry entry6 {123 39 279 60} {} entry6 entrydemo {} groove #000000 #fefefe 2 {Courier 13}} {listbox lb {12 69 147 201} {} listbox8 {} {} ridge #000000 #ffffc8 2 n} {button button9 {18 264 39 282} {} 1 {} {} flat #000000 #d9d9d9 1 n} {button button10 {48 264 68 282} {} 2 {} {} flat #000000 #d9d9d9 1 n} {button button11 {78 264 234 282} {} {and other hidden buttons} {} {} flat #000000 #d9d9d9 1 n} {text txt {153 69 372 201} {} text12 {} {} sunken #000000 #d4ffff 1 n} {button button13 {150 210 369 243} {.full.txt tag configure bold -font {Helvetica 12 bold}\
.full.txt tag configure italic -font {Helvetica 12 italic}\
.full.txt tag configure large -font {Helvetica -14 bold}\
.full.txt tag configure title -font {Helvetica 12 bold italic} -justify center\
.full.txt tag configure link -font {Helvetica -12 underline} -foreground #000080\
.full.txt tag configure code -font {Courier 13}\
.full.txt tag configure warning -font {Helvetica 12 bold} -foreground #800000\
\
# That't the way help files are written\
\
.full.txt delete 1.0 end\
.full.txt insert end {Centered title} {title} "\
\
You can make different " {} "portions of text bold" {bold} " or italic " {italic} ".\
Some parts of them can be written as follows" {} "\
SELECT * FROM PHONEBOOK" {code} "\
You can also change " {} "colors for some words " {warning} "or underline them" {link} } {Old style button} {} {} raised #000000 #d9d9d9 2 n} {checkbox checkbox14 {48 297 153 309} {} different {} {} flat #00009c #d9d9d9 1 b} {checkbox checkbox15 {48 321 156 336} {} {fonts and} {} {} flat #cc0000 #d9d9d9 1 i} {checkbox checkbox16 {48 345 156 360} {} colors {} {} flat #00b600 #dfb2df 1 f} {radio radio17 {207 297 330 315} {} {red , rosu , rouge} color red flat #9c0000 #d9d9d9 1 n} {radio radio18 {207 321 324 333} {} {green , verde , vert} color green flat #009000 #d9d9d9 1 n} {radio radio19 {207 345 327 363} {} {blue , albastru, bleu} color blue flat #000000 #d9d9d9 1 n} {label selcolor {210 369 345 384} {} {} color {} flat #000000 #d9d9d9 1 n} {button button21 {285 258 363 285} {destroy .full} Exit {} {} raised #7c0000 #dfdbb8 1 b}
Phone book pb 28 {FS {}} 444x307+284+246 {label label1 {33 10 68 28} {} Name {} label1 flat #000000 #d9d9d9 1 n} {entry name_entry {87 9 227 27} {} entry2 DataSet(.pb.qs,name) name_entry sunken #000000 #fefefe 1 n} {label label3 {33 37 73 52} {} Phone {} label3 flat #000000 #d9d9d9 1 n} {entry entry4 {87 36 195 54} {} entry4 DataSet(.pb.qs,phone_nr) entry4 sunken #000000 #fefefe 1 n} {label label5 {33 64 78 82} {} City {} label5 flat #000000 #d9d9d9 1 n} {entry entry6 {87 63 195 81} {} entry6 DataSet(.pb.qs,city) entry6 sunken #000000 #fefefe 1 n} {query qs {3 6 33 33} {} query7 {} qs flat {} {} 1 n} {button button8 {174 177 246 203} {namespace eval DataControl(.pb.qs) {\
\ setSQL "select oid,* from phonebook where name ~* '$what' order by name"\
\ open\
\ set nrecs [getRowCount]\
\ updateDataSet\
\ fill .pb.allnames name\
\ bind .pb.allnames <ButtonRelease-1> {\
\ set ancr [.pb.allnames curselection]\
\ if {$ancr!=""} {\
\ \ DataControl(.pb.qs)::moveTo $ancr\
\ \ DataControl(.pb.qs)::updateDataSet\
\ }\
\ }\
}} {Start search} {} button8 raised #000000 #d9d9d9 1 n} {button button9 {363 276 433 300} {DataControl(.pb.qs)::close\
DataControl(.pb.qs)::clearDataSet\
set nrecs {}\
set what {}\
destroy .pb\
} Exit {} button9 raised #000000 #d9d9d9 2 n} {button button10 {291 237 313 257} {namespace eval DataControl(.pb.qs) {\
\ moveFirst\
\ updateDataSet\
}\
} |< {} button10 ridge #000092 #d9d9d9 2 n} {button button11 {324 237 346 257} {namespace eval DataControl(.pb.qs) {\
\ movePrevious\
\ updateDataSet\
}\
} << {} button11 ridge #000000 #d9d9d9 2 n} {button button12 {348 237 370 257} {namespace eval DataControl(.pb.qs) {\
\ moveNext\
\ updateDataSet\
}} >> {} button12 ridge #000000 #d9d9d9 2 n} {button button13 {381 237 403 257} {namespace eval DataControl(.pb.qs) {\
\ moveLast\
\ updateDataSet\
}\
} >| {} button13 ridge #000088 #d9d9d9 2 n} {checkbox checkbox14 {33 87 126 105} {} {Is it a company ?} DataSet(.pb.qs,company) checkbox14 flat #000000 #d9d9d9 1 n} {radio usa {63 108 201 120} {} U.S.A. DataSet(.pb.qs,continent) usa flat #000000 #d9d9d9 1 n} {radio europe {63 126 204 141} {} Europe DataSet(.pb.qs,continent) europe flat #000000 #d9d9d9 1 n} {radio africa {63 144 210 159} {} Africa DataSet(.pb.qs,continent) africa flat #000000 #d9d9d9 1 n} {entry entry18 {129 180 169 198} {} entry18 what entry18 sunken #000000 #fefefe 1 n} {label label19 {108 219 188 234} {} {records found} {} label19 flat #000000 #d9d9d9 1 n} {label label20 {90 219 105 234} {} { } nrecs label20 flat #000000 #d9d9d9 1 n} {label label21 {3 252 33 267} {} OID= {} label21 flat #000000 #d9d9d9 1 n} {label label22 {39 252 87 267} {} { } pbqs(oid) label22 flat #000000 #d9d9d9 1 n} {button button23 {9 276 79 300} {set oid {}\
catch {set oid $DataSet(.pb.qs,oid)}\
if {[string trim $oid]!=""} {\
sql_exec noquiet "update phonebook set name='$DataSet(.pb.qs,name)', phone_nr='$DataSet(.pb.qs,phone_nr)',city='$DataSet(.pb.qs,city)',company='$DataSet(.pb.qs,company)',continent='$DataSet(.pb.qs,continent)' where oid=$oid"\
} else {\
tk_messageBox -title Error -message "No record is displayed!"\
}\
\
} Update {} button23 raised #000000 #d9d9d9 1 n} {button button24 {210 276 280 300} {set thisname $DataSet(.pb.qs,name)\
if {[string trim $thisname] != ""} {\
\ sql_exec noquiet "insert into phonebook values (\
\ \ '$DataSet(.pb.qs,name)',\
\ \ '$DataSet(.pb.qs,phone_nr)',\
\ \ '$DataSet(.pb.qs,city)',\
\ \ '$DataSet(.pb.qs,company)',\
\ \ '$DataSet(.pb.qs,continent)'\
\ )"\
\ tk_messageBox -title Information -message "A new record has been added!"\
} else {\
\ tk_messageBox -title Error -message "This one doesn't have a name?"\
}\
\
} {Add record} {} button24 raised #000000 #d9d9d9 1 n} {button button25 {141 276 204 300} {DataControl(.pb.qs)::clearDataSet\
# clearcontrols stillinitialise\
# incorectly booleans controls to {}\
# so I force it to 'f' (false)\
set DataSet(.pb.qs,company) f\
focus .pb.name_entry} {Clear all} {} button25 raised #000000 #d9d9d9 1 n} {listbox allnames {249 6 435 231} {} listbox26 {} allnames sunken #000000 #fefefe 1 n} {label label27 {33 252 90 267} {} {} DataSet(.pb.qs,oid) label27 flat #000000 #d9d9d9 1 n} {label label28 {3 182 128 197} {} {Find name containing} {} {} flat #000000 #d9d9d9 1 n}
\.
COPY "pga_scripts" FROM stdin;
How are forms keeped inside ? Tables::open pga_forms\
\
\
\
Opening a table with filters Tables::open phonebook "name ~* 'e'" "name desc"\
\
\
Autoexec Mainlib::tab_click Forms\
Forms::open {Full featured form}\
\
\
\.
COPY "pga_reports" FROM stdin;
My phone book phonebook set PgAcVar(report,tablename) "phonebook" ; set PgAcVar(report,y_rpthdr) 21 ; set PgAcVar(report,y_pghdr) 47 ; set PgAcVar(report,y_detail) 66 ; set PgAcVar(report,y_pgfoo) 96 ; set PgAcVar(report,y_rptfoo) 126 ; .pgaw:ReportBuilder.c create text 10 35 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -anchor nw -text {name} -tags {t_l mov ro} ; .pgaw:ReportBuilder.c create text 10 52 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -anchor nw -text {name} -tags {f-name t_f rg_detail mov ro} ; .pgaw:ReportBuilder.c create text 141 36 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -anchor nw -text {city} -tags {t_l mov ro} ; .pgaw:ReportBuilder.c create text 141 51 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -anchor nw -text {city} -tags {f-city t_f rg_detail mov ro} ; .pgaw:ReportBuilder.c create text 231 35 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -anchor nw -text {phone_nr} -tags {t_l mov ro} ; .pgaw:ReportBuilder.c create text 231 51 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -anchor nw -text {phone_nr} -tags {f-phone_nr t_f rg_detail mov ro} \N \N
\.
COPY "phonebook" FROM stdin;
FIAT 623463445 t europe
Gelu Voican 01-32234 Bucuresti f europe
Radu Vasile 01-5523423 Bucuresti f europe
MUGADUMBU SRL +92 534662634 Cairo t africa
Jimmy Page 66323452 f europe
IBM 623346234 \N t usa
John Doe +44 35 2993825 Washington f usa
Bill Clinton +44 35 9283845 New York f usa
Monica Levintchi +44 38 5234526 Dallas f usa
Bill Gates +42 64 4523454 Los Angeles f usa
COMPAQ 623462345 \N t usa
SUN 784563253 \N t usa
DIGITAL 922644516 \N t usa
Frank Zappa 6734567 Montreal f usa
Constantin Teodorescu +40 39 611820 Braila f europe
Ngbendu Wazabanga 34577345 f africa
Mugabe Kandalam 7635745 f africa
Vasile Lupu 52345623 Bucuresti f europe
Gica Farafrica +42 64 4523454 Los Angeles f usa
Victor Ciorbea 634567 Bucuresti f europe
\.
COPY "pga_layout" FROM stdin;
pga_forms 2 formname formsource 82 713
Usaisti 5 name phone_nr city company continent 150 150 150 150 150
q1 5 name phone_nr city company continent 150 150 150 150 150
view_saved_from_that_query 5 name phone_nr city company continent 150 150 150 150 150
phonebook 5 name phone_nr city company continent 150 105 80 66 104
Query that can be saved as view 5 name phone_nr city company continent 150 150 150 150 150
cities 3 id name prefix 150 150 150
\.
COPY "pga_schema" FROM stdin;
Simple schema cities 10 10 phonebook 201.0 84.0 {cities name phonebook city}
\.
COPY "cities" FROM stdin;
3 Braila 4039
4 Galati 4036
5 Dallas 5362
6 Cairo 9352
1 Bucuresti 4013
7 Montreal 5325
\.
CREATE UNIQUE INDEX "cities_id_key" on "cities" using btree ( "id" "int4_ops" );

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,203 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
</head>
<body text="#000000" bgcolor="#FEFEDF" link="#0000EF" vlink="#51188E" alink="#FF0000">
<h1>
FORMS</h1>
<hr WIDTH="100%">
<p>This version (0.97) of PgAccess has changed the form API : variable
handling, query results interface and control bindings naming convention.
Please read it carefully, download the database demo and practice a while
before trying to design your own forms.
<p>For the moment, it has only some basic widgets : labels, entries, buttons
, listboxes , checkboxes and radiobuttons.
<p>Also there is a pseudo data control widget that allows you yo have access
to a query results.
<p><b>How do you generate widgets :</b>
<ol>
<li>
select a widget from the toolbox by clicking the appropriate radiobutton</li>
<li>
move to the canvas , point with the mouse at the desired location and click
the mouse button to begin</li>
<li>
keeping the mouse-button pressed move the mouse in order to draw a rectangle
that will hold the widget</li>
<li>
release the mouse-button</li>
</ol>
In the rectangle that you have designed it will appear the selected object.
<br>Move now to the attribute window to change some of its properties.
<p>Renaming, resizing items are possible (for the moment) only by modifying
appropriate parameters in attribute window. You <b>must </b>press Enter
in the edit field after changing a value in order to be accepted.
<p>You can also move items by dragging them or delete them by pressing
Del key after selecting them.
<p>In attribute window, there are some fields named <b><tt><font size=+1>Command
</font></tt></b>and
<b><tt><font size=+1>Variable</font></tt></b>.
<p>The field <b><tt><font size=+1>Command </font></tt></b>have meaning
only for Button widgets and holds the command that will be invoked when
the button is pressed.
<p>&nbsp;&nbsp;&nbsp; The field <b><tt><font size=+1>Variable </font></tt></b>have
meaning only for EditField , Label widgets , checkboxes and radiobuttons
and it is the name of the global variable that will hold the value for
that widget. For checkboxes the values are <b>t</b> and <b>f</b> (from
true and false) in order to simplify binding to logical data fields (PgAccess
0.82 used 0 and 1).
<p>&nbsp;&nbsp;&nbsp; For radiobuttons, it is usual to assign the same
variable to the same radiobuttons within the same group. That variable
will contain the name of the widget of the radiobutton that has been pressed.
Let's presume that you have entered 3 radiobuttons named red, green and
blue, all of them having the same variable named color. If you will press
them, they will assign their names to global variable.
<p>&nbsp;&nbsp;&nbsp; In order to make a simple test, put an entry field
and set it's variable to <b>v1</b> and a button who's command is "set v1
whisky". Press the button "Test form" and click on the button. In that
entry should appear whisky.
<br>Another test is defining in Script module a script called "My first
script" having the following commands:
<br><tt><font size=+1>tk_messageBox -title Warning -message "This is my
first message!"</font></tt>
<br>and then define a button who's command is <b><tt><font size=+1>execute_script
"My first script"</font></tt></b>.
<br>&nbsp;
<h2>
Database manipulation</h2>
Let's presume that our form have the internal name <b><tt>mf </tt></b>(<b>m</b>y
<b>f</b>orm). Don't forget that the Tk window names could not start with
an uppercase letter.
<br>The window will be referred inside the Tcl/Tk source as <b><tt>.mf</tt></b>
<br>If you want to close the form in run-time you have to issue the command
<b><tt>destroy
.mf</tt></b>
<p>Also, any widget created inside this window (form) will have the name
prefixed by <b><tt>.mf ,</tt></b>so we will have <b><tt>.mf.button1</tt></b>
or <b><tt>.mf.listbox1</tt></b> .
<p>We can name the data control widget <b><tt>dc</tt></b> for example.
The fully qualified name for that "virtual widget" will be <b><tt>.mf.dc</tt></b>
then. A new namespace called <b><tt>DataControl(.mf.dc)</tt></b> will be
automatically defined.
<br>The <b><tt>Command </tt></b>property of the data control widget must
contain the SQL command that will be executed.
<br>When the form will be in run-time, automatically you will have access
to the following procedures and functions from the namespace:
<p><b><tt>open</tt></b> - opens the connection and execute the query (returns
nothing)
<br><b><tt>setSQL newsql</tt></b> - set the command query that will be
executed at the next <b><tt>open</tt></b>
<br><b><tt>getRowCount</tt></b> - returns the number of records of the
result set
<br><b><tt>getRowIndex </tt></b>- returns the current record number inside
the result set
<br><b><tt>getFieldList</tt></b> - returns a Tcl list containing the fields
names from the current result set
<br><b><tt>moveFirst</tt></b> - move the cursor to the first record in
the recordset
<br><b><tt>moveLast</tt></b><tt> , <b>moveNext</b> , <b>movePrevious</b></tt>-
moves the cursor there
<br><b><tt>moveTo newrecno</tt></b> - move the cursor to that new record
number (first is 0)
<br><b><tt>updateDataSet</tt></b> - update the variables inside the designed
form that have a particular name (I'll explain later)
<br><b><tt>clearDataSet</tt></b> - clear the associated DataSet variables
<br><tt><b>fill listbox field</b> </tt>- fill the named listbox (whole
widget name as <b><tt>.mf.listbox1</tt></b>) with the all the values of
that field from the current result set
<br><b><tt>close</tt></b> - close the result set (<b><font color="#FF0000">if
you don't close it, you will loose some memory</font></b>)
<p>These procedures and functions should be called in the normal Tcl namespace
mode as in the following example:
<p><tt>DataControl(.mf.dc)::setSQL "select * from phonebook"</tt>
<br><tt>DataControl(.mf.dc)::open</tt>
<br><tt>set nrecs [DataControl(.mf.dc)::getRowCount]</tt>
<p>If you complaint about writting to many DataControl(...) you can include
many commands into a single namespace eval as in the following example
:
<p><tt>namespace eval DataControl(.mf.dc) {</tt>
<br><tt>&nbsp;&nbsp;&nbsp; setSQL "select * from phonebook"</tt>
<br><tt>&nbsp;&nbsp;&nbsp; open</tt>
<br><tt>&nbsp;&nbsp;&nbsp; set nrecs [getRowCount]</tt>
<br><tt>&nbsp;&nbsp;&nbsp; moveLast</tt>
<br><tt>&nbsp;&nbsp;&nbsp; updateDataSet</tt>
<br><tt>}</tt>
<p>It's no need to close a query-result set if you want to assign it a
new SQL command and open it again. That will be done automatically releasing
the memory used for the last result set.
<br>Opening a new <b>DataControl</b> will automatically position the current
row index of the result set on the first row (index 0) and will define
a new global associative array named <b>DataSet</b> that will hold data
from the current row. The key into that array will be the fully qualified
name of the data control widget followed by a comma and the name of every
field in the selected rows.
<p><i>Example:</i>
<br><tt>DataSet(.mf.dc,name)</tt>
<br><tt>DataSet(.mf.dc,city)</tt>
<p>If you want to bound some controls to the fields of the recordset, you
will have to name their associate variable like that :
<p><b><tt>DataSet(.mf.dc,salary)</tt></b> to get the "salary" field , or
<b><tt>DataSet(.mf.dc,name)</tt></b> to get the "name" field. Using the
data control procedures <b><tt>DataControl(.mf.dc)::moveNext</tt></b> or
movePrevious will automatically update the <b><tt>DataSet(.mf.dc,...)</tt></b>
array so the database information from entries in the form will be refreshed.
<br>&nbsp;
<p>Here it is a dumped <b><a href="formdemo.sql">sample database</a></b>
that contains a demo database. What should you do ?
<br>Shift-click the above URL in order to download that tiny file (4 Kb).
Create a empty database and <b><tt>psql yourdatabase &lt;formdemo.sql</tt></b>
<p>You should find a single table called "phonebook" a form called "Phone
book" and another "A simple demo form".
<p>First of all enter and view the phonebook table in table view. Note
the fields and their values.
<br>Open the "Phone book" form and enter a letter (a, e or i) in the field
to the left of "Find" button then press Find. It's fine to enter one letter
in order to get more records in query result. You will get information
about the number of records selected, in the listbox you will see all the
values of field "name" from the current data set. Use buttons to move to
first, next, previous or last record within the record set.
<p>In order to add a new record, press the "New" button in order to get
new, clean entries. Fill them with your data and press "Add new" button.
A new phonebook record will be added. Also, if you want to update a record,
change it's values in the displayed fields after finding it and press "Update"
button. The values will be updated in the database BUT NOT IN THE CURRENT
QUERY RESULT . If you want to see them modified, make a new query trying
to find it again.
<p><font color="#000080">Before using the results from a query you should
know that the information that has been retrieved could be found only in
your computer client memory. It has <b>no live connection</b> to the data
from the database. That's why it isn't possible to develop a simple update
function as interface to that query-result widget. More than that : a query
result could be obtained from a SQL command that return a non-updatable
data set !!! For example fields gathered from multiple tables or summary
fields. It isn't just simple to make an automatic update procedure. The
programmer must know how to make the update or the append procedure, sometimes
using key fields to point to the desired record or an OID. There are examples
in the demo database in "Phone book" form. It may be possible that in the
future, I will develop another pseudo-widget describing a table. It would
be more simple than to implement an update or append or even a delete procedure.</font>
<p>There is in the demo database also another simple form called "A simple
demo form". It will show you how to handle variables from checkboxes, radiobuttons,
how to use listboxes, open another forms and so on. I think they will help
you.
<p>In order to avoid naming user defined forms with&nbsp; a particular
name of another PgAccess form, I would recommend naming them as udf0, udf1
(user defined form 0 , 1 )
<p>
<hr WIDTH="25%">
<p>Please feel free to send me your opinion at <b>teo@flex.ro</b> on forms
designing and usage.
<p><b><font size=+1>KEEP IN MIND !&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
THE FORM API MAY CHANGE IN ORDER TO BE MORE SIMPLE AND BETTER!</font></b>
<br><b><font size=+1>SEND ME YOUR WISHES, YOUR IDEAS, YOUR OPINIONS !</font></b>
<br><b><font size=+1>ALSO ... DON'T BLAME ME IF YOU WILL HAVE TO RE-DESIGN
YOUR OLD FORMS DUE TO SOME INCOMPATIBILITIES WITH NEWER PGACCESS VERSIONS.</font></b>
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -0,0 +1,11 @@
<HTML>
<HEAD>
<TITLE>PgAccess</TITLE>
<FRAMESET COLS="200,*" border=0 framespacing=0 frameborder=no>
<FRAME NAME="left" scrolling="none" src="contents.html">
<FRAME NAME="right" scrolling="nonw" src="main.html">
</FRAMESET>
</HTML>

View File

@ -0,0 +1,133 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>PgAccess on Irix</TITLE>
<META NAME="GENERATOR" CONTENT="Mozilla/3.04Gold (X11; I; Linux 2.0.33 i586) [Netscape]">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
<H1>INSTALLING PgAccess UNDER IRIX 5.3.
<HR WIDTH="100%"></H1>
<P><B><FONT COLOR="#000080">This HOWO-TO make PgAccess working under Irix
is written by Stuart Rison</FONT></B></P>
<P>These are the steps that I had to follow to get pgaccess to run on an
INDIGO2 running postgreSQL 6.3.2 under IRIX 5.3. I make no guarantee whatsoever
that the same step will work for others but at least it should point you
in the right direction. Also, I am a biologist by training so I only got
pgaccess working by fudging (that is, trial and error) this means that
some of the steps may be unnecessary (e.g. compiling $postgreSQL_source/src/interfaces/libpgtcl
as both a shared and static library) and they certainly haven't been optimised
(I know nothing about compiler switches etc.).</P>
<P><B>1) Requirements:</B></P>
<UL>
<P>You will need:</P>
<UL>
<LI>postgreSQL source (http://www.postgresql.org)</LI>
<LI>tcl8.0 source (http://www.tclconsortium.org/)</LI>
<LI>tk8.0 source (http://www.tclconsortium.org/)</LI>
<LI>pgaccess source (http://www.flex.ro/pgaccess)</LI>
</UL>
</UL>
<P><B>2) Installation:</B></P>
<P>a) tcl/tk:</P>
<UL>
<P>You must first install tcl and then tk (in that order). I just used
./configure, no switches and gmake. Their installation should be trouble
free. Then you must move headers and libraries to the right places so:</P>
<P>Header files: both tcl and tk have a header file (tcl.h and tk.h). The
tcl.h file is in $tcl_source_dir/generic and the tk.h file is in $tk_source_dir/generic;
both should be copied to /usr/local/include.</P>
<P>Libraries: compilation (with cc) of tcl and tk yield libraries libtcl8.0.a
and libtk8.0.a in $source_dir/unix. Both should be copied to /usr/local/lib.</P>
</UL>
<P>b) postgreSQL:</P>
<UL>
<P>Make sure you have a fully patched postgreSQL source. If your ./configure
says it can't load 'IRIX' settings then you most probably will need to
patch ./configure.</P>
<P>Configure using ./configure with the following switches: ./configure
--with-includes=/usr/local/include</P>
<P>--with-libraries=/usr/local/lib --with-tcl [this and previous line as
one]</P>
<P>Then make, make install as usual</P>
</UL>
<P>c) Compiling libpgtcl:</P>
<UL>
<P>The source for libpgtcl is in $postgreSQL_directory/src/interfaces/libpgsql.</P>
<P>I do this twice. Once with just gmake. This produces a static library
libpgtcl.a which I leave where it is (I don't know what to do with it but
it may just come in handy). The I modify Makefile manually with a text
editor. Essentially I modify two line:</P>
<P>before:</P>
<P># Shared library stuff</P>
<P>install-shlib-dep := shlib :=</P>
<P>after:</P>
<P># Shared library stuff</P>
<P>install-shlib-dep := install-shlib shlib := libpgtcl.so.1</P>
<P>Then gmake -f Makefile_modified. This creates two shared (.so) libraries:
libpgtcl.so and libpgtcl.so.1. I can't tell the difference between them
so I copied them both to /usr/lib/.</P>
</UL>
<P>d) running pgaccess:</P>
<UL>
<P>Uncompress pgaccess (usually with gunzip and tar). So long as 'wish'
(a binary produced when compiling tk8.0) is somewhere in your path, you
should be able to run pgaccess with:</P>
<P>wish -f $pgaccess_dir/pgaccess.tcl [postgreSQL_database_name]</P>
</UL>
<P>e) et voila!</P>
<P><B>3) Concluding remarks:</B></P>
<UL>
<P>As I stated at the start of this document, following the procedure indicated
above worked for me. I am sure, however, that a few of the steps are unnecessary/non-optimised/stupid
etc. If any Unix (IRIX) boffin is reading this and you spot anything you
would like to comment/correct etc. please e-mail me (stuart@ludwig.ucl.ac.uk).
Also, if you just have questions and think I might help, please contact
me at the same e-mail.</P>
<P>Finally, I can accept no responsibility if these steps don't work for
you or if it all goes horribly wrong and you 'damage' your computer trying
them. Let common sense prevail!</P>
</UL>
<P>Good luck</P>
<P>Stuart Rison LICR University College London London W1P 8BT<BR>
<A HREF="mailto:stuart@ludwig.ucl.ac.uk">stuart@ludwig.ucl.ac.uk</A></P>
</BODY>
</HTML>

Binary file not shown.

After

Width:  |  Height:  |  Size: 789 B

View File

@ -0,0 +1,43 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE></TITLE>
<META NAME="GENERATOR" CONTENT="Mozilla/3.04Gold (X11; I; Linux 2.0.32 i586) [Netscape]">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
<P>The mailing list for PgAccess is : &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B><TT>pgsql-interfaces@postgresql.org</TT></B></P>
<P>If you have some questions regarding PgAccess you should mail to this
address. I will also answer to messages addresed directly to me but it
would be better to post your messages here because it might be possible
to get an answer quickly from another user of PgAccess.</P>
<P>
<HR WIDTH="100%"></P>
<P>To subscribe please send a mail message to&nbsp;:</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B><TT><FONT SIZE=+1>pgsql-interfaces-request@postgresql.org
</FONT></TT></B>&nbsp;</P>
<P>having a single line in the body message :&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<B><TT><FONT SIZE=+1>subscribe</FONT></TT></B></P>
<P>In a couple of minutes , if everything is ok, you must receive something
like that :</P>
<P>
<HR WIDTH="100%"></P>
<P><TT>Welcome to the pgsql-interfaces mailing list!</TT></P>
<P><TT>Please save this message for future reference. Thank you.</TT></P>
<P><TT>If you ever want to remove yourself from this mailing list, you
can send mail to &lt;Majordomo@hub.org&gt; with the following command in
the body of your email message:</TT></P>
<P><TT>unsubscribe pgsql-interfaces yourname@yourdomain</TT></P>
<TT></TT>
</BODY>
</HTML>

View File

@ -0,0 +1,34 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.12 i586) [Netscape]">
</head>
<body bgcolor="#FEFEDF">
<h1>
PgAccess
<hr WIDTH="100%"></h1>
A free graphical database management tool for <a href="http://www.postgresql.org">PostgreSQL</a>.
PgAccess has been written by <a href="mailto:teo@flex.ro">Constantin Teodorescu</a>
using Visual Tcl, the best tool for developing Tcl/Tk applications I've
ever seen.
<p><b>Last version</b>
<br>Last stable version is 0.98 , released on 29 August 1999. Read <a href="whatsnew.html">what's
new</a> in 0.98.
<p><b>Portability issues</b>
<br>PgAccess is available for every platform where PostgreSQL was ported
and where a Tcl/Tk package is available. PgAccess has been reported running
on :
<br>- Linux
<br>- FreeBSD
<br>- Solaris
<br>- HPUX
<br>- Irix
<br>- Windows 95,98,NT
<p>PgAccess needs Tcl/Tk versions 8.0.x and higher thought PgAccess. For
win32 platforms there are some special DLL's that have to be downloaded
and installed, more information <a href="win32.html">here</a>.
<p>PgAccess is protected by the following <a href="copyright.html">copyright</a>.
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -0,0 +1,143 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
<title>PgAccess - a Tcl/Tk PostgreSQL interface</title>
</head>
<body bgcolor="#FFFFFF">
<h1>
PgAccess - a free database management tool for <a href="http://www.postgreSQL.org">PostgreSQL</a></h1>
<hr>
<li>
Download the last version of PgAccess <a href="pgaccess-0.96.tar.gz">(press
shift and click this link) (tar.gz file)</a>&nbsp; or&nbsp;&nbsp; <a href="pgaccess.zip">this
one (zip file for Windows)</a></li>
<center>
<p><br>Latest stable version of PgAccess is 0.97 , released 16 August 1999
!
<p><font size=+2>PgAccess 0.93 and higher will not work from the beginning
with PostgreSQL 6.3.x !!</font>
<br><font size=+2>Read <a href="pg93patch.html">here</a> how to apply a
simple patch in order to make it work !</font></center>
<b><font color="#000000"><font size=+2></font></font></b>
<center><table BORDER=2 NOSAVE >
<tr NOSAVE>
<td NOSAVE><b><font color="#FF0000"><font size=+2>NEW</font></font></b></td>
<td NOSAVE><b><font color="#000000"><font size=+2>International version
(english, french, italian, romanian)</font></font></b></td>
</tr>
<tr NOSAVE>
<td NOSAVE><b><font color="#FF0000"><font size=+2>NEW</font></font></b></td>
<td><b><font size=+2>Context sensitive Help</font></b></td>
</tr>
</table></center>
<center>
<p>Precompiled libpgtcl and libpq binaries and dll's for i386 are <a href="ftp://ftp.flex.ro/pub/pgaccess">here
</a>!!!</center>
<h3>
<font color="#000080">Installation problems</font></h3>
<ul>
<li>
Some problems related with locale special characters could be solved by
this <a href="specialchars.html">simple patch</a></li>
<li>
I think that there were some problems loading libpgtcl library. I invite
you to read a <a href="index.html#libpgtcl">special section concerning
libpgtcl</a></li>
<li>
For Silicon Graphics Indigo computers, Irix operating system, there is
a <a href="irix.html">HOWTO make PgAccess to work</a></li>
</ul>
<h3>
<font color="#191970">What does PgAccess now!</font></h3>
Here are some screenshots from PgAccess windows : <a href="pic-pga-1.gif">Main
window </a>, <a href="pic-pga-2.gif">table builder </a>, <a href="pic-pga-4.gif">table(query)
view </a>, <a href="pic-pga-3.gif">visual query builder </a>.
<p><b>Tables</b>
<br>- opening multiple tables for viewing, max. n records (changed by preferences
menu)
<br>- column resizing, dragging the vertical grid line (better in table
space rather than in the table header)
<br>- text wrap in cells - layout saved for every table
<br>- import/export to external files (SDF,CSV)
<br>- filter capabilities (enter filter like (price>3.14)
<br>- sort order capabilities (enter manually the sort field(s))
<br>- editing in place
<br>- improved table generator assistant
<br>- improved field editing
<br><b>Queries</b>
<br>- define , edit and stores "user defined queries"
<br>- store queries as views
<br>- execution of queries with optional user input parameters ( select
* from invoices where year=[parameter "Year of selection"] )
<br>- viewing of select type queries result
<br>- query deleting and renaming
<br>- visual query builder with drag &amp; drop capabilities. For any of
you who had installed the Tcl/Tk plugin for Netscape Navigator, you can
see it at work <a href="qbtclet.html">clicking here</a>
<br><b>Sequences</b>
<br>- defines sequences, delete them and inspect them
<br><b>Functions</b>
<br>- define, inspect and delete functions in SQL, plpgsql and pgtcl languages
<br><b>Reports</b>
<br>- design and display simple reports from tables
<br>- fields and labels, font changing, style and size
<br>- saves and loads report description from database
<br>- show report previews, sample postscript output file
<br><b>Forms</b>
<br>- open user defined forms
<br>- form design module available
<br>- query widget available, controls bound to query results
<br>- <a href="forms.html">click here</a> for a description of forms and
how they can be used
<br><b>Scripts</b>
<br>- define, modify and call user defined scripts
<br><b>Users</b>
<br>- define and modify user information
<p>Here is <a href="pga-rad.html">a special section concerning forms and
scripts</a> .
<p>This program is protected by the following <a href="copyright.html">copyright</a>
<p>If you have any comment, suggestion for improvements, please feel free
to e-mail to : <a href="mailto:teo@flex.ro">teo@flex.ro</a>
<p><b><font color="#FF1493"><font size=+2>Mailing list for PgAccess </font></font></b><a href="maillist.html">Here
you will find how to subscribe to this mailing list</a>.
<p>
<hr>
<h1>
More information about libpgtcl - downloads</h1>
&nbsp;&nbsp;&nbsp;&nbsp; Also, you will need the PostgreSQL to Tcl interface
library, lined as a Tcl/Tk 'load'-able module. It is called libpgtcl and
the source is located in the PostgreSQL directory /src/interfaces/libpgtcl.
Specifically, you will need a libpgtcl library that is 'load'-able from
Tcl/Tk.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; This is technically different from
an ordinary PostgreSQL loadable object file, because libpgtcl is a collection
of object files. Under Linux, this is called libpgtcl.so.
<p>&nbsp;&nbsp;&nbsp;&nbsp; One of the solutions is to remove from the
source the line containing <b>load libpgtcl.so </b>and to load pgaccess.tcl
not with wish, but with pgwish (or wishpg) that wish that was linked with
libpgtcl library! I do not recommend this one.
<p>&nbsp;&nbsp;&nbsp;&nbsp; If you have installed RedHat 5.x, you should
get the last distribution kit of PostgreSQL and compile it from scratch.
RedHat 5.x is using some new versions of libraries and you have to compile
and install again at least <b>libpq </b>and <b><tt>libpgtcl </tt></b>libraries.
<p>&nbsp;&nbsp;&nbsp; PostgreSQL 6.4 release has a minor bug. I does not
include by default the crypt lib when compiling libpgtcl. So, you will
need to manually add a -lcrypt to SHLIB line in Makefile in src/interfaces/libpgtcl
and then make clean and make again. The new libpgtcl.so library is properly
configured to run pgaccess.
<br>&nbsp;
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

View File

@ -0,0 +1,25 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.5 [en] (X11; I; Linux 2.0.36 i586) [Netscape]">
</head>
<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#FF0000" alink="#000088">
<h1>
PgAccess 0.93 patch to make it work with PostgreSQL 6.3.x
<hr WIDTH="100%"></h1>
<p><br>PgAccess 0.93 is working fine with PostgreSQL 6.4.x due to some
changes in libpgtcl !
<p>There is a small patch that you have to make in order to make it work
with 6.3.x !
<p>Replace in procedure <tt>wpg_exec</tt> the following line:
<p><tt>set pgsql(errmsg) [pg_result $pgsql(res) -error]</tt>
<p>with this one :
<p><tt>set pgsql(errmsg) "NO ERROR INFORMATION SUPPLIED"</tt>
<p>And it will work fine! In some error cases, you will not get the appropriate
error message from libpgtcl.
<p>&nbsp;<a href="index.html">Back</a>
</body>
</html>

View File

@ -0,0 +1,65 @@
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i586) [Netscape]">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
<H1>
PgAccess - Scripts and Forms&nbsp;
<HR WIDTH="100%"></H1>
Beginning with 0.70 version, I have introduced in PgAccess two new modules
for operating with scripts and forms.
<P>&nbsp;&nbsp; This would give to PgAccess the power of creating application
directly into PgAccess, defining new modules, procedures, forms and possibly
making it a rapid development tool for PostgreSQL. The "scripts" and "forms"
modules are using two new tables called pga_forms and pga_scripts. PgAccess
take care of creating them if user is opening a new database and grant
ALL permissions on them to PUBLIC.
<BR>&nbsp;
<BR>&nbsp;&nbsp; Of course, when Designing a script, a simple text editor
is opened and text is saved as is in pga_scripts table. When "designing"
a form, a "form editor" that would be very similar with "Visual Tcl" is
invoked.
<P>&nbsp;&nbsp; This mechanism and the extremely versatile scripting mode
of Tcl/Tk would give PgAccess a great power for creating end user application
using PostgreSQL. The most important thing is that the user could call
procedures and functions that I have used for building up PgAccess !
<H3>
Forms</H3>
&nbsp;&nbsp; Forms are used for creating windows and placing widgets inside
it. When PgAccess interpret them, a new window appear, with buttons as
defined that could call "user defined scripts", "user defined procedures"
or "internal PgAccess procedures".
<BR>&nbsp;&nbsp; Forms can hold all the widgets allowed in Tcl/Tk , buttons,
check-boxes, radio-buttons, list-boxes, frames, canvases, etc. With these
forms, you can control your application so PgAccess would become just a
"shell", a startup point for you applications. See the&nbsp; <A HREF="forms.html">special
section concerning forms.</A>
<H3>
Scripts</H3>
&nbsp;&nbsp; Scripts are normal Tcl/Tk code that is interpreted by Tcl/Tk.
You can define your own procedures inside a script called "Library" for
example. You can call your procedures from within another script, from
another procedure.
<BR>&nbsp;&nbsp; The most important thing is that you have total access
to the PgAccess core of functions and procedures used by me in building
PgAccess as an application. Just write <B><TT><FONT COLOR="#000080">open_table
"Your sample table"</FONT></TT></B> and you'll see the result.
<BR>&nbsp;&nbsp; If you are writing a script called "Autoexec" then it
will be executed every time the database is opened. You can put inside
different commands that you want to be executed such as : running scripts
that would define your own procedures such as <B><TT><FONT COLOR="#000080">execute_script
"My own procedure library"</FONT></TT></B> or open a form with <B><TT><FONT COLOR="#000080">open_form
"Main window with menu buttons"</FONT></TT></B> , and so on.
<P>
<HR WIDTH="100%">
<BR>Remember : I'm waiting your messages at <A HREF="mailto:teo@flex.ro">teo@flex.ro</A>
<P>
<HR WIDTH="50%">
</BODY>
</HTML>

View File

@ -0,0 +1,45 @@
<html>
<title> Visual Query Builder in Tcl/Tk </title>
<body bgcolor=white>
<h1> Visual Query Builder</h1>
<hr>
This visual query builder is included in <a href='http://www.flex.ro/pgaccess'>
PgAccess</a>, a visual interface to
<a href='http://www.postgreSQL.org'> PostgreSQL</a> written entirely in
vTcl , (Visual Tcl).
<p align="center">
<embed src="qbtclet.tcl" width=590 height=485>
</p>
<br>
Visual Query Designer demo<br>
Click <a href='qbtclet.tar.gz'>here</a> to download the source </a>
created by Constantin Teodorescu with vTcl (visual Tcl), teo@flex.ro
<hr>
Facitilies<br>
- drag and drop selection of fields<br>
- drag and drop fields from a table to another do create links<br>
- move table position by dragging<br>
- point and click any link or table then press delete to delete them<br>
- modify sort order by clicking on (unsorted)<br>
- enter filter conditions as criteria (>2000 , ='item')<br>
- easy panning of table and result panels<br>
- show SQL command<br>
<br>
If you want to use it for your database, modify ql_read_struct in order to read
your table structure.
<br>
Feel free to use, modify or copy this software for non-commercial purposes.<br>
In any other case, please contact me.
<br>
FLEX Consulting Braila, ROMANIA is able to deliver high end interfaces
and any other commercial products written in Tcl/Tk just like that you have seen.
</body>
</html>

View File

@ -0,0 +1,529 @@
#################################
# GLOBAL VARIABLES
#
global qlvar;
global widget;
#################################
# USER DEFINED PROCEDURES
#
proc init {argc argv} {
global qlvar
set qlvar(yoffs) 360
set qlvar(xoffs) 50
set qlvar(reswidth) 150
}
init $argc $argv
proc main {argc argv} {
}
proc show_message {usrmsg} {
global msg
set msg $usrmsg
after 2000 {set msg {}}
}
proc ql_delete_object {} {
global qlvar
# Checking if there
set obj [.c find withtag hili]
if {$obj==""} return
if {[ql_get_tag_info $obj link]=="s"} {
# if {[tk_messageBox -title WARNING -icon question -message "Remove link ?" -type yesno -default no]=="no"} return
show_message "Deleting the link from tables ..."
set linkid [ql_get_tag_info $obj lkid]
set qlvar(links) [lreplace $qlvar(links) $linkid $linkid]
.c delete links
ql_draw_links
} else {
set tablename [ql_get_tag_info $obj tab]
if {$tablename==""} return
# if {[tk_messageBox -title WARNING -icon question -message "Remove table $tablename from query ?" -type yesno -default no]=="no"} return
show_message "Deleting table from query ..."
for {set i [expr [llength $qlvar(restables)]-1]} {$i>=0} {incr i -1} {
if {$tablename==[lindex $qlvar(restables) $i]} {
set qlvar(resfields) [lreplace $qlvar(resfields) $i $i]
set qlvar(restables) [lreplace $qlvar(restables) $i $i]
set qlvar(rescriteria) [lreplace $qlvar(rescriteria) $i $i]
}
}
for {set i [expr [llength $qlvar(links)]-1]} {$i>=0} {incr i -1} {
set thelink [lindex $qlvar(links) $i]
if {($tablename==[lindex $thelink 0]) || ($tablename==[lindex $thelink 2])} {
set qlvar(links) [lreplace $qlvar(links) $i $i]
}
}
.c delete tab$tablename
.c delete links
ql_draw_links
ql_draw_res_panel
}
}
proc ql_dragit {w x y} {
global draginfo
if {"$draginfo(obj)" != ""} {
set dx [expr $x - $draginfo(x)]
set dy [expr $y - $draginfo(y)]
if {$draginfo(is_a_table)} {
set taglist [.c gettags $draginfo(obj)]
set tabletag [lindex $taglist [lsearch -regexp $taglist "^tab"]]
$w move $tabletag $dx $dy
ql_draw_links
} else {
$w move $draginfo(obj) $dx $dy
}
set draginfo(x) $x
set draginfo(y) $y
}
}
proc ql_dragstart {w x y} {
global draginfo
catch {unset draginfo}
set draginfo(obj) [$w find closest $x $y]
if {[ql_get_tag_info $draginfo(obj) r]=="ect"} {
# If it'a a rectangle, exit
set draginfo(obj) {}
return
}
. configure -cursor hand1
.c raise $draginfo(obj)
set draginfo(table) 0
if {[ql_get_tag_info $draginfo(obj) table]=="header"} {
set draginfo(is_a_table) 1
.c itemconfigure [.c find withtag hili] -fill black
.c dtag [.c find withtag hili] hili
.c addtag hili withtag $draginfo(obj)
.c itemconfigure hili -fill blue
} else {
set draginfo(is_a_table) 0
}
set draginfo(x) $x
set draginfo(y) $y
set draginfo(sx) $x
set draginfo(sy) $y
}
proc ql_dragstop {x y} {
global draginfo qlvar
. configure -cursor top_left_arrow
set este {}
catch {set este $draginfo(obj)}
if {$este==""} return
# Re-establish the normal paint order so
# information won't be overlapped by table rectangles
# or link linkes
.c lower $draginfo(obj)
.c lower rect
.c lower links
set qlvar(panstarted) 0
if {$draginfo(is_a_table)} {
set draginfo(obj) {}
.c delete links
ql_draw_links
return
}
.c move $draginfo(obj) [expr $draginfo(sx)-$x] [expr $draginfo(sy)-$y]
if {($y>$qlvar(yoffs)) && ($x>$qlvar(xoffs))} {
# Drop position : inside the result panel
# Compute the offset of the result panel due to panning
set resoffset [expr [lindex [.c bbox resmarker] 0]-$qlvar(xoffs)]
set newfld [.c itemcget $draginfo(obj) -text]
set tabtag [ql_get_tag_info $draginfo(obj) tab]
set col [expr int(($x-$qlvar(xoffs)-$resoffset)/$qlvar(reswidth))]
set qlvar(resfields) [linsert $qlvar(resfields) $col $newfld]
set qlvar(ressort) [linsert $qlvar(ressort) $col unsorted]
set qlvar(rescriteria) [linsert $qlvar(rescriteria) $col {}]
set qlvar(restables) [linsert $qlvar(restables) $col $tabtag]
ql_draw_res_panel
} else {
# Drop position : in the table panel
set droptarget [.c find overlapping $x $y $x $y]
set targettable {}
foreach item $droptarget {
set targettable [ql_get_tag_info $item tab]
set targetfield [ql_get_tag_info $item f-]
if {($targettable!="") && ($targetfield!="")} {
set droptarget $item
break
}
}
# check if target object isn't a rectangle
if {[ql_get_tag_info $droptarget rec]=="t"} {set targettable {}}
if {$targettable!=""} {
# Target has a table
# See about originate table
set sourcetable [ql_get_tag_info $draginfo(obj) tab]
if {$sourcetable!=""} {
# Source has also a tab .. tag
set sourcefield [ql_get_tag_info $draginfo(obj) f-]
if {$sourcetable!=$targettable} {
lappend qlvar(links) [list $sourcetable $sourcefield $targettable $targetfield $draginfo(obj) $droptarget]
ql_draw_links
}
}
}
}
# Erase information about onbject beeing dragged
set draginfo(obj) {}
}
proc ql_draw_links {} {
global qlvar
.c delete links
set i 0
foreach link $qlvar(links) {
# Compute the source and destination right edge
set sre [lindex [.c bbox tab[lindex $link 0]] 2]
set dre [lindex [.c bbox tab[lindex $link 2]] 2]
# Compute field bound boxes
set sbbox [.c bbox [lindex $link 4]]
set dbbox [.c bbox [lindex $link 5]]
# Compute the auxiliary lines
if {[lindex $sbbox 2] < [lindex $dbbox 0]} {
# Source object is on the left of target object
set x1 $sre
set y1 [expr ([lindex $sbbox 1]+[lindex $sbbox 3])/2]
.c create line $x1 $y1 [expr $x1+10] $y1 -tags [subst {links lkid$i}] -width 3
set x2 [lindex $dbbox 0]
set y2 [expr ([lindex $dbbox 1]+[lindex $dbbox 3])/2]
.c create line [expr $x2-10] $y2 $x2 $y2 -tags {links} -width 3
.c create line [expr $x1+10] $y1 [expr $x2-10] $y2 -tags [subst {links lkid$i}] -width 2
} else {
# source object is on the right of target object
set x1 [lindex $sbbox 0]
set y1 [expr ([lindex $sbbox 1]+[lindex $sbbox 3])/2]
.c create line $x1 $y1 [expr $x1-10] $y1 -tags [subst {links lkid$i}] -width 3
set x2 $dre
set y2 [expr ([lindex $dbbox 1]+[lindex $dbbox 3])/2]
.c create line $x2 $y2 [expr $x2+10] $y2 -width 3 -tags [subst {links lkid$i}]
.c create line [expr $x1-10] $y1 [expr $x2+10] $y2 -tags [subst {links lkid$i}] -width 2
}
incr i
}
.c lower links
.c bind links <Button-1> {ql_link_click %x %y}
}
proc ql_draw_lizzard {} {
global qlvar
ql_read_struct
.c delete all
set posx 20
for {set it 0} {$it<$qlvar(ntables)} {incr it} {
ql_draw_table $it
# set posy 10
# set tablename $qlvar(tablename$it)
# .c create text $posx $posy -text $tablename -anchor nw -tags [subst {tab$tablename f-oid mov tableheader}] -font -Adobe-Helvetica-Bold-R-Normal-*-*-120-*-*-*-*-*
# incr posy 16
# foreach fld $qlvar(tablestruct$it) {
# .c create text $posx $posy -text $fld -anchor nw -tags [subst {f-$fld tab$tablename mov}] -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
# incr posy 14
# }
# set reg [.c bbox tab$tablename]
# .c create rectangle [lindex $reg 0] [lindex $reg 1] [lindex $reg 2] [lindex $reg 3] -fill #EEEEEE -tags [subst {rect tab$tablename}]
# .c create line [lindex $reg 0] [expr [lindex $reg 1]+15] [lindex $reg 2] [expr [lindex $reg 1]+15] -tags [subst {rect tab$tablename}]
# set posx [expr $posx+40+[lindex $reg 2]-[lindex $reg 0]]
}
.c lower rect
.c create line 0 $qlvar(yoffs) 10000 $qlvar(yoffs) -width 3
.c create rectangle 0 $qlvar(yoffs) 10000 5000 -fill #FFFFFF
for {set i [expr 15+$qlvar(yoffs)]} {$i<500} {incr i 15} {
.c create line $qlvar(xoffs) $i 10000 $i -fill #CCCCCC -tags {resgrid}
}
for {set i $qlvar(xoffs)} {$i<10000} {incr i $qlvar(reswidth)} {
.c create line $i [expr 1+$qlvar(yoffs)] $i 10000 -fill #cccccc -tags {resgrid}
}
# Make a marker for result panel offset calculations (due to panning)
.c create line $qlvar(xoffs) $qlvar(yoffs) $qlvar(xoffs) 500 -tags {resmarker resgrid}
.c create rectangle 0 $qlvar(yoffs) $qlvar(xoffs) 5000 -fill #EEEEEE -tags {reshdr}
.c create text 5 [expr 1+$qlvar(yoffs)] -text Field: -anchor nw -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -tags {reshdr}
.c create text 5 [expr 16+$qlvar(yoffs)] -text Table: -anchor nw -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -tags {reshdr}
.c create text 5 [expr 31+$qlvar(yoffs)] -text Sort: -anchor nw -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -tags {reshdr}
.c create text 5 [expr 46+$qlvar(yoffs)] -text Criteria: -anchor nw -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -tags {reshdr}
.c bind mov <Button-1> {ql_dragstart %W %x %y}
.c bind mov <B1-Motion> {ql_dragit %W %x %y}
bind . <ButtonRelease-1> {ql_dragstop %x %y}
bind . <Button-1> {qlc_click %x %y %W}
bind . <B1-Motion> {ql_pan %x %y}
bind . <Key-Delete> {ql_delete_object}
set qlvar(resfields) {}
set qlvar(ressort) {}
set qlvar(rescriteria) {}
set qlvar(restables) {}
set qlvar(critedit) 0
set qlvar(links) {}
set qlvar(linktodelete) {}
}
proc ql_draw_res_panel {} {
global qlvar
# Compute the offset of the result panel due to panning
set resoffset [expr [lindex [.c bbox resmarker] 0]-$qlvar(xoffs)]
.c delete resp
for {set i 0} {$i<[llength $qlvar(resfields)]} {incr i} {
.c create text [expr $resoffset+4+$qlvar(xoffs)+$i*$qlvar(reswidth)] [expr 1+$qlvar(yoffs)] -text [lindex $qlvar(resfields) $i] -anchor nw -fill navy -tags {resf resp} -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
.c create text [expr $resoffset+4+$qlvar(xoffs)+$i*$qlvar(reswidth)] [expr 16+$qlvar(yoffs)] -text [lindex $qlvar(restables) $i] -anchor nw -tags {resp rest} -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
.c create text [expr $resoffset+4+$qlvar(xoffs)+$i*$qlvar(reswidth)] [expr 31+$qlvar(yoffs)] -text [lindex $qlvar(ressort) $i] -anchor nw -tags {resp sort} -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
if {[lindex $qlvar(rescriteria) $i]!=""} {
.c create text [expr $resoffset+4+$qlvar(xoffs)+$i*$qlvar(reswidth)] [expr $qlvar(yoffs)+46+15*0] -anchor nw -text [lindex $qlvar(rescriteria) $i] -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -tags [subst {resp cr-c$i-r0}]
}
}
.c raise reshdr
.c bind sort <Button-1> {ql_swap_sort %W %x %y}
}
proc ql_draw_table {it} {
global qlvar
set posy 10
set allbox [.c bbox rect]
if {$allbox==""} {set posx 10} else {set posx [expr 20+[lindex $allbox 2]]}
set tablename $qlvar(tablename$it)
.c create text $posx $posy -text $tablename -anchor nw -tags [subst {tab$tablename f-oid mov tableheader}] -font -Adobe-Helvetica-Bold-R-Normal-*-*-120-*-*-*-*-*
incr posy 16
foreach fld $qlvar(tablestruct$it) {
.c create text $posx $posy -text $fld -anchor nw -tags [subst {f-$fld tab$tablename mov}] -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
incr posy 14
}
set reg [.c bbox tab$tablename]
.c create rectangle [lindex $reg 0] [lindex $reg 1] [lindex $reg 2] [lindex $reg 3] -fill #EEEEEE -tags [subst {rect tab$tablename}]
.c create line [lindex $reg 0] [expr [lindex $reg 1]+15] [lindex $reg 2] [expr [lindex $reg 1]+15] -tags [subst {rect tab$tablename}]
}
proc ql_get_tag_info {obj prefix} {
set taglist [.c gettags $obj]
set tagpos [lsearch -regexp $taglist "^$prefix"]
if {$tagpos==-1} {return ""}
set thattag [lindex $taglist $tagpos]
return [string range $thattag [string length $prefix] end]
}
proc ql_link_click {x y} {
global qlvar
set obj [.c find closest $x $y 1 links]
if {[ql_get_tag_info $obj link]!="s"} return
.c itemconfigure [.c find withtag hili] -fill black
.c dtag [.c find withtag hili] hili
.c addtag hili withtag $obj
.c itemconfigure $obj -fill blue
}
proc ql_pan {x y} {
global qlvar
set panstarted 0
catch {set panstarted $qlvar(panstarted) }
if {!$panstarted} return
set dx [expr $x-$qlvar(panstartx)]
set dy [expr $y-$qlvar(panstarty)]
set qlvar(panstartx) $x
set qlvar(panstarty) $y
if {$qlvar(panobject)=="tables"} {
.c move mov $dx $dy
.c move links $dx $dy
.c move rect $dx $dy
} else {
.c move resp $dx 0
.c move resgrid $dx 0
.c raise reshdr
}
}
proc ql_read_struct {} {
global qlvar
set qlvar(ntables) 3
set qlvar(tablename0) Facturi
set qlvar(tablename1) Nommat
set qlvar(tablename2) Incasari
set qlvar(tablestruct0) [list factura client valoare tva]
set qlvar(tablestruct1) [list cod denumire pret greutate procent_tva]
set qlvar(tablestruct2) [list data valoare nrdoc referinta]
}
proc ql_show_sql {} {
global qlvar
set sqlcmd "select "
for {set i 0} {$i<[llength $qlvar(resfields)]} {incr i} {
if {$sqlcmd!="select "} {set sqlcmd "$sqlcmd, "}
set sqlcmd "$sqlcmd[lindex $qlvar(restables) $i].[lindex $qlvar(resfields) $i]"
}
set tables {}
for {set i 0} {$i<$qlvar(ntables)} {incr i} {
lappend tables $qlvar(tablename$i)
}
set sqlcmd "$sqlcmd from [join $tables ,] "
set sup1 {}
if {[llength $qlvar(links)]>0} {
set sup1 "where "
foreach link $qlvar(links) {
if {$sup1!="where "} {set sup1 "$sup1 and "}
set sup1 "$sup1 ([lindex $link 0].[lindex $link 1]=[lindex $link 2].[lindex $link 3])"
}
}
for {set i 0} {$i<[llength $qlvar(resfields)]} {incr i} {
set crit [lindex $qlvar(rescriteria) $i]
if {$crit!=""} {
if {$sup1==""} {set sup1 "where "}
if {[string range $sup1 0 4]=="where"} {set sup1 "$sup1 and "}
set sup1 "$sup1 ([lindex $qlvar(restables) $i].[lindex $qlvar(resfields) $i]$crit) "
}
}
set sqlcmd "$sqlcmd $sup1"
set sup2 {}
for {set i 0} {$i<[llength $qlvar(ressort)]} {incr i} {
set how [lindex $qlvar(ressort) $i]
if {$how!="unsorted"} {
if {$how=="Ascending"} {set how asc} else {set how desc}
if {$sup2==""} {set sup2 " order by "} else {set sup2 "$sup2,"}
set sup2 "$sup2 [lindex $qlvar(resfields) $i] $how "
}
}
set sqlcmd "$sqlcmd $sup2"
set qlvar(sql) $sqlcmd
#tk_messageBox -message $sqlcmd
.c delete sqlpage
.c create rectangle 0 0 2000 [expr $qlvar(yoffs)-1] -fill #ffffff -tags {sqlpage}
.c create text 10 10 -text $sqlcmd -anchor nw -width 550 -tags {sqlpage} -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
.c bind sqlpage <Button-1> {.c delete sqlpage}
}
proc ql_swap_sort {w x y} {
global qlvar
set obj [$w find closest $x $y]
set taglist [.c gettags $obj]
if {[lsearch $taglist sort]==-1} return
set cum [.c itemcget $obj -text]
if {$cum=="unsorted"} {
set cum Ascending
} elseif {$cum=="Ascending"} {
set cum Descending
} else {
set cum unsorted
}
set col [expr int(($x-$qlvar(xoffs))/$qlvar(reswidth))]
set qlvar(ressort) [lreplace $qlvar(ressort) $col $col $cum]
.c itemconfigure $obj -text $cum
}
proc qlc_click {x y w} {
global qlvar
set qlvar(panstarted) 0
if {$w==".c"} {
set canpan 1
if {$y<$qlvar(yoffs)} {
if {[llength [.c find overlapping $x $y $x $y]]!=0} {set canpan 0}
set qlvar(panobject) tables
} else {
set qlvar(panobject) result
}
if {$canpan} {
. configure -cursor hand1
set qlvar(panstartx) $x
set qlvar(panstarty) $y
set qlvar(panstarted) 1
}
}
set isedit 0
catch {set isedit $qlvar(critedit)}
# Compute the offset of the result panel due to panning
set resoffset [expr [lindex [.c bbox resmarker] 0]-$qlvar(xoffs)]
if {$isedit} {
set qlvar(rescriteria) [lreplace $qlvar(rescriteria) $qlvar(critcol) $qlvar(critcol) $qlvar(critval)]
.c delete cr-c$qlvar(critcol)-r$qlvar(critrow)
.c create text [expr $resoffset+4+$qlvar(xoffs)+$qlvar(critcol)*$qlvar(reswidth)] [expr $qlvar(yoffs)+46+15*$qlvar(critrow)] -anchor nw -text $qlvar(critval) -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -tags [subst {resp cr-c$qlvar(critcol)-r$qlvar(critrow)}]
set qlvar(critedit) 0
}
catch {destroy .entc}
if {$y<[expr $qlvar(yoffs)+46]} return
if {$x<[expr $qlvar(xoffs)+5]} return
set col [expr int(($x-$qlvar(xoffs)-$resoffset)/$qlvar(reswidth))]
if {$col>=[llength $qlvar(resfields)]} return
set nx [expr $col*$qlvar(reswidth)+8+$qlvar(xoffs)+$resoffset]
set ny [expr $qlvar(yoffs)+76]
# Get the old criteria value
set qlvar(critval) [lindex $qlvar(rescriteria) $col]
entry .entc -textvar qlvar(critval) -borderwidth 0 -background #FFFFFF -highlightthickness 0 -selectborderwidth 0 -font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-*
place .entc -x $nx -y $ny -height 14
focus .entc
bind .entc <Button-1> {set qlvar(panstarted) 0}
set qlvar(critcol) $col
set qlvar(critrow) 0
set qlvar(critedit) 1
}
proc Window {args} {
global vTcl
set cmd [lindex $args 0]
set name [lindex $args 1]
set newname [lindex $args 2]
set rest [lrange $args 3 end]
if {$name == "" || $cmd == ""} {return}
if {$newname == ""} {
set newname $name
}
set exists [winfo exists $newname]
switch $cmd {
show {
if {$exists == "1" && $name != "."} {wm deiconify $name; return}
if {[info procs vTclWindow(pre)$name] != ""} {
eval "vTclWindow(pre)$name $newname $rest"
}
if {[info procs vTclWindow$name] != ""} {
eval "vTclWindow$name $newname $rest"
}
if {[info procs vTclWindow(post)$name] != ""} {
eval "vTclWindow(post)$name $newname $rest"
}
}
hide { if $exists {wm withdraw $newname; return} }
iconify { if $exists {wm iconify $newname; return} }
destroy { if $exists {destroy $newname; return} }
}
}
set base ""
bind $base <B1-Motion> {
ql_pan %x %y
}
bind $base <Button-1> {
qlc_click %x %y %W
}
bind $base <ButtonRelease-1> {
ql_dragstop %x %y
}
bind $base <Key-Delete> {
ql_delete_object
}
canvas $base.c \
-background #fefefe -borderwidth 2 -height 207 -relief ridge \
-takefocus 0 -width 295
label $base.msg -textvar msg -borderwidth 1 -relief sunken
button $base.b2 \
-borderwidth 1 -command ql_draw_lizzard \
-font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -padx 9 \
-pady 3 -text {Paint demo tables}
button $base.showbtn \
-borderwidth 1 -command ql_show_sql \
-font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-* -padx 9 \
-pady 3 -text {Show SQL}
###################
# SETTING GEOMETRY
###################
place $base.c \
-x 5 -y 30 -width 578 -height 425 -anchor nw -bordermode ignore
place $base.b2 \
-x 5 -y 5 -height 26 -anchor nw -bordermode ignore
place $base.showbtn \
-x 130 -y 5 -height 26 -anchor nw -bordermode ignore
place $base.msg \
-x 5 -y 460 -width 578 -anchor nw
main $argc $argv

View File

@ -0,0 +1,43 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.12 i586) [Netscape]">
</head>
<body bgcolor="#FEFEDF">
<h3>
Image gallery
<hr WIDTH="100%"></h3>
<ul>
<li>
&nbsp;<a href="mainwindow.gif">Main window</a> 9 Kb</li>
<li>
&nbsp;<a href="newtable.gif">Creating a new table</a> 9 Kb</li>
<li>
&nbsp;<a href="permissions.gif">Table access control</a> 10 Kb</li>
<li>
&nbsp;<a href="addindex.gif">Adding a new index</a> 12 Kb</li>
<li>
&nbsp;<a href="vdesigner.gif">The visual query designer</a> 16 Kb</li>
<li>
&nbsp;<a href="function.gif">Working with functions</a> 10 Kb</li>
<li>
&nbsp;<a href="forms.gif">Form designer</a> 19 Kb</li>
<li>
&nbsp;<a href="newuser.gif">User management</a> 4 Kb</li>
<li>
&nbsp;<a href="help.gif">Help</a> 7 Kb</li>
</ul>
</body>
</html>

View File

@ -0,0 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Special locale characters</TITLE>
<META NAME="GENERATOR" CONTENT="Mozilla/3.04Gold (X11; I; Linux 2.0.32 i586) [Netscape]">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
<H1>Special locale characters and PgAccess
<HR WIDTH="100%"></H1>
<P>The problem is related with some special characters used in different
countries because PgAccess did not use fonts with `-ISO8859-1' encoding
-- </P>
<P>The sollution was proposed by H.P.Heidinger ( hph@hphbbs.ruhr.de) and
it's very simple.</P>
<P>If you look into PgAccess, you will find fonts declared as follows :</P>
<P><TT>$ grep -e '-font' -i pgaccess.tcl<BR>
-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* \<BR>
-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* \<BR>
-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* \<BR>
-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* \</TT></P>
<P>It should be something like: -adobe-helvetica-medium-r-normal-*-*-120-*-*-*-*-iso8859-1</P>
<P>You can achieve this by running the following script :</P>
<P><TT>#!/bin/sh<BR>
cp pgaccess.tcl pgaccess.tcl-org<BR>
cat pgaccess.tcl |\<BR>
sed -e's/\-\*\-\*\ /\-iso8859\-1\ /g' |\<BR>
sed -e's/\-\*\-\*\}/\-iso8859\-1}/g' |\<BR>
sed -e's/\-\*\-\*\]/\-iso8859\-1]/g' |\<BR>
sed -e's/\-\*\-\*$/\-iso8859\-1/g' |\<BR>
sed -e's/\-Clean\-/\-Fixed\-/g' |\<BR>
sed -e's/clean/fixed/g' &gt;pgaccess.iso<BR>
mv pgaccess.iso pgaccess.tcl<BR>
chmod +x pgaccess.tcl</TT></P>
<P>The final version of PgAccess (1.0) will let the user decide what fonts
will be used through a &quot;preferences&quot; dialog window.</P>
</BODY>
</HTML>

View File

@ -0,0 +1,11 @@
<html>
<body bgcolor="#FEFEDF">
<h2>ToDo List</h2><hr>
- Finish the report generator module<br>
- Enhance the form designer<br>
- Enhance the scripts module<br>
- Translations in other languages<br>
<br>
Please send any suggestions by mail to <a href="mailto:teo@flex.ro">Constantin Teodorescu</a>.
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

View File

@ -0,0 +1,33 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html><head><title>PgAccess - a Tcl/Tk interface for PostgreSQL</title></head>
<body bgcolor="#C0C0C0">
<h1>PgAccess - a Tcl/Tk interface for PostgreSQL</h1>
<hr>
<a name="intro">
<ul><li><a href="intro.html">Introduction</a>
<ul><li><a href="intro.html#whatpga">What is PgAccess?</a>
<li><a href="intro.html#helppga">How to get help with PgAccess</a>
</ul>
<a name="start">
<li><a href="start.html">Getting Started</a>
<ul><li><a href="start.html#getpga">How to get PgAccess</a>
<li><a href="start.html#uncpga">How to uncompress PgAccess</a>
<li><a href="start.html#putpga">Putting PgAccess where it will be found</a>
<li><a href="start.html#startpga">Starting PgAccess</a>
<li><a href="irix.html">Installing PgAccess under IRIX 5.3</a>
</ul>
<a name="problems">
<li><a href="problems.html">Common Initial Problems</a>
<ul><li><a href="problems.html#connfail">Connection failure</a>
<li><a href="problems.html#nonuser">User not defined</a>
<li><a href="problems.html#libpg">libpgtcl not found</a>
<li><a href="problems.html#spchar">Locale specific characters</a>
<li><a href="problems.html#pg63">Problems with PostgreSQL 6.3.x</a>
</ul>
<li><a href="tut.html">PgAccess tutorial</a>
<ul><li><a href="tut_user.html">User Administration</a>
<li><a href="tut_new.html">Creating a table</a>
<li><a href="tut_edit.html">Editing a table</a>
<li><a href="tut_sel1.html">Querying - SELECT</a>
</ul>
</body></html>

View File

@ -0,0 +1,39 @@
<html><head><title>PgAccess - Introduction</title></head>
<body bgcolor="#C0C0C0">
<h1>PgAccess - Introduction</h1>
<a name="whatpga"><h2>What is PgAccess?</h2>
PgAccess is a graphical user interface for the PostgreSQL database management
system written in the Tcl/Tk scripting language by Constantin Teodorescu. It
allows the user to interact with PostgreSQL in a manner similar to many PC
database applications, with menu choices and graphical tools like buttons.
This means that the user can avoid the basic command line interface for most
common tasks. PgAccess doesn't change the way PostgreSQL operates, just makes
it easier to use for those familiar with graphical interfaces.<p>
Obviously, you <u>must</u> have PostgreSQL installed and running, and Tcl/Tk on
your system before you can use PgAccess.<p>
PgAccess is an "open source" application. The source code is available to the
user, and may be modified by the user. The user can fix a bug, or change the
way a function operates. You may not want to get that involved with the
programming, but you have the option to do so. If you feel you have made an
improvement to the program, you are encouraged to share it with other users.<p>
If you are not familiar with how open source software can be altered and
redistributed, please read <a href="copyright.html">this</a>.<p>
<a name="helppga"><h2>How to get help with PgAccess</h2>
The mailing list for PgAccess is: <b>pgsql-interfaces@postgresql.org</b><p>
If you have any questions regarding PgAccess you should subscribe to this
list in the following way:<p>
First subscribe to the list by sending an email message to:<p>
<samp>pgsql-interfaces-request@postgresql.org</samp><p>
Send a single line in the body of the message as follows:<p>
<samp>subscribe</samp><p>
In a short time you should receive a message beginning like this:<p>
<samp>Welcome to the pgsql-interfaces mailing list!<br>
...</samp><p>
This will contain instructions on how to remove yourself from the mailing
list, so save that message. You may only want to ask a few questions and then
stop receiving messages.<p>
You may also email <a href="mailto:teo@flex.ro">Constantin Teodorescu</a>
directly, although writing to a mailing list with many correspondents will often
produce a quicker answer.<p>
<a href="index.html#intro">Back to index</a>
</body></html>

View File

@ -0,0 +1,133 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>PgAccess on Irix</TITLE>
<META NAME="GENERATOR" CONTENT="Mozilla/3.04Gold (X11; I; Linux 2.0.33 i586) [Netscape]">
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000EF" VLINK="#51188E" ALINK="#FF0000">
<H1>INSTALLING PgAccess UNDER IRIX 5.3.
<HR WIDTH="100%"></H1>
<P><B><FONT COLOR="#000080">This HOWO-TO make PgAccess working under Irix
is written by Stuart Rison</FONT></B></P>
<P>These are the steps that I had to follow to get pgaccess to run on an
INDIGO2 running postgreSQL 6.3.2 under IRIX 5.3. I make no guarantee whatsoever
that the same step will work for others but at least it should point you
in the right direction. Also, I am a biologist by training so I only got
pgaccess working by fudging (that is, trial and error) this means that
some of the steps may be unnecessary (e.g. compiling $postgreSQL_source/src/interfaces/libpgtcl
as both a shared and static library) and they certainly haven't been optimised
(I know nothing about compiler switches etc.).</P>
<P><B>1) Requirements:</B></P>
<UL>
<P>You will need:</P>
<UL>
<LI>postgreSQL source (http://www.postgresql.org)</LI>
<LI>tcl8.0 source (http://www.tclconsortium.org/)</LI>
<LI>tk8.0 source (http://www.tclconsortium.org/)</LI>
<LI>pgaccess source (http://www.flex.ro/pgaccess)</LI>
</UL>
</UL>
<P><B>2) Installation:</B></P>
<P>a) tcl/tk:</P>
<UL>
<P>You must first install tcl and then tk (in that order). I just used
./configure, no switches and gmake. Their installation should be trouble
free. Then you must move headers and libraries to the right places so:</P>
<P>Header files: both tcl and tk have a header file (tcl.h and tk.h). The
tcl.h file is in $tcl_source_dir/generic and the tk.h file is in $tk_source_dir/generic;
both should be copied to /usr/local/include.</P>
<P>Libraries: compilation (with cc) of tcl and tk yield libraries libtcl8.0.a
and libtk8.0.a in $source_dir/unix. Both should be copied to /usr/local/lib.</P>
</UL>
<P>b) postgreSQL:</P>
<UL>
<P>Make sure you have a fully patched postgreSQL source. If your ./configure
says it can't load 'IRIX' settings then you most probably will need to
patch ./configure.</P>
<P>Configure using ./configure with the following switches: ./configure
--with-includes=/usr/local/include</P>
<P>--with-libraries=/usr/local/lib --with-tcl [this and previous line as
one]</P>
<P>Then make, make install as usual</P>
</UL>
<P>c) Compiling libpgtcl:</P>
<UL>
<P>The source for libpgtcl is in $postgreSQL_directory/src/interfaces/libpgsql.</P>
<P>I do this twice. Once with just gmake. This produces a static library
libpgtcl.a which I leave where it is (I don't know what to do with it but
it may just come in handy). The I modify Makefile manually with a text
editor. Essentially I modify two line:</P>
<P>before:</P>
<P># Shared library stuff</P>
<P>install-shlib-dep := shlib :=</P>
<P>after:</P>
<P># Shared library stuff</P>
<P>install-shlib-dep := install-shlib shlib := libpgtcl.so.1</P>
<P>Then gmake -f Makefile_modified. This creates two shared (.so) libraries:
libpgtcl.so and libpgtcl.so.1. I can't tell the difference between them
so I copied them both to /usr/lib/.</P>
</UL>
<P>d) running pgaccess:</P>
<UL>
<P>Uncompress pgaccess (usually with gunzip and tar). So long as 'wish'
(a binary produced when compiling tk8.0) is somewhere in your path, you
should be able to run pgaccess with:</P>
<P>wish -f $pgaccess_dir/pgaccess.tcl [postgreSQL_database_name]</P>
</UL>
<P>e) et voila!</P>
<P><B>3) Concluding remarks:</B></P>
<UL>
<P>As I stated at the start of this document, following the procedure indicated
above worked for me. I am sure, however, that a few of the steps are unnecessary/non-optimised/stupid
etc. If any Unix (IRIX) boffin is reading this and you spot anything you
would like to comment/correct etc. please e-mail me (stuart@ludwig.ucl.ac.uk).
Also, if you just have questions and think I might help, please contact
me at the same e-mail.</P>
<P>Finally, I can accept no responsibility if these steps don't work for
you or if it all goes horribly wrong and you 'damage' your computer trying
them. Let common sense prevail!</P>
</UL>
<P>Good luck</P>
<P>Stuart Rison LICR University College London London W1P 8BT<BR>
<A HREF="mailto:stuart@ludwig.ucl.ac.uk">stuart@ludwig.ucl.ac.uk</A></P>
<a href="index.html#start">Back to index</a>
</BODY>
</HTML>

View File

@ -0,0 +1 @@
Cassileth, BR~Unorthodox Cancer Medicine~Cancer Investigation~~1986~4~6~591-598

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

View File

@ -0,0 +1,83 @@
<html><head><title>PgAccess - Common Problems</title></head>
<body bgcolor="#C0C0C0">
<h1>Common Problems with PgAccess</h1>
<a name="connfail"><h2>Connection failure</h2>
One of the most common initial problems is the message:<p>
<samp>Error connecting database<br>
Connection to database failed<br>
connectDB() failed: Is the<br>
postmaster running and<br>
accepting TCP/IP (with -i)<br>
connections at 'localhost' on<br>
port '5432'?</samp><p>
This usually occurs because the "postmaster" (the postgreSQL backend) was not
started with the <samp>-i</samp> option. Usually just adding <samp>-i</samp> to
the command line that starts the postmaster and restarting will fix this.<p>
If you have installed the prewritten script to start <b>postgreSQL</b>
automatically, this option is (currently) commented out:<p>
<samp># PGOPTS="-i"</samp><p>
just remove the hash and space and comment out the "blank" option above:<p>
<samp>PGOPTS=""</samp><p>
<a name="nonuser"><h2>User not defined</h2>
Initially, <b>postgreSQL</b> only has one user, <samp>postgres</samp>, and any
other user who starts up PgAccess will get the message:<p>
<samp>Error connecting database<br>
Connection to database failed<br>
FATAL 1: SetUserId: user<br>
'jim' is not in 'pg_shadow'</samp><p>
See <b>User Administration</b> in the <b>PgAccess tutorial</b> for a description
of how to create users.<p>
<a name="libpg"><h2>libpgtcl not found</h2>
PgAccess requires a library of functions named <samp>libpgtcl</samp>. This
should be available with the postgreSQL distribution, and is usually placed in
the correct location when installing postgreSQL. First check that there is a
file named <samp>libpgtcl.so</samp> (perhaps with a number appended - or
<samp>libpgtcl.dll</samp> on Windows systems) on your
system. If not, you will have to download and perhaps compile this library.<p>
<samp>ftp://ftp.flex.ro/pub/pgaccess</samp><p>
is one place that you can download precompiled libpgtcl libraries for
PgAccess.<p>
<a name="spchar">
<h2>Locale specific characters</h2>
This problem occurs with some special characters used in different
countries because PgAccess did not use fonts with `-ISO8859-1' encoding.<p>
One solution was proposed by H.P.Heidinger ( hph@hphbbs.ruhr.de) and
is very simple.<p>
If you look in the file pgaccess.tcl, you will find the fonts declared in
this manner:<p>
<TT>$ grep -e '-font' -i pgaccess.tcl<BR>
-font -Adobe-Helvetica-Medium-R-Normal--*-120-*-*-*-*-*-* \<br>
...</TT></P>
The font declarations should be altered to:<p>
<tt>-font -Adobe-Helvetica-Medium-R-Normal-*-*-120-*-*-*-*-iso8859-1<br>
...</tt><p>
That is, inserting an asterisk between the first pair of hyphens, and changing
the final two asterisks to <samp>iso8859</samp> and <samp>1</samp>
respectively.<p>
You can alter the source code by running the following script :
<P><TT>#!/bin/sh<BR>
cp pgaccess.tcl pgaccess.tcl-org<BR>
cat pgaccess.tcl |\<BR>
sed -e's/\-\*\-\*\ /\-iso8859\-1\ /g' |\<BR>
sed -e's/\-\*\-\*\}/\-iso8859\-1}/g' |\<BR>
sed -e's/\-\*\-\*\]/\-iso8859\-1]/g' |\<BR>
sed -e's/\-\*\-\*$/\-iso8859\-1/g' |\<BR>
sed -e's/\-Clean\-/\-Fixed\-/g' |\<BR>
sed -e's/clean/fixed/g' &gt;pgaccess.iso<BR>
mv pgaccess.iso pgaccess.tcl<BR>
chmod +x pgaccess.tcl</TT><P>
The final version of PgAccess (1.0) will let the user decide what fonts
will be used through a &quot;preferences&quot; dialog window.</p>
<a name="pg63">
<h2>Problem with PostgreSQL 6.3.x</h2>
PgAccess 0.93 and later may have problems working with PostgreSQL 6.3.x.
Changes in libpgtcl have been made to remove these, but if you are
using PostgreSQL 6.3.x, this patch will allow you to get around the problems.<p>
In the procedure <tt>wpg_exec</tt> change the following line:<p>
<tt>set pgsql(errmsg) [pg_result $pgsql(res) -error]</tt><p>
to this:<p>
<tt>set pgsql(errmsg) "NO ERROR INFORMATION SUPPLIED"</tt><p>
and the program will work. The only disadvantage is that with some error
conditions, you will not get the appropriate error message from libpgtcl.<p>
<a href="index.html#problems">Back to index</a>
</body></html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,74 @@
<html><head><title>PgAccess - Getting Started</title></head>
<body bgcolor="#C0C0C0">
<h1>PgAccess - Getting Started</h1>
<a name="getpga"><h2>How to get PgAccess</h2>
If you have this HTML help system, you have probably already downloaded
PgAccess. If not, or you wish to download the latest version, it is available
from the URL:<p>
<samp>http://www.flex.ro</samp><p>
The home page will contain instructions on which files to download for your
operating system. Download the file to a directory where the program will
eventually reside (see below).<p>
<a name="uncpga"><h2>How to uncompress PgAccess</h2>
PgAccess, like most applications available for download, is usually downloaded
in compressed format to save download time. You must uncompress these files in
order to use the application.<p>
<h3>UNIX (Linux, BSD, IRIX, Solaris, etc.)</h3>
The files will be compressed using "gzip" and packaged using "tar", and have
filenames like this:<p>
<samp>pgaccess-n.nn.tar.gz</samp><p>
Note that "n.nn" will be the version number in an actual file.<p>
First decide where you want to have the program. A typical location on UNIX
systems is <samp>/usr/local/src/&lt;name&gt;</samp>, where &lt;name&gt; is the name of
the program. To use this location, download or move the "tar.gz" file to the
directory <samp>/usr/local/src</samp>. Change to that directory, and
uncompress the file with the command:<p>
<samp>tar -zxvf pgaccess-n.nn.tar.gz</samp><p>
You should see the files listed as they are uncompressed and placed in the new
directory, and now have a directory named:<p>
<samp>/usr/local/src/pgaccess</samp><p>
In that directory will be all of the files that were packaged in the downloaded
file. When you have PgAccess working, you can delete the file with the ".tar"
or ".tar.gz" extension.
<h3>Windows</h3>
The files will be compressed so that "WinZip" will uncompress the package. Just
open the file with "WinZip" and the program files will be extracted.<p>
<a name="putpga"><h2>Putting PgAccess where it will be found</h2>
<h3>UNIX</h3>
In order to run PgAccess easily, the program file "pgaccess.tcl" should be in a
location on the "PATH" of the system. You can find out what the PATH is by
entering:<p>
<samp>echo $PATH<br>
/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:./:/usr/local/pgsql/bin
</samp><p>
Usually the directory <samp>/usr/local/bin</samp> will be in your PATH, and that
is a fairly common place to put programs like PgAccess. Other common
directories in the PATH are <samp>/usr/bin</samp> and <samp>/usr/sbin</samp>.
Simply move the file "pgaccess.tcl" to the directory where you want it.<p>
<h3>Windows</h3>
You will usually link PgAccess to an icon, so just specify the full path to the
program when you create the icon.
<a name=startpga"><h2>Starting PgAccess</h2>
The easiest way to start PgAccess is to simply invoke the program by name:<p>
<samp>pgaccess.tcl</samp><p>
If the program has been placed in a directory listed in the PATH, the PgAccess
window should appear.<p>
<h3>Starting from a menu</h3>
Most users will want to link the program to a menu or icon so that it can be
started using the mouse or other pointing device. Here is a method that will
work on most Linux X-Windows systems. Create a file named "pgaccess" in the directory
<samp>/etc/X11/wmconfig</samp> with the following contents:<p>
<samp>pgaccess name "PgAccess"<br>
pgaccess description "postgreSQL frontend"<br>
pgaccess mini-icon "mini-pgaccess.xpm"<br>
pgaccess group "Applications"<br>
pgaccess exec "pgaccess.tcl &"</samp><p>
This assumes that you have an "Applications" sub-menu. You may prefer
"Programs" or some other place. Also, you will have to create the
"mini-pgaccess.xpm" icon if you want it to appear. You can edit an existing
icon from the <samp>/usr/share/icons/mini</samp> directory in XPaint and rename
it. When you next start an X-Windows session, there should be a "PgAccess" item
on the menu that you have chosen. Clicking on this item should start
PgAccess.<p>
<a href="index.html#start">Back to index</a>
</body></html>

View File

@ -0,0 +1,50 @@
<html><head><title>PgAccess - Tutorial</title></head>
<body bgcolor="#C0C0C0">
<h1>PgAccess - Tutorial</h1>
<a name="admin"><h2>User Administration</h2>
The procedure for setting up <b>postgreSQL</b> usually results in a single user
named <samp>postgres</samp>. In order for anyone else to use <b>postgreSQL</b>,
users must be added. The program <samp>createuser</samp> accomplishes this.
First become the PostgreSQL administrator (usually <samp>postgres</samp>):<p>
<samp>su postgres</samp><p>
Then create a new user:<p>
<samp>createuser jim<br>
Enter user's postgres ID or RETURN to use unix user ID: 500 -&gt;<br>
Is user "jim" allowed to create databases (y/n) y<br>
Is user "jim" a superuser? (y/n) n<br>
createuser: jim was successfully added</samp><p>
You can use either the UNIX user ID or the postgres ID to identify users. See
the <b>postgreSQL</b> documentation in the "admin" section for a fuller
account of users and groups.<p>
To remove users, use the <samp>destroyuser</samp> command in the same way.<p>
<img src="screen1.jpg" border=1 align=right>
<a name="basic"><h2>Basic use of PgAccess</h2>
<h3>Creating a database</h3>
At the right is the window you should see when PgAccess starts up. The first
task for most users will be to create a database.<p>
Press the <em>New</em> button to bring up the window shown below. This will
allow you to specify the structure of the new table. It is important to note
that if you haven't specified a database when starting up PgAccess, this table
will be created in the database named <samp>&lt;username&gt;</samp>, your
username.<p>
Assume that you want to create a table with entries describing bibliographic
references in the field of chemistry. Choose a table name, such as
<samp>chemref</samp> that will be easy to recall and find in a list. Enter the
table name in the first input field.<p>
When you already have tables in a database, you can use the <em>Inherits</em>
button to toggle a list of existing tables to inherit characteristics of another
table. In this example, there should be no previous tables to use.<p>
Enter each field, giving it a name, field type and size, if the field type does
not imply the size. That is, if your first field was to be a sequence number,
and you selected <em>int2</em> as the field type, you would not have to specify
a field size. However, if your second field was to contain the author of the
reference, and was a <em>varchar</em> type, you would have to specify how many
characters would be allowed in the field.<p>
As you enter each field, click the <em>Add field</em> button to add it to the
list at the right side of the window. You can change the position of fields
using the <em>Move field up</em> and <em>Move field down</em> buttons, or delete
a field if you decide it isn't what you wanted. When you are finished
specifying fields, press the <em>Create table</em> button.<p>
<img src="newtable.jpg" border=1 align=right>
<a href="index.html#tut">Back to index</a>
</body></html>

View File

@ -0,0 +1,39 @@
<html><head><title>PgAccess Tutorial</title></head>
<body bgcolor="#C0C0C0">
<h1>PgAccess Tutorial - Editing a table</h1>
<img src="sel_tbl.jpg" border=1 align=right>
<h2>Adding records</h2>
Once you have a table, you can begin to add entries to it. In the main
PgAccess window, when you click the <em>Tables</em> button, you should see the
new table appear in the list of tables. Highlighting the table name by clicking
on it and clicking on the <em>Open</em> button will open that table in another
window, as shown below.<p>
The most straighforward way to add records to a table is to type the information
directly into the fields. Two records have been entered in the table shown. As
is common with this user interface, clicking the mouse while the pointer is in a
field will allow keyboard entry to that field. This type of entry is adequate
when the information arrives infrequently in small parcels, for instance in
keeping a table of contact information about other researchers. However, what
do you do when someone emails you the entire reference list for their doctoral
dissertation?<p>
This is best handled using the SQL <em>COPY</em> command.
First, the information will have to be massaged into shape in what is called a
'flat' ASCII file. This is simply a text file in which each line is a record,
and each field in each record is separated by a <em>delimiter</em> such as a
tilde (~). The fields will have to be in the same order as those in your table,
and there will have to be the same number of fields in each record as are in the
table, otherwise you may get unexpected data or no data at all. Say you produce
a text file named <samp>newref.txt</samp> that starts like this:<p>
<samp>Cassileth, BR~Unorthodox Cancer Medicine~Cancer Investigation~~1986~4~6~591-598
<br>...</samp><p>
Notice that there are two consecutive tildes to allow for the fact that this
particular entry doesn't have anything in the <b>Editor</b> field.
You can then perform a <em>Query</em> as follows:<p>
<samp>COPY psyref FROM '/home/jim/newref.txt' USING DELIMITERS
'~';</samp><p>
This will read the records from <samp>newref.txt</samp> and insert them into the
table <samp>psyref</samp>. See the PostgreSQL documentation under the headings
<br><b>Tutorial|The Query Language|Populating a Class with Instances</b><p>
<img src="addref.jpg" border=1 align=right>
<a href="index.html#tut">Back to index</a>
</body></html>

View File

@ -0,0 +1,36 @@
<html><head><title>PgAccess Tutorial</title></head>
<body bgcolor="#C0C0C0">
<h1>PgAccess Tutorial - Creating a table</h1>
<img src="screen1.jpg" border=1 align=right>
<h2>Creating a table</h2>
At the right is the window you should see when PgAccess starts up. The first
task for most users will be to create a database. Notice the 'buttons' at the
left of the main window. Clicking on these allows you to see the names of
different <em>objects</em> that are stored in your database, which should be
empty at the moment.<p>
Click the <em>Tables</em> and <em>New</em> buttons to bring up the window shown
below. This will allow you to specify the structure of the new table. It is
important to note that if you haven't specified a database when starting up
PgAccess, this table will be created in the database named
<samp>&lt;username&gt;</samp>, your username.<p>
Assume that you want to create a table with entries describing bibliographic
references in the field of psychology. Choose a table name, such as
<samp>psyref</samp> that will be easy to recall and find in a list. Enter the
table name in the first input field.<p>
When you already have tables in a database, you can use the <em>Inherits</em>
button to toggle a list of existing tables to inherit characteristics of another
table. In this example, there should be no previous tables to use.<p>
Enter each field, giving it a name, field type and size, if the field type does
not imply the size. That is, if your first field was to be a sequence number,
and you selected <em>int2</em> as the field type, you would not have to specify
a field size. However, if your second field was to contain the author of the
reference, and was a <em>varchar</em> type, you would have to specify how many
characters would be allowed in the field.<p>
As you enter each field, click the <em>Add field</em> button to add it to the
list at the right side of the window. You can change the position of fields
using the <em>Move field up</em> and <em>Move field down</em> buttons, or delete
a field if you decide it isn't what you wanted. When you are finished
specifying fields, press the <em>Create table</em> button.<p>
<img src="newtable.jpg" border=1 align=right>
<a href="index.html#tut">Back to index</a>
</body></html>

View File

@ -0,0 +1,36 @@
<html><head><title>PgAccess Tutorial</title></head>
<body bgcolor="#C0C0C0">
<h1>PgAccess Tutorial - SELECT</h1>
<img src="altern_q.jpg" border=1 align=right>
<h2>What is a query?</h2>
<em>Query</em> is the term for an SQL command which will perform an operation
on a table. It is sometimes confusing to newcomers, as some of the operations
seem to have nothing to do with querying in the common sense of <em>asking</em>.
As we saw in the previous section, a <em>query</em> can simply copy
records from an ASCII file to a table.<p>
The PostgreSQL documentation has a complete list of <em>queries</em> that can be
used. We'll start with the common task of selecting records with certain
characteristics.<p>
<h2>Selecting records</h2>
<img src="altern_v.jpg" border=1 align=right>
Suppose that I want to know all of the references in the sample table
<em>psyref</em> for which the word "alternative" appeared in the title.<p>
By clicking <em>Query</em>, then <em>New</em>, a <b>Query builder</b> window will
appear. Clicking in the area below the buttons will allow the user to enter an
SQL <em>query</em>. The specification of the <em>query</em> must be exact or
PostgreSQL will return an error message.<p>
The <em>query</em> shown will <b>SELECT</b> those records from <em>psyref</em>
that contain the word "alternative" anywhere in the <em>title</em> field. The
'*' indicates that all of the fields are to be returned. You might only want to
return, for instance, the <em>author</em> field if you were only interested in
which authors had used that word in the title of their work.<p>
At the right is the record that fulfils these conditions, displayed in the
<b>Table viewer</b>. If you wanted to save this query for use again,
clicking the <em>Save query definition</em> button will do so. You will then
see <em>altern</em> listed under <em>Queries</em> when you return to the main
window. By clicking the <em>Save this query as a view</em> tickbox in the
<b>Query builder</b>, the result of your query will be saved as a
<em>View</em> which you can access from <em>Views</em> in the main window.
Click the <em>Close</em> button to leave the <b>Query builder</b>.<p>
<a href="index.html#tut">Back to index</a>
</body></html>

View File

@ -0,0 +1,28 @@
<html><head><title>PgAccess Tutorial</title></head>
<body bgcolor="#C0C0C0">
<h1>PgAccess Tutorial - User Administration</h1>
While user administration is really not a part of the PgAccess program, it is
such a basic operation that a brief description is given here.
<h2>Creating users</h2>
The procedure for setting up <b>postgreSQL</b> usually results in a single user
named <samp>postgres</samp>. In order for anyone else to use <b>postgreSQL</b>,
users must be added. The program <samp>createuser</samp> accomplishes this.
First become the PostgreSQL administrator (usually <samp>postgres</samp>):<p>
<samp>su postgres</samp><p>
Then create a new user:<p>
<samp>createuser jim<br>
Enter user's postgres ID or RETURN to use unix user ID: 500 -&gt;<br>
Is user "jim" allowed to create databases (y/n) y<br>
Is user "jim" a superuser? (y/n) y<br>
createuser: jim was successfully added</samp><p>
You can use either the UNIX user ID or the postgres ID to identify users. See
the <b>postgreSQL</b> documentation in the "admin" section for a fuller
account of users and groups.<p>
The reason for using the command line to create the first user (other than
<em>postgres</em>) is that <em>postgres</em> may not have X-Window permission.
You can also create users using <b>PgAccess</b> if you are created as a
<em>superuser</em> as shown in the example above.<p>
<h2>Removing users</h2>
To remove users, use the <samp>destroyuser</samp> command in the same way.<p>
<a href="index.html#tut">Back to index</a>
</body></html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -0,0 +1,50 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
</head>
<body bgcolor="#FEFEDF">
<b>29 August 1999</b> - PgAccess 0.98 has been released!
<ul>
<li>
international version (romanian, french, italian translations available)
in separate files (japanese translation now possible)</li>
<li>
context sensitive help, complete help for SQL commands</li>
<li>
geometry changes for many forms</li>
<li>
form designer enhancements (widget icons , new attribute window style,
form startup script)</li>
<li>
ability to inspect PostgreSQL system tables (preferences)</li>
<li>
enhanced table design window, table permissions</li>
<li>
distribution archive changes</li>
<li>
unified internal global variables</li>
<li>
unified internal window naming conventions</li>
<li>
usage of Tcl namespaces for all modules</li>
<li>
PgAccess developer <a href="api.html">API</a></li>
<li>
web site enhancements</li>
</ul>
</body>
</html>

View File

@ -0,0 +1,45 @@
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (X11; I; Linux 2.2.11 i586) [Netscape]">
</head>
<body bgcolor="#FEFEDF">
<h2>
PgAccess on Win32</h2>
<hr>In order to run PgAccess on a Win32 workstation you should follow the
following steps:
<ol>
<li>
download and install a Tcl/Tk package from <a href="http://www.scriptics.com">Scriptics</a>
(8.0.x or 8.1.x)</li>
<li>
install PgAccess package</li>
<li>
check the Tcl/Tk version that you have</li>
<li>
check the PostgreSQL version installed on your database server machine</li>
<li>
get from win32/dll directory the appropriate libraries suitable for your
Tcl/Tk version and PostgreSQL version and copy them into your Windows/System
directory renaming them as libpq.dll and libpgtcl.dll</li>
<li>
check if your win32 workstation is able to see your database server (ping
yourdatabaseserver)</li>
<li>
ask your database administrator to verify if your win32 workstation has
access rights to the database (pg_hba.conf)</li>
</ol>
<p><br>You should be able to run PgAccess.
<br>&nbsp;
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 873 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 908 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 896 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 897 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 870 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 911 B

View File

@ -0,0 +1,61 @@
namespace eval Database {
proc {getTablesList} {} {
global CurrentDB PgAcVar
set tlist {}
if {[catch {
wpg_select $CurrentDB "select c.relname,count(c.relname) from pg_class C, pg_rewrite R where (r.ev_class = C.oid) and (r.ev_type = '1') group by relname" rec {
if {$rec(count)!=0} {
set itsaview($rec(relname)) 1
}
}
if {! $PgAcVar(pref,systemtables)} {
wpg_select $CurrentDB "select relname from pg_class where (relname !~ '^pg_') and (relkind='r') order by relname" rec {
if {![regexp "^pga_" $rec(relname)]} then {
if {![info exists itsaview($rec(relname))]} {
lappend tlist $rec(relname)
}
}
}
} else {
wpg_select $CurrentDB "select relname from pg_class where (relkind='r') order by relname" rec {
if {![info exists itsaview($rec(relname))]} {
lappend tlist $rec(relname)
}
}
}
} gterrmsg]} {
showError $gterrmsg
}
return $tlist
}
proc {vacuum} {} {
global PgAcVar CurrentDB
if {$CurrentDB==""} return;
set PgAcVar(statusline,dbname) [format [intlmsg "vacuuming database %s ..."] $PgAcVar(currentdb,dbname)]
setCursor CLOCK
set pgres [wpg_exec $CurrentDB "vacuum;"]
catch {pg_result $pgres -clear}
setCursor DEFAULT
set PgAcVar(statusline,dbname) $PgAcVar(currentdb,dbname)
}
proc {getPgType} {oid} {
global CurrentDB
set temp "unknown"
wpg_select $CurrentDB "select typname from pg_type where oid=$oid" rec {
set temp $rec(typname)
}
return $temp
}
proc {executeUpdate} {sqlcmd} {
global CurrentDB
return [sql_exec noquiet $sqlcmd]
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,181 @@
namespace eval Functions {
proc {new} {} {
global PgAcVar
Window show .pgaw:Function
set PgAcVar(function,name) {}
set PgAcVar(function,nametodrop) {}
set PgAcVar(function,parameters) {}
set PgAcVar(function,returns) {}
set PgAcVar(function,language) {}
.pgaw:Function.fs.text1 delete 1.0 end
focus .pgaw:Function.fp.e1
wm transient .pgaw:Function .pgaw:Main
}
proc {design} {functionname} {
global PgAcVar CurrentDB
Window show .pgaw:Function
.pgaw:Function.fs.text1 delete 1.0 end
wpg_select $CurrentDB "select * from pg_proc where proname='$functionname'" rec {
set PgAcVar(function,name) $functionname
set temppar $rec(proargtypes)
set PgAcVar(function,returns) [Database::getPgType $rec(prorettype)]
set funcnrp $rec(pronargs)
set prolanguage $rec(prolang)
.pgaw:Function.fs.text1 insert end $rec(prosrc)
}
wpg_select $CurrentDB "select lanname from pg_language where oid=$prolanguage" rec {
set PgAcVar(function,language) $rec(lanname)
}
if { $PgAcVar(function,language)=="C" || $PgAcVar(function,language)=="c" } {
wpg_select $CurrentDB "select probin from pg_proc where proname='$functionname'" rec {
.pgaw:Function.fs.text1 delete 1.0 end
.pgaw:Function.fs.text1 insert end $rec(probin)
}
}
set PgAcVar(function,parameters) {}
for {set i 0} {$i<$funcnrp} {incr i} {
lappend PgAcVar(function,parameters) [Database::getPgType [lindex $temppar $i]]
}
set PgAcVar(function,parameters) [join $PgAcVar(function,parameters) ,]
set PgAcVar(function,nametodrop) "$PgAcVar(function,name) ($PgAcVar(function,parameters))"
}
proc {save} {} {
global PgAcVar
if {$PgAcVar(function,name)==""} {
focus .pgaw:Function.fp.e1
showError [intlmsg "You must supply a name for this function!"]
} elseif {$PgAcVar(function,returns)==""} {
focus .pgaw:Function.fp.e3
showError [intlmsg "You must supply a return type!"]
} elseif {$PgAcVar(function,language)==""} {
focus .pgaw:Function.fp.e4
showError [intlmsg "You must supply the function language!"]
} else {
set funcbody [.pgaw:Function.fs.text1 get 1.0 end]
regsub -all "\n" $funcbody " " funcbody
if {$PgAcVar(function,nametodrop) != ""} {
if {! [sql_exec noquiet "drop function $PgAcVar(function,nametodrop)"]} {
return
}
}
if {[sql_exec noquiet "create function $PgAcVar(function,name) ($PgAcVar(function,parameters)) returns $PgAcVar(function,returns) as '$funcbody' language '$PgAcVar(function,language)'"]} {
Window destroy .pgaw:Function
tk_messageBox -title PostgreSQL -parent .pgaw:Main -message [intlmsg "Function saved!"]
Mainlib::tab_click Functions
}
}
}
}
proc vTclWindow.pgaw:Function {base} {
global PgAcVar
if {$base == ""} {
set base .pgaw:Function
}
if {[winfo exists $base]} {
wm deiconify $base; return
}
toplevel $base -class Toplevel
wm focusmodel $base passive
wm geometry $base 480x330+98+212
wm maxsize $base 1009 738
wm minsize $base 480 330
wm overrideredirect $base 0
wm resizable $base 1 1
wm deiconify $base
wm title $base [intlmsg "Function"]
bind $base <Key-F1> "Help::load functions"
frame $base.fp \
-height 88 -relief groove -width 125
label $base.fp.l1 \
-borderwidth 0 -relief raised -text [intlmsg Name]
entry $base.fp.e1 \
-background #fefefe -borderwidth 1 -textvariable PgAcVar(function,name)
bind $base.fp.e1 <Key-Return> {
focus .pgaw:Function.fp.e2
}
label $base.fp.l2 \
-borderwidth 0 -relief raised -text [intlmsg Parameters]
entry $base.fp.e2 \
-background #fefefe -borderwidth 1 -textvariable PgAcVar(function,parameters) -width 15
bind $base.fp.e2 <Key-Return> {
focus .pgaw:Function.fp.e3
}
label $base.fp.l3 \
-borderwidth 0 -relief raised -text [intlmsg Returns]
entry $base.fp.e3 \
-background #fefefe -borderwidth 1 -textvariable PgAcVar(function,returns)
bind $base.fp.e3 <Key-Return> {
focus .pgaw:Function.fp.e4
}
label $base.fp.l4 \
-borderwidth 0 -relief raised -text [intlmsg Language]
entry $base.fp.e4 \
-background #fefefe -borderwidth 1 -textvariable PgAcVar(function,language) -width 15
bind $base.fp.e4 <Key-Return> {
focus .pgaw:Function.fs.text1
}
label $base.fp.lspace \
-borderwidth 0 -relief raised -text { }
frame $base.fs \
-borderwidth 2 -height 75 -relief groove -width 125
text $base.fs.text1 \
-background #fefefe -foreground #000000 -borderwidth 1 -font $PgAcVar(pref,font_fix) -height 16 \
-tabs {20 40 60 80 100 120} -width 43 -yscrollcommand {.pgaw:Function.fs.vsb set}
scrollbar $base.fs.vsb \
-borderwidth 1 -command {.pgaw:Function.fs.text1 yview} -orient vert
frame $base.fb \
-borderwidth 2 -height 75 -width 125
frame $base.fb.fbc \
-borderwidth 2 -height 75 -width 125
button $base.fb.fbc.btnsave -command {Functions::save} \
-borderwidth 1 -padx 9 -pady 3 -text [intlmsg Save]
button $base.fb.fbc.btnhelp -command {Help::load functions} \
-borderwidth 1 -padx 9 -pady 3 -text [intlmsg Help]
button $base.fb.fbc.btncancel \
-borderwidth 1 -command {Window destroy .pgaw:Function} -padx 9 -pady 3 \
-text [intlmsg Cancel]
pack $base.fp \
-in .pgaw:Function -anchor center -expand 0 -fill x -side top
grid $base.fp.l1 \
-in .pgaw:Function.fp -column 0 -row 0 -columnspan 1 -rowspan 1 -sticky w
grid $base.fp.e1 \
-in .pgaw:Function.fp -column 1 -row 0 -columnspan 1 -rowspan 1
grid $base.fp.l2 \
-in .pgaw:Function.fp -column 3 -row 0 -columnspan 1 -rowspan 1 -sticky w
grid $base.fp.e2 \
-in .pgaw:Function.fp -column 4 -row 0 -columnspan 1 -rowspan 1 -pady 2
grid $base.fp.l3 \
-in .pgaw:Function.fp -column 0 -row 4 -columnspan 1 -rowspan 1 -sticky w
grid $base.fp.e3 \
-in .pgaw:Function.fp -column 1 -row 4 -columnspan 1 -rowspan 1
grid $base.fp.l4 \
-in .pgaw:Function.fp -column 3 -row 4 -columnspan 1 -rowspan 1 -sticky w
grid $base.fp.e4 \
-in .pgaw:Function.fp -column 4 -row 4 -columnspan 1 -rowspan 1 -pady 3
grid $base.fp.lspace \
-in .pgaw:Function.fp -column 2 -row 4 -columnspan 1 -rowspan 1
pack $base.fs \
-in .pgaw:Function -anchor center -expand 1 -fill both -side top
pack $base.fs.text1 \
-in .pgaw:Function.fs -anchor center -expand 1 -fill both -side left
pack $base.fs.vsb \
-in .pgaw:Function.fs -anchor center -expand 0 -fill y -side right
pack $base.fb \
-in .pgaw:Function -anchor center -expand 0 -fill x -side bottom
pack $base.fb.fbc \
-in .pgaw:Function.fb -anchor center -expand 0 -fill none -side top
pack $base.fb.fbc.btnsave \
-in .pgaw:Function.fb.fbc -anchor center -expand 0 -fill none -side left
pack $base.fb.fbc.btnhelp \
-in .pgaw:Function.fb.fbc -anchor center -expand 0 -fill none -side left
pack $base.fb.fbc.btncancel \
-in .pgaw:Function.fb.fbc -anchor center -expand 0 -fill none -side right
}

View File

@ -0,0 +1,127 @@
namespace eval Help {
proc {findLink} {} {
foreach tagname [.pgaw:Help.f.t tag names current] {
if {$tagname!="link"} {
load $tagname
return
}
}
}
proc {load} {topic args} {
global PgAcVar
if {![winfo exists .pgaw:Help]} {
Window show .pgaw:Help
tkwait visibility .pgaw:Help
}
wm deiconify .pgaw:Help
if {![info exists PgAcVar(help,history)]} {
set PgAcVar(help,history) {}
}
if {[llength $args]==1} {
set PgAcVar(help,current_topic) [lindex $args 0]
set PgAcVar(help,history) [lrange $PgAcVar(help,history) 0 [lindex $args 0]]
} else {
lappend PgAcVar(help,history) $topic
set PgAcVar(help,current_topic) [expr {[llength $PgAcVar(help,history)]-1}]
}
# Limit the history length to 100 topics
if {[llength $PgAcVar(help,history)]>100} {
set PgAcVar(help,history) [lrange $PgAcVar(help,history) 1 end]
}
.pgaw:Help.f.t configure -state normal
.pgaw:Help.f.t delete 1.0 end
.pgaw:Help.f.t tag configure bold -font $PgAcVar(pref,font_bold)
.pgaw:Help.f.t tag configure italic -font $PgAcVar(pref,font_italic)
.pgaw:Help.f.t tag configure large -font {Helvetica -14 bold}
.pgaw:Help.f.t tag configure title -font $PgAcVar(pref,font_bold) -justify center
.pgaw:Help.f.t tag configure link -font {Helvetica -12 underline} -foreground #000080
.pgaw:Help.f.t tag configure code -font $PgAcVar(pref,font_fix)
.pgaw:Help.f.t tag configure warning -font $PgAcVar(pref,font_bold) -foreground #800000
.pgaw:Help.f.t tag bind link <Button-1> {Help::findLink}
set errmsg {}
.pgaw:Help.f.t configure -tabs {30 60 90 120 150 180 210 240 270 300 330 360 390}
catch { source [file join $PgAcVar(PGACCESS_HOME) lib help $topic.hlp] } errmsg
if {$errmsg!=""} {
.pgaw:Help.f.t insert end "Error loading help file [file join $PgAcVar(PGACCESS_HOME) $topic.hlp]\n\n$errmsg" bold
}
.pgaw:Help.f.t configure -state disabled
focus .pgaw:Help.f.sb
}
proc {back} {} {
global PgAcVar
if {![info exists PgAcVar(help,history)]} {return}
if {[llength $PgAcVar(help,history)]==0} {return}
set i $PgAcVar(help,current_topic)
if {$i<1} {return}
incr i -1
load [lindex $PgAcVar(help,history) $i] $i
}
}
proc vTclWindow.pgaw:Help {base} {
global PgAcVar
if {$base == ""} {
set base .pgaw:Help
}
if {[winfo exists $base]} {
wm deiconify $base; return
}
toplevel $base -class Toplevel
wm focusmodel $base passive
set sw [winfo screenwidth .]
set sh [winfo screenheight .]
set x [expr {($sw - 640)/2}]
set y [expr {($sh - 480)/2}]
wm geometry $base 640x480+$x+$y
wm maxsize $base 1009 738
wm minsize $base 1 1
wm overrideredirect $base 0
wm resizable $base 1 1
wm deiconify $base
wm title $base [intlmsg "Help"]
bind $base <Key-Escape> "Window destroy .pgaw:Help"
frame $base.fb \
-borderwidth 2 -height 75 -relief groove -width 125
button $base.fb.bback \
-command Help::back -padx 9 -pady 3 -text [intlmsg Back]
button $base.fb.bi \
-command {Help::load index} -padx 9 -pady 3 -text [intlmsg Index]
button $base.fb.bp \
-command {Help::load postgresql} -padx 9 -pady 3 -text PostgreSQL
button $base.fb.btnclose \
-command {Window destroy .pgaw:Help} -padx 9 -pady 3 -text [intlmsg Close]
frame $base.f \
-borderwidth 2 -height 75 -relief groove -width 125
text $base.f.t \
-borderwidth 1 -cursor {} -font $PgAcVar(pref,font_normal) -height 2 \
-highlightthickness 0 -state disabled \
-tabs {30 60 90 120 150 180 210 240 270 300 330 360 390} -width 8 \
-wrap word -yscrollcommand {.pgaw:Help.f.sb set}
scrollbar $base.f.sb \
-borderwidth 1 -command {.pgaw:Help.f.t yview} -highlightthickness 0 \
-orient vert
pack $base.fb \
-in .pgaw:Help -anchor center -expand 0 -fill x -side top
pack $base.fb.bback \
-in .pgaw:Help.fb -anchor center -expand 0 -fill none -side left
pack $base.fb.bi \
-in .pgaw:Help.fb -anchor center -expand 0 -fill none -side left
pack $base.fb.bp \
-in .pgaw:Help.fb -anchor center -expand 0 -fill none -side left
pack $base.fb.btnclose \
-in .pgaw:Help.fb -anchor center -expand 0 -fill none -side right
pack $base.f \
-in .pgaw:Help -anchor center -expand 1 -fill both -side top
pack $base.f.t \
-in .pgaw:Help.f -anchor center -expand 1 -fill both -side left
pack $base.f.sb \
-in .pgaw:Help.f -anchor center -expand 0 -fill y -side right
}

View File

@ -0,0 +1,10 @@
.pgaw:Help.f.t insert end \
"ABORT" {bold} " rolls back the current transaction and causes all the updates made by the transaction to be discarded. This command is identical in behavior to the SQL92 command ROLLBACK, and is present only for historical reasons.
" {} "Synopsis" {bold} "
" {} "ABORT" {code} "
" {} "Compatibility SQL92" {bold} "
This command is a Postgres extension present for historical reasons. " {} "ROLLBACK" {bold} " is the SQL92 equivalent command."

View File

@ -0,0 +1,7 @@
.pgaw:Help.f.t insert end \
"Adding new records to an existing table" {bold} "
" {} "Open a table for viewing and editing" {link open_table} " and move to the end of the displayed records using the vertical scrollbar. You will find there a single row containing only * characters. Click with the mouse on a field and start edit the new record. Move through the fields using Tab and Shift-Tab.
The new record will be saved into the database when you will select another record (or press on the mouse right-button).
"

View File

@ -0,0 +1,30 @@
.pgaw:Help.f.t insert end "ALTER TABLE" {bold} " changes the definition of an existing table. The new columns and their types are specified in the same style and with the the same restrictions as in CREATE TABLE. The RENAME clause causes the name of a table or column to change without changing any of the data contained in the affected table. Thus, the table or column will remain of the same type and size after this command is executed.
" {} "Synopsis" {bold} "
ALTER TABLE table \[ * \] ADD \[ COLUMN \] column type
ALTER TABLE table \[ * \] RENAME \[ COLUMN \] column TO newcolumn
ALTER TABLE table RENAME TO newtable
" {code} "table" {italic} "
The name of an existing table to alter.
" {} "column" {italic} "
Name of a new or existing column.
" {} "type " {italic} "
Type of the new column.
" {} "newcolumn " {italic} "
New name for an existing column.
" {} "newtable " {italic} "
New name for an existing column.
You must own the table in order to change its schema.
" {} "Notes:" {italic} " The keyword COLUMN is noise and can be omitted.
\"\[*\]\" following a name of a table indicates that statement should be run over that table and all tables below it in the inheritance hierarchy. The PostgreSQL User's Guide has further information on inheritance.
Refer to " {} "CREATE TABLE" {link create_table} " for a further description of valid arguments."

View File

@ -0,0 +1,49 @@
.pgaw:Help.f.t insert end "ALTER USER" {bold} " is used to change the attributes of a user's Postgres account. Please note that \
it is not possible to alter a user's " {} "usesysid" {bold} " via the alter user statement. Also, it is only possible for \
the Postgres user or any user with read and modify permissions on " {} "pg_shadow" {bold} " to alter user passwords. \
If any of the clauses of the alter user statement are omitted, the corresponding value in the " {} "pg_shadow" {bold} " table is left unchanged. \
" {} "Synopsis" {bold} "
ALTER USER username
\[ WITH PASSWORD password \]
\[ CREATEDB | NOCREATEDB \]
\[ CREATEUSER | NOCREATEUSER \]
\[ IN GROUP groupname \[, ...\] \]
\[ VALID UNTIL 'abstime' \]
" {code} "Inputs" {bold} "
Refer to CREATE USER for a detailed description of each clause.
" {} "username" {italic} "
The Postgres account name of the user whose details are to be altered.
" {} "password" {italic} "
The new password to be used for this account.
" {} "groupname" {italic} "
The name of an access group into which this account is to be put.
" {} "abstime" {italic} "
The date (and, optionally, the time) at which this user's access is to be terminated.
" {} "Outputs" {bold} "
" {} "ALTER USER" {italic} "
Message returned if the alteration was successful.
" {} "ERROR: alterUser: user 'username' does not exist" {italic} "
Error message returned if the user specified doesn't exist.
" {} "Notes" {italic} "
" {} "ALTER USER" {bold} " statement is a Postgres language extension.
Refer to CREATE/DROP USER to create or remove a user account.
In the current release (v6.5), the IN GROUP clause is parsed but has no affect. When it is fully implemented, it is intended to modify the pg_group relation.
" {} "Compatibility" {bold} "
SQL92
There is no ALTER USER statement in SQL92. The standard leaves the definition of users to the \
implementation."

View File

@ -0,0 +1,12 @@
.pgaw:Help.f.t insert end \
"The author of PgAccess\n" {title} \
"
My name is Constantin Teodorescu, I'm 36 years old, I have graduated the Faculty of Computers and Automation Bucharest, ROMANIA, I have a 16 year experience in developing applications in various languages, Pascal, C, C++, Visual Basic, Delphi, Perl , Tcl/Tk and Java for different platforms. Currently working as a manager of a team that works in Unix with Java , SQL databases (Oracle, SYBASE) currently using PostgreSQL database for developing professional client/server multi-platform applications (standalone Java or Tcl/Tk ,Java applets) for different customers and various projects (accounting, invoicing, stock inventory).
In present I am the technical manager of FLEX Consulting Braila, a computer shop, software company, networking designer and consultant, ISP provider for Braila city. I'm also a columnist in the romanian technical magazine \"PC-Magazine\" and \"BYTE\".
I have discovered PostgreSQL in 1995 and from the first moment I decided to help it's development writting PgAccess, a graphical interface.
The work has been done using Visual Tcl, in my opinion the best tool for developing Tcl/Tk projects. Visual Tcl is free, more information at http://www.neuron.com/stewart/vtcl/index.html
I'm waiting for any suggestions at e-mail address teo@flex.ro"

View File

@ -0,0 +1,35 @@
.pgaw:Help.f.t insert end "BEGIN" {bold} "
By default, Postgres executes transactions in unchained mode (also known as " {} "autocommit" {bold} " in other database systems). In other words, each user statement is executed in its own transaction \
and a commit is implicitly performed at the end of the statement (if execution was successful, otherwise a rollback is done). BEGIN initiates a user transaction in chained mode, i.e. all user \
statements after BEGIN command will be executed in a single transaction until an explicit COMMIT, ROLLBACK or execution abort. Statements in chained mode are executed much faster, \
because transaction start/commit requires significant CPU and disk activity. Execution of multiple statements inside a transaction is also required for consistency when changing several related \
tables. \
The default transaction isolation level in Postgres is READ COMMITTED, where queries inside the transaction see only changes committed before query execution. So, you have to use SET \
TRANSACTION ISOLATION LEVEL SERIALIZABLE just after BEGIN if you need more rigorous transaction isolation. In SERIALIZABLE mode queries will see only changes committed \
before the entire transaction began (actually, before execution of the first DML statement in a serializable transaction). \
If the transaction is committed, Postgres will ensure either that all updates are done or else that none of them are done. Transactions have the standard ACID (atomic, consistent, isolatable, and durable) property.
" {} "Synopsis" {bold} "
" {} "
BEGIN \[ WORK | TRANSACTION \]
" {code} "Notes" {bold} "
The keyword TRANSACTION is just a cosmetic alternative to WORK. Neither keyword need be specified.
Refer to the LOCK statement for further information about locking tables inside a transaction.
Use " {} "COMMIT" {link commit} " or " {} "ROLLBACK" {link rollback} " to terminate a transaction.
" {} "Usage" {bold} "
To begin a user transaction:
" {} "BEGIN WORK;" {italic} "
" {} "Compatibility" {bold} "
BEGIN is a Postgres language extension.
" {} "SQL92" {bold} "
There is no explicit BEGIN WORK command in SQL92; transaction initiation is always implicit and it terminates either with a COMMIT or with a ROLLBACK statement.
Note: Many relational database systems offer an autocommit feature as a convenience.
SQL92 also requires SERIALIZABLE to be the default transaction isolation level. "

View File

@ -0,0 +1,22 @@
.pgaw:Help.f.t insert end "CLOSE" {bold} " frees the resources associated with an open cursor. After the cursor is closed, no subsequent operations are allowed on it. A cursor should be closed when it is no longer needed. \
An implicit close is executed for every open cursor when a transaction is terminated by \
" {} "COMMIT" {link commit} " or " {} "ROLLBACK" {link rollback} ".
" {} "Synopsis" {bold} "
CLOSE cursor
" {} "Usage" {bold} "
Close the cursor liahona:
CLOSE liahona;
" {} "Compatibility" {bold} "
SQL92
CLOSE is fully compatible with SQL92
" {} "Notes" {bold} "
Postgres does not have an explicit OPEN cursor statement; a cursor is considered open when it is declared. Use the DECLARE statement to declare a cursor."

View File

@ -0,0 +1,48 @@
.pgaw:Help.f.t insert end "CLUSTER" {bold} " instructs Postgres to cluster the class specified by classname approximately based on the index specified by indexname. The index must already have been defined on classname. \
When a class is clustered, it is physically reordered based on the index information. The clustering is static. In other words, as the class is updated, the changes are not clustered. No attempt is \
made to keep new instances or updated tuples clustered. If one wishes, one can recluster manually by issuing the command \
again.
" {} "Synopsis" {bold} "
CLUSTER indexname ON table
" {} "Inputs" {bold} "
" {} "indexname" {italic} "
The name of an index.
" {} "table" {italic} "
The name of a table.
" {} "Outputs" {bold} "
CLUSTER
The clustering was done successfully.
ERROR: relation <tablerelation_number> inherits \"invoice\"
ERROR: Relation x does not exist!
" {} "Usage" {bold} "
Cluster the employees relation on the basis of its salary attribute
CLUSTER emp_ind ON emp
" {} "Notes" {bold} "
The table is actually copied to a temporary table in index order, then renamed back to the original name. For this reason, all grant permissions and other indexes are lost when clustering is \
performed.
In cases where you are accessing single rows randomly within a table, the actual order of the data in the heap table is unimportant. However, if you tend to access some data more than others, \
and there is an index that groups them together, you will benefit from using CLUSTER.
Another place CLUSTER is helpful is in cases where you use an index to pull out several rows from a table. If you are requesting a range of indexed values from a table, or a single indexed \
value that has multiple rows that match, CLUSTER will help because once the index identifies the heap page for the first row that matches, all other rows that match are probably already on the \
same heap page, saving disk accesses and speeding up the query.
There are two ways to cluster data. The first is with the CLUSTER command, which reorders the original table with the ordering of the index you specify. This can be slow on large tables \
because the rows are fetched from the heap in index order, and if the heap table is unordered, the entries are on random pages, so there is one disk page retrieved for every row moved. Postgres \
has a cache, but the majority of a big table will not fit in the cache.
Another way to cluster data is to use
SELECT ... INTO TABLE temp FROM ... ORDER BY ...
This uses the Postgres sorting code in ORDER BY to match the index, and is much faster for unordered data. You then drop the old table, use ALTER TABLE/RENAME to rename temp to \
the old name, and recreate any indexes. The only problem is that OIDs will not be preserved. From then on, CLUSTER should be fast because most of the heap data has already been ordered, \
and the existing index is used. "

View File

@ -0,0 +1,17 @@
.pgaw:Help.f.t insert end "COMMIT" {bold} " commits the current transaction. All changes made by the transaction become visible to others and are guaranteed to be durable if a crash occurs.
" {} "Synopsis" {bold} "
" {} "
COMMIT \[ WORK | TRANSACTION \]
" {code} "Usage" {bold} "
To make all changes permanent:
COMMIT WORK;
" {} "Notes" {bold} "
The keywords WORK and TRANSACTION are noise and can be omitted.
Use " {} "ROLLBACK" {link rollback} " to abort a transaction."

View File

@ -0,0 +1,105 @@
.pgaw:Help.f.t insert end "COPY" {bold} " moves data between Postgres tables and standard Unix files. COPY instructs the Postgres backend to directly read from or write to a file. The file must be directly visible to the backend \
and the name must be specified from the viewpoint of the backend. If stdin or stdout are specified, data flows through the client frontend to the backend.
" {} "Synopsis" {bold} "
" {} "
COPY \[ BINARY \] table \[ WITH OIDS \]
FROM { 'filename' | stdin }
\[ USING DELIMITERS 'delimiter' \]
COPY \[ BINARY \] table \[ WITH OIDS \]
TO { 'filename' | stdout }
\[ USING DELIMITERS 'delimiter' \]
" {code} "Inputs" {bold} "
" {} "BINARY" {italic} "
Changes the behavior of field formatting, forcing all data to be stored or read as binary objects rather than as text.
" {} "table" {italic} "
The name of an existing table.
" {} "WITH OIDS" {italic} "
Copies the internal unique object id (OID) for each row.
" {} "filename" {italic} "
The absolute Unix pathname of the input or output file.
" {} "stdin" {italic} "
Specifies that input comes from a pipe or terminal.
" {} "stdout" {italic} "
Specifies that output goes to a pipe or terminal.
" {} "delimiter" {italic} "
A character that delimits the input or output fields.
" {} "Outputs" {bold} "
" {} "COPY" {italic} "
The copy completed successfully.
" {} "ERROR: error message" {italic} "
The copy failed for the reason stated in the error message.
" {} "Usage" {bold} "
The following example copies a table to standard output, using a vertical bar \(\"|\"\) as the field delimiter:
COPY country TO stdout USING DELIMITERS '|';
To copy data from a Unix file into a table \"country\":
COPY country FROM '/usr1/proj/bray/sql/country_data';
Here is a sample of data suitable for copying into a table from stdin \(so it has the termination sequence on the last \
line\):
AF AFGHANISTAN
AL ALBANIA
DZ ALGERIA
...
ZM ZAMBIA
ZW ZIMBABWE
\.
" {} "File Formats" {bold} "
" {} "Text Format" {italic} "
When COPY TO is used without the BINARY option, the file generated will have each row \(instance\) on a single line, with each column \
\(attribute\) separated by the delimiter character. Embedded delimiter characters will be preceded by a backslash character \
\(\"\\\"\). The attribute values themselves are strings generated by the output function associated with each attribute type. \
The output function for a type should not try to generate the backslash character; this will be handled by COPY itself.
The actual format for each instance is
<attr1><separator><attr2><separator>...<separator><attrn><newline>
The oid is placed on the beginning of the line if WITH OIDS is specified.
If " {} "COPY" {bold} " is sending its output to standard output instead of a file, it will send a backslash\(\"\\\"\) and a period \
\(\".\"\) followed immediately by a newline, on a separate line, when it is done. Similarly, \
if " {} "COPY" {bold} " is reading from standard input, it will expect a backslash \(\"\\\"\) and a period \
\(\".\"\) followed by a newline, as the first three characters on a line to denote end-of-file. However, COPY will \
terminate \(followed by the backend itself\) if a true EOF is encountered before this special end-of-file pattern is found.
The backslash character has other special meanings. NULL attributes are represented as \"\\N\". A literal backslash character is represented as two consecutive backslashes \
\(\"\\\\\"\). A literal tab character is represented as a backslash and a tab. A literal newline character is represented as a backslash and a newline. When loading text data not generated by Postgres, you will need to \
convert backslash characters \(\"\\\"\) to double-backslashes \(\"\\\\\"\) to ensure that they are loaded properly.
" {} "Binary Format" {italic} "
In the case of " {} "COPY BINARY" {bold} ", the first four bytes in the file will be the number of instances in the file. If this number is zero, the \
" {} "COPY BINARY" {bold} " command will read until end of file is encountered. Otherwise, it will stop reading when this number of instances has been read. Remaining data in the file will be ignored. \
The format for each instance in the file is as follows. Note that this format must be followed exactly. Unsigned four-byte integer quantities are called uint32 in the table below.
" {} "Notes" {bold} "
The " {} "BINARY" {bold} " keyword will force all data to be stored/read as binary objects rather than as text. It is somewhat faster than the normal copy command, but is not generally portable, and the files \
generated are somewhat larger, although this factor is highly dependent on the data itself. By default, a text copy uses a tab \
\(\"\\t\"\) character as a delimiter. The delimiter may also be changed to any other single character with the keyword phrase USING DELIMITERS. Characters in data fields which happen to match the delimiter character will be quoted.
You must have select access on any table whose values are read by " {} "COPY" {bold} ", and either insert or update access to a table into which values are being inserted by \
" {} "COPY" {bold} ". The backend also needs appropriate Unix permissions for any file read or written by \
" {} "COPY" {bold} ".
The keyword phrase " {} "USING DELIMITERS" {bold} " specifies a single character to be used for all delimiters between columns. If multiple characters are specified in the delimiter string, only the first \
character is used.
Tip: Do not confuse " {} "COPY" {bold} " with the psql instruction \\copy. "

View File

@ -0,0 +1,11 @@
.pgaw:Help.f.t insert end \
"Copyrights\n\n" {title} \
"
PostgreSQL is Copyright © 1996-9 by the PostgreSQL Global Development Group, and is distributed under the terms of the Berkeley license.
Postgres95 is Copyright © 1994-5 by the Regents of the University of California. Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.
In no event shall the University of California be liable to any party for direct, indirect, special, incidental, or consequential damages, including lost profits, arising out of the use of this software and its documentation, even if the University of California has been advised of the possibility of such damage.
The University of California specifically disclaims any warranties, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The software provided hereunder is on an \"as-is\" basis, and the University of California has no obligations to provide maintainance, support, updates, enhancements, or modifications.
"

View File

@ -0,0 +1,90 @@
.pgaw:Help.f.t insert end "CREATE AGGREGATE" {bold} " allows a user or programmer to extend Postgres functionality by defining new aggregate functions. Some aggregate functions for base types such as \
min\(int4\) and avg(float8) are already provided in the base distribution. If one defines new types or needs an aggregate function not already provided then CREATE AGGREGATE can be used to provide \
the desired features.
An aggregate function can require up to three functions, two state transition functions, sfunc1 and sfunc2:
sfunc1( internal-state1, next-data_item ) ---> next-internal-state1
sfunc2( internal-state2 ) ---> next-internal-state2
and a final calculation function, ffunc:
ffunc(internal-state1, internal-state2) ---> aggregate-value
Postgres creates up to two temporary variables (referred to here as temp1 and temp2) to hold intermediate results used as arguments to the transition functions.
These transition functions are required to have the following properties:
The arguments to sfunc1 must be temp1 of type sfunc1_return_type and column_value of type data_type. The return value must be of type sfunc1_return_type and will be used as
the first argument in the next call to sfunc1.
The argument and return value of sfunc2 must be temp2 of type sfunc2_return_type.
The arguments to the final-calculation-function must be temp1 and temp2 and its return value must be a Postgres base type (not necessarily data_type which had been specified for
BASETYPE).
FINALFUNC should be specified if and only if both state-transition functions are specified.
An aggregate function may also require one or two initial conditions, one for each transition function. These are specified and stored in the database as fields of type text.
" {} "Synopsis" {bold} "
" {} "
CREATE AGGREGATE name \[ AS \]
( BASETYPE = data_type
\[ , SFUNC1 = sfunc1
, STYPE1 = sfunc1_return_type \]
\[ , SFUNC2 = sfunc2
, STYPE2 = sfunc2_return_type \]
\[ , FINALFUNC = ffunc \]
\[ , INITCOND1 = initial_condition1 \]
\[ , INITCOND2 = initial_condition2 \]
)
" {code} "Inputs" {bold} "
" {} "name" {italic} "
The name of an aggregate function to create.
" {} "data_type" {italic} "
The fundamental data type on which this aggregate function operates.
" {} "sfunc1" {italic} "
The state transition function to be called for every non-NULL field from the source column. It takes a variable of type sfunc1_return_type as the first argument and that field as the
second argument.
" {} "sfunc1_return_type" {italic} "
The return type of the first transition function.
" {} "sfunc2" {italic} "
The state transition function to be called for every non-NULL field from the source column. It takes a variable of type sfunc2_return_type as the only argument and returns a variable
of the same type.
" {} "sfunc2_return_type" {italic} "
The return type of the second transition function.
" {} "ffunc" {italic} "
The final function called after traversing all input fields. This function must take two arguments of types sfunc1_return_type and sfunc2_return_type.
" {} "initial_condition1" {italic} "
The initial value for the first transition function argument.
" {} "initial_condition2" {italic} "
The initial value for the second transition function argument.
" {} "Outputs" {bold} "
" {} "CREATE" {italic} "
Message returned if the command completes successfully.
" {} "Usage" {bold} "
Refer to the chapter on aggregate functions in the PostgreSQL Programmer's Guide on aggregate functions for complete examples of usage.
" {} "Notes" {bold} "
Use " {} "DROP AGGREGATE" {bold} " to drop aggregate functions.
It is possible to specify aggregate functions that have varying combinations of state and final functions. For example, the count aggregate requires SFUNC2 (an incrementing function) but not \
SFUNC1 or FINALFUNC, whereas the sum aggregate requires SFUNC1 (an addition function) but not SFUNC2 or FINALFUNC and the avg aggregate requires both of the above state \
functions as well as a FINALFUNC (a division function) to produce its answer. In any case, at least one state function must be defined, and any SFUNC2 must have a corresponding \
INITCOND2."

View File

@ -0,0 +1,59 @@
.pgaw:Help.f.t insert end "CREATE DATABASE" {bold} " creates a new Postgres database. The creator becomes the administrator of the new database.
" {} "Synopsis" {bold} "
" {} "
CREATE DATABASE name \[ WITH LOCATION = 'dbpath' \]
" {code} "Inputs" {bold} "
" {} "name" {italic} "
The name of a database to create.
" {} "dbpath" {italic} "
An alternate location can be specified as either an environment variable known to the backend server (e.g. 'PGDATA2') or as an absolute path name (e.g. '/usr/local/pgsql/data'). In \
either case, the location must be pre-configured by initlocation.
" {} "Outputs" {bold} "
" {} "CREATEDB" {italic} "
Message returned if the command completes successfully.
" {} "WARN: createdb: database \"name\" already exists." {italic} "
This occurs if database specified already exists.
" {} "ERROR: Unable to create database directory directory" {italic} "
There was a problem with creating the required directory; this operation will need permissions for the postgres user on the specified location.
" {} "Usage" {bold} "
To create a new database:
olly=> create database lusiadas;
To create a new database in an alternate area ~/private_db:
$ mkdir private_db
$ initlocation ~/private_db
Creating Postgres database system directory /home/olly/private_db/base
$ psql olly
Welcome to the POSTGRESQL interactive sql monitor:
Please read the file COPYRIGHT for copyright terms of POSTGRESQL
type \\? for help on slash commands
type \\q to quit
type \\g or terminate with semicolon to execute query
You are currently connected to the database: template1
olly=> create database elsewhere with location = '/home/olly/private_db';
" {} "Bugs" {bold} "
There are security and data integrity issues involved with using alternate database locations specified with absolute path names, and by default only an environment variable known to the \
backend may be specified for an alternate location. See the Administrator's Guide for more information.
" {} "Notes" {bold} "
" {} "CREATE DATABASE" {italic} " is a Postgres language extension.
Use " {} "DROP DATABASE" {italic} " to remove a database. "

View File

@ -0,0 +1,69 @@
.pgaw:Help.f.t insert end \
"Synopsis" {bold} "
CREATE FUNCTION name ( \[ ftype \[, ...\] \] )
RETURNS rtype
AS definition
LANGUAGE 'langname'
" {code} "
name" {italic} "
The name of a function to create.
" {} "ftype" {italic} "
The data type of function arguments.
" {} "rtype" {italic} "
The return data type.
" {} "definition" {italic} "
A string defining the function; the meaning depends on the language. It may be an internal function name, the path to an object file, an SQL query, or text in a procedural language.
" {} "langname" {italic} "
may be 'C', 'sql', 'internal' or 'plname', where 'plname' is the name of a created procedural language. See CREATE LANGUAGE for details.
" {} "Outputs" {bold} "
CREATE
This is returned if the command completes successfully.
CREATE FUNCTION allows a Postgres user to register a function with a database. Subsequently, this user is treated as the owner of the function.
" {} "Notes:" {italic} "Refer to the chapter on functions in the PostgreSQL Programmer's Guide for further information.
Use " {} "DROP FUNCTION" {link drop_function} " to drop user-defined functions.
Postgres allows function \"overloading\"; that is, the same name can be used for several different functions so long as they have distinct argument types. This facility must be used with caution for INTERNAL and C-language functions, however.
Two INTERNAL functions cannot have the same C name without causing errors at link time. To get around that, give them different C names (for example, use the argument types as part of the C names), then specify those names in the AS clause of CREATE FUNCTION. If the AS clause is left empty then CREATE FUNCTION assumes the C name of the function is the same as the SQL name.
For dynamically-loaded C functions, the SQL name of the function must be the same as the C function name, because the AS clause is used to give the path name of the object file containing the C code. In this situation it is best not to try to overload SQL function names. It might work to load a C function that has the same C name as an internal function or another dynamically-loaded function --- or it might not. On some platforms the dynamic loader may botch the load in interesting ways if there is a conflict of C function names. So, even if it works for you today, you might regret overloading names later when you try to run the code somewhere else.
" {} "Usage" {bold} "
To create a simple SQL function:
" {} "
CREATE FUNCTION product_price(int4) RETURNS float8 AS
'SELECT price FROM products where id = \$1'
LANGUAGE 'sql';
SELECT product_price(314) AS answer;
answer
------
15.25
" {code} "
To create a C function, calling a routine from a user-created shared library. This particular routine calculates a check digit and returns TRUE if the check digit in the function parameters is correct. It is intended for use in a CHECK contraint.
" {} "
CREATE FUNCTION ean_checkdigit(bpchar, bpchar) RETURNS bool
AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE 'c';
CREATE TABLE product (
id char(8) PRIMARY KEY,
eanprefix char(8) CHECK (eanprefix ~ '\[0-9\]{2}-\[0-9\]{5}')
REFERENCES brandname(ean_prefix),
eancode char(6) CHECK (eancode ~ '\[0-9\]{6}'),
CONSTRAINT ean CHECK (ean_checkdigit(eanprefix, eancode))
);
" {code}

View File

@ -0,0 +1,87 @@
.pgaw:Help.f.t insert end "CREATE INDEX" {bold} " constructs an index index_name. on the specified table.
Tip: Indexes are primarily used to enhance database performance. But inappropriate use will result in slower performance.
In the first syntax shown above, the key fields for the index are specified as column names; a column may also have an associated operator class. An operator class is used to specify the \
operators to be used for a particular index. For example, a btree index on four-byte integers would use the int4_ops class; this operator class includes comparison functions for four-byte \
integers. The default operator class is the appropriate operator class for that field type.
In the second syntax, an index is defined on the result of a user-defined function func_name applied to one or more attributes of a single class. These functional indexes can be used to obtain \
fast access to data based on operators that would normally require some transformation to apply them to the base data.
" {} "Synopsis" {bold} "
CREATE \[ UNIQUE \] INDEX index_name
ON table \[ USING acc_name \]
( column \[ ops_name\] \[, ...\] )
CREATE \[ UNIQUE \] INDEX index_name
ON table \[ USING acc_name \]
( func_name( column \[, ... \]) ops_name )
" {code} "Inputs" {bold} "
" {} "UNIQUE" {italic} "
Causes the system to check for duplicate values in the table when the index is created \
\(if data already exist\) and each time data is added. Attempts to insert or update non-duplicate \
data will generate an error.
" {} "index_name" {italic} "
The name of the index to be created.
" {} "table" {italic} "
The name of the table to be indexed.
" {} "acc_name" {italic} "
the name of the access method which is to be used for the index. The default access method is BTREE. Postgres provides three access methods for secondary indexes:
BTREE
an implementation of the Lehman-Yao high-concurrency btrees.
RTREE
implements standard rtrees using Guttman's quadratic split algorithm.
HASH
an implementation of Litwin's linear hashing.
" {} "column" {italic} "
The name of a column of the table.
" {} "ops_name" {italic} "
An associated operator class. The following select list returns all ops_names:
" {} "
SELECT am.amname AS acc_name,
opc.opcname AS ops_name,
opr.oprname AS ops_comp
FROM pg_am am, pg_amop amop,
pg_opclass opc, pg_operator opr
WHERE amop.amopid = am.oid AND
amop.amopclaid = opc.oid AND
amop.amopopr = opr.oid
ORDER BY acc_name, ops_name, ops_comp
" {code} "func_name" {italic} "
A user-defined function, which returns a value that can be indexed.
" {} "Outputs" {bold} "
" {} "CREATE" {italic} "
The message returned if the index is successfully created.
" {} "ERROR: Cannot create index: 'index_name' already exists." {italic} "
This error occurs if it is impossible to create the index.
" {} "Usage" {bold} "
To create a btree index on the field title in the table films:
" {} "
CREATE UNIQUE INDEX title_idx
ON films (title);
" {code} "Notes" {bold} "
Currently, only the BTREE access method supports multi-column indexes. Up to 7 keys may be specified.
Use DROP INDEX to remove an index. "

View File

@ -0,0 +1,130 @@
.pgaw:Help.f.t insert end "CREATE LANGUAGE" {bold} ". Using CREATE LANGUAGE, a Postgres user can register a new language with Postgres. Subsequently, functions and trigger procedures can be defined in this new language. The user must \
have the Postgres superuser privilege to register a new language.
Writing PL handlers
The call handler for a procedural language must be written in a compiler language such as 'C' and registered with Postgres as a function taking no arguments and returning the opaque type, a \
placeholder for unspecified or undefined types.. This prevents the call handler from being called directly as a function from queries.
However, arguments must be supplied on the actual call when a PL function or trigger procedure in the language offered by the handler is to be executed. \
When called from the trigger manager, the only argument is the object ID from the procedure's pg_proc entry. All other information from the trigger manager is found in the global \
CurrentTriggerData pointer.
When called from the function manager, the arguments are the object ID of the procedure's pg_proc entry, the number of arguments given to the PL function, the arguments in a \
FmgrValues structure and a pointer to a boolean where the function tells the caller if the return value is the SQL NULL value.
It's up to the call handler to fetch the pg_proc entry and to analyze the argument and return types of the called procedure. The AS clause from the CREATE FUNCTION of the procedure will \
be found in the prosrc attribute of the pg_proc table entry. This may be the source text in the procedural language itself (like for PL/Tcl), a pathname to a file or anything else that tells the call \
handler what to do in detail.
" {} "Synopsis" {bold} "
CREATE \[ TRUSTED \] PROCEDURAL LANGUAGE 'langname'
HANDLER call_handler
LANCOMPILER 'comment'
" {code} "Inputs" {bold} "
" {} "TRUSTED" {italic} "
TRUSTED specifies that the call handler for the language is safe; that is, it offers an unprivileged user no functionality to bypass access restrictions. If this keyword is omitted when
registering the language, only users with the Postgres superuser privilege can use this language to create new functions (like the 'C' language).
" {} "langname" {italic} "
The name of the new procedural language. The language name is case insensitive. A procedural language cannot override one of the built-in languages of Postgres.
" {} "HANDLER call_handler" {italic} "
call_handler is the name of a previously registered function that will be called to execute the PL procedures.
" {} "comment" {italic} "
The LANCOMPILER argument is the string that will be inserted in the LANCOMPILER attribute of the new pg_language entry. At present, Postgres does not use this attribute in any way.
" {} "Outputs" {bold} "
" {} "CREATE" {italic} "
This message is returned if the language is successfully created.
" {} "ERROR: PL handler function funcname\(\) doesn't exist" {italic} "
This error is returned if the function funcname() is not found.
" {} "Usage" {bold} "
This is a template for a PL handler written in 'C':
" {} "
#include \"executor/spi.h\"
#include \"commands/trigger.h\"
#include \"utils/elog.h\"
#include \"fmgr.h\" /* for FmgrValues struct */
#include \"access/heapam.h\"
#include \"utils/syscache.h\"
#include \"catalog/pg_proc.h\"
#include \"catalog/pg_type.h\"
Datum
plsample_call_handler\(
Oid prooid,
int pronargs,
FmgrValues *proargs,
bool *isNull\)
\{
Datum retval;
TriggerData *trigdata;
if \(CurrentTriggerData == NULL\) \{
/*
* Called as a function
*/
retval = ...
\} else \{
/*
* Called as a trigger procedure
*/
trigdata = CurrentTriggerData;
CurrentTriggerData = NULL;
retval = ...
\}
*isNull = false;
return retval;
\}
" {code} "
Only a few thousand lines of code have to be added instead of the dots to complete the PL call handler. See CREATE FUNCTION for information on how to compile it into a loadable module .
The following commands then register the sample procedural language:
" {} "
CREATE FUNCTION plsample_call_handler () RETURNS opaque
AS '/usr/local/pgsql/lib/plsample.so'
LANGUAGE 'C';
CREATE PROCEDURAL LANGUAGE 'plsample'
HANDLER plsample_call_handler
LANCOMPILER 'PL/Sample';
" {code} "Notes" {bold} "
Use " {} "CREATE FUNCTION" {bold} " to create a function.
Use DROP LANGUAGE to drop procedural languages.
Refer to the table pg_language for further information:
Table = pg_language
" {} "
+-----------------+----------+-------+
| Field | Type | Length|
+-----------------+----------+-------+
| lanname | name | 32 |
| lancompiler | text | var |
+-----------------+----------+-------+
lanname |lancompiler
--------+--------------
internal|n/a
lisp |/usr/ucb/liszt
C |/bin/cc
sql |postgres
" {code} "
" {} "Restrictions" {bold} "
Since the call handler for a procedural language must be registered with Postgres in the 'C' language, it inherits all the capabilities and restrictions of 'C' functions.
"

View File

@ -0,0 +1,145 @@
.pgaw:Help.f.t insert end "CREATE OPERATOR" {bold} " defines a new operator, name. The user who defines an operator becomes its owner.
The operator name is a sequence of up to thirty two (32) characters in any combination from the following:
+ - * / < > = ~ ! @ # % ^ & | ` ? $ :
" {} "Note:" {bold} " No alphabetic characters are allowed in an operator name. This enables Postgres to parse SQL input into tokens without requiring spaces between each token.
The operator \"!=\" is mapped to \"<>\" on input, so they are therefore equivalent.
At least one of LEFTARG and RIGHTARG must be defined. For binary operators, both should be defined. For right unary operators, only LEFTARG should be defined, while for left unary \
operators only RIGHTARG should be defined.
Also, the func_name procedure must have been previously defined using CREATE FUNCTION and must be defined to accept the correct number of arguments (either one or two). \
The commutator operator should be identified if one exists, so that Postgres can reverse the order of the operands if it wishes. For example, the operator area-less-than, <<<, would probably \
have a commutator operator, area-greater-than, >>>. Hence, the query optimizer could freely convert:
\"0,0,1,1\"::box >>> MYBOXES.description
to
MYBOXES.description <<< \"0,0,1,1\"::box
This allows the execution code to always use the latter representation and simplifies the query optimizer somewhat.
Similarly, if there is a negator operator then it should be identified. Suppose that an operator, area-equal, ===, exists, as well as an area not equal, !==. The negator link allows the query \
optimizer to simplify
NOT MYBOXES.description === \"0,0,1,1\"::box
to
MYBOXES.description !== \"0,0,1,1\"::box
If a commutator operator name is supplied, Postgres searches for it in the catalog. If it is found and it does not yet have a commutator itself, then the commutator's entry is updated to have the \
newly created operator as its commutator. This applies to the negator, as well.
This is to allow the definition of two operators that are the commutators or the negators of each other. The first operator should be defined without a commutator or negator (as appropriate). \
When the second operator is defined, name the first as the commutator or negator. The first will be updated as a side effect.(As of Postgres 6.5, it also works to just have both operators refer to \
each other.)
The next three specifications are present to support the query optimizer in performing joins. Postgres can always evaluate a join (i.e., processing a clause with two tuple variables separated by \
an operator that returns a boolean) by iterative substitution \[WONG76\]. In addition, Postgres can use a hash-join algorithm along the lines of \
\[SHAP86\]; however, it must know whether this \
strategy is applicable. The current hash-join algorithm is only correct for operators that represent equality tests; furthermore, equality of the datatype must mean bitwise equality of the \
representation of the type. (For example, a datatype that contains unused bits that don't matter for equality tests could not be hashjoined.) The HASHES flag indicates to the query optimizer \
that a hash join may safely be used with this operator.
Similarly, the two sort operators indicate to the query optimizer whether merge-sort is a usable join strategy and which operators should be used to sort the two operand classes. Sort operators \
should only be provided for an equality operator, and they should refer to less-than operators for the left and right side data types respectively.
If other join strategies are found to be practical, Postgres will change the optimizer and run-time system to use them and will require additional specification when an operator is defined. \
Fortunately, the research community invents new join strategies infrequently, and the added generality of user-defined join strategies was not felt to be worth the complexity involved.
The last two pieces of the specification are present so the query optimizer can estimate result sizes. If a clause of the form:
MYBOXES.description <<< \"0,0,1,1\"::box
is present in the qualification, then Postgres may have to estimate the fraction of the instances in MYBOXES that satisfy the clause. The function res_proc must be a registered function \
(meaning it is already defined using CREATE FUNCTION) which accepts arguments of the correct data types and returns a floating point number. The query optimizer simply calls this function, \
passing the parameter \"0,0,1,1\" and multiplies the result by the relation size to get the desired expected number of instances.
Similarly, when the operands of the operator both contain instance variables, the query optimizer must estimate the size of the resulting join. The function join_proc will return another floating \
point number which will be multiplied by the cardinalities of the two classes involved to compute the desired expected result size.
The difference between the function
my_procedure_1 (MYBOXES.description, \"0,0,1,1\"::box)
and the operator
MYBOXES.description === \"0,0,1,1\"::box
is that Postgres attempts to optimize operators and can decide to use an index to restrict the search space when operators are involved. However, there is no attempt to optimize functions, and \
they are performed by brute force. Moreover, functions can have any number of arguments while operators are restricted to one or two.
" {} "Synopsis" {bold} "
CREATE OPERATOR name (
PROCEDURE = func_name
\[, LEFTARG = type1 \]
\[, RIGHTARG = type2 \]
\[, COMMUTATOR = com_op \]
\[, NEGATOR = neg_op \]
\[, RESTRICT = res_proc \]
\[, JOIN = join_proc \]
\[, HASHES \]
\[, SORT1 = left_sort_op \]
\[, SORT2 = right_sort_op \]
)
" {code} "Inputs" {bold} "
" {} "name" {italic} "
The operator to be defined. See below for allowable characters.
" {} "func_name" {italic} "
The function used to implement this operator.
" {} "type1" {italic} "
The type for the left-hand side of the operator, if any. This option would be omitted for a right-unary operator.
" {} "type2" {italic} "
The type for the right-hand side of the operator, if any. This option would be omitted for a left-unary operator.
" {} "com_op" {italic} "
The commutator for this operator.
" {} "neg_op" {italic} "
The negator of this operator.
" {} "res_proc" {italic} "
The restriction selectivity estimator function for this operator.
" {} "join_proc" {italic} "
The join selectivity estimator function for this operator.
" {} "HASHES" {italic} "
Indicates this operator can support a hash-join algorithm.
" {} "left_sort_op" {italic} "
Operator that sorts the left-hand data type of this operator.
" {} "right_sort_op" {italic} "
Operator that sorts the right-hand data type of this operator.
" {} "Outputs" {bold} "
" {} "CREATE" {italic} "
Message returned if the operator is successfully created.
" {} "Usage" {bold} "
The following command defines a new operator, area-equality, for the BOX data type.
" {} "
CREATE OPERATOR === (
LEFTARG = box,
RIGHTARG = box,
PROCEDURE = area_equal_procedure,
COMMUTATOR = ===,
NEGATOR = !==,
RESTRICT = area_restriction_procedure,
JOIN = area_join_procedure,
HASHES,
SORT1 = <<<,
SORT2 = <<<)
" {code} "Notes" {bold} "
Refer to the chapter on operators in the PostgreSQL User's Guide for further information. Refer to DROP OPERATOR to delete user-defined operators from a database.
"

View File

@ -0,0 +1,132 @@
.pgaw:Help.f.t insert end "CREATE RULE" {bold} " The semantics of a rule is that at the time an individual instance is accessed, updated, inserted or deleted, there is a current instance (for retrieves, updates and deletes) and a new instance (for \
updates and appends). If the event specified in the ON clause and the condition specified in the WHERE clause are true for the current instance, the action part of the rule is executed. First, \
however, values from fields in the current instance and/or the new instance are substituted for current.attribute-name and new.attribute-name.
The action part of the rule executes with the same command and transaction identifier as the user command that caused activation.
" {} "Synopsis" {bold} "
CREATE RULE name
AS ON event
TO object \[ WHERE condition \]
DO \[ INSTEAD \] \[ action | NOTHING \]
" {code} "Inputs" {bold} "
" {} "name" {italic} "
The name of a rule to create.
" {} "event" {italic} "
Event is one of select, update, delete or insert.
" {} "object" {italic} "
Object is either table or table.column.
" {} "condition" {italic} "
Any SQL WHERE clause. new or current can appear instead of an instance variable whenever an instance variable is permissible in SQL.
" {} "action" {italic} "
Any SQL statement. new or current can appear instead of an instance variable whenever an instance variable is permissible in SQL.
" {} "Outputs" {bold} "
" {} "CREATE" {italic} "
Message returned if the rule is successfully created.
" {} "Usage" {bold} "
Make Sam get the same salary adjustment as Joe:
" {} "
create rule example_1 as
on update EMP.salary where current.name = \"Joe\"
do update EMP (salary = new.salary)
where EMP.name = \"Sam\"
" {code} "
At the time Joe receives a salary adjustment, the event will become true and Joe's current instance and proposed new instance are available to the execution routines. Hence, his new salary is \
substituted into the action part of the rule which is subsequently executed. This propagates Joe's salary on to Sam.
Make Bill get Joe's salary when it is accessed:
" {} "
create rule example_2 as
on select to EMP.salary
where current.name = \"Bill\"
do instead
select (EMP.salary) from EMP
where EMP.name = \"Joe\"
" {code} "
Deny Joe access to the salary of employees in the shoe department (current_user returns the name of the current user):
" {} "
create rule example_3 as
on select to EMP.salary
where current.dept = \"shoe\" and current_user = \"Joe\"
do instead nothing
" {code} "
Create a view of the employees working in the toy department.
" {} "
create TOYEMP(name = char16, salary = int4)
create rule example_4 as
on select to TOYEMP
do instead
select (EMP.name, EMP.salary) from EMP
where EMP.dept = \"toy\"
" {code} "
All new employees must make 5,000 or less
" {} "
create rule example_5 as
on insert to EMP where new.salary > 5000
do update newset salary = 5000
" {code} "Notes" {bold} "
A caution about SQL rules is in order. If the same class name or instance variable appears in the event, the condition and the action parts of a rule, they are all considered different tuple \
variables. More accurately, new and current are the only tuple variables that are shared between these clauses. For example, the following two rules have the same semantics:
" {} "
on update to EMP.salary where EMP.name = \"Joe\"
do update EMP ( ... ) where ...
on update to EMP-1.salary where EMP-2.name = \"Joe\"
do update EMP-3 ( ... ) where ...
" {code} "
Each rule can have the optional tag INSTEAD. Without this tag, action will be performed in addition to the user command when the event in the condition part of the rule occurs. Alternately, \
the action part will be done instead of the user command. In this later case, the action can be the keyword NOTHING.
When choosing between the rewrite and instance rule systems for a particular rule application, remember that in the rewrite system, current refers to a relation and some qualifiers whereas in \
the instance system it refers to an instance (tuple).
It is very important to note that the rewrite rule system will neither detect nor process circular rules. For example, though each of the following two rule definitions are accepted by Postgres, the \
retrieve command will cause Postgres to crash:
Example 14-1. Example of a circular rewrite rule combination.
" {} "
create rule bad_rule_combination_1 as
on select to EMP
do instead select to TOYEMP
create rule bad_rule_combination_2 as
on select to TOYEMP
do instead select to EMP
" {code} "
This attempt to retrieve from EMP will cause Postgres to crash.
" {} "
select * from EMP
" {code} "
You must have rule definition access to a class in order to define a rule on it. Use GRANT and REVOKE to change permissions.
" {} "Bugs" {bold} "
The object in a SQL rule cannot be an array reference and cannot have parameters.
Aside from the \"oid\" field, system attributes cannot be referenced anywhere in a rule. Among other things, this means that functions of instances (e.g., \"foo(emp)\" where \
\"emp\" is a class) cannot be called anywhere in a rule.
The rule system stores the rule text and query plans as text attributes. This implies that creation of rules may fail if the rule plus its various internal representations exceed some value that is on \
the order of one page (8KB). "

View File

@ -0,0 +1,42 @@
.pgaw:Help.f.t insert end \
"CREATE SEQUENCE" {bold} " will enter a new sequence number generator into the current data base. This involves creating and initialising a new single-row table with the name seqname. The generator will be \"owned\" by the user issuing the command.
After a sequence is created, you may use the function nextval(seqname) to get a new number from the sequence. The function currval('seqname') may be used to determine the number returned by the last call to nextval(seqname) for the specified sequence in the current session. The function setval('seqname', newvalue) may be used to set the current value of the specified sequence. The next call to nextval(seqname) will return the given value plus the sequence increment.
" {} "Synopsis" {bold} "
CREATE SEQUENCE seqname
\[ INCREMENT increment \]
\[ MINVALUE minvalue \]
\[ MAXVALUE maxvalue \]
\[ START start \]
\[ CACHE cache \]
\[ CYCLE \]
" {code} "
" {} "Inputs" {bold} "
" {} "seqname" {italic} "
The name of a sequence to be created.
" {} "increment" {italic} "
The INCREMENT increment clause is optional. A positive value will make an ascending sequence, a negative one a descending sequence. The default value is one (1).
" {} "minvalue" {italic} "
The optional clause MINVALUE minvalue determines the minimum value a sequence can generate. The defaults are 1 and -2147483647 for ascending and descending sequences, respectively.
" {} "maxvalue" {italic} "
Use the optional clause MAXVALUE maxvalue to determine the maximum value for the sequence. The defaults are 2147483647 and -1 for ascending and descending sequences, respectively.
" {} "start" {italic} "
The optional START start clause enables the sequence to begin anywhere. The default starting value is minvalue for ascending sequences and maxvalue for descending ones.
" {} "cache" {italic} "
The CACHE cache option enables sequence numbers to be preallocated and stored in memory for faster access. The minimum value is 1 (only one value can be generated at a time, i.e. no cache) and this is also the default.
" {} "CYCLE" {italic} "
The optional CYCLE keyword may be used to enable the sequence to continue when the maxvalue or minvalue has been reached by an ascending or descending sequence respectively. If the limit is reached, the next number generated will be whatever the minvalue or maxvalue is, as appropriate.
" {} "CAUTION" {title} "
Unexpected results may be obtained if a cache setting greater than one is used for a sequence object that will be used concurrently by multiple backends. Each backend will allocate \"cache\" successive sequence values during one access to the sequence object and increase the sequence object's last_value accordingly. Then, the next cache-1 uses of nextval within that backend simply return the preallocated values without touching the shared object. So, numbers allocated but not used in the current session will be lost. Furthermore, although multiple backends are guaranteed to allocate distinct sequence values, the values may be generated out of sequence when all the backends are considered. (For example, with a cache setting of 10, backend A might reserve values 1..10 and return nextval=1, then backend B might reserve values 11..20 and return nextval=11 before backend A has generated nextval=2.) Thus, with a cache setting of one it is safe to assume that nextval values are generated sequentially; with a cache setting greater than one you should only assume that the nextval values are all distinct, not that they are generated purely sequentially. Also, last_value will reflect the latest value reserved by any backend, whether or not it has yet been returned by nextval.
CREATE SEQUENCE is a Postgres language extension. There is no CREATE SEQUENCE statement in SQL92."

View File

@ -0,0 +1,39 @@
.pgaw:Help.f.t insert end \
"CREATE TABLE" {bold} "
CREATE \[ TEMPORARY | TEMP \] TABLE table (
column type
\[ NULL | NOT NULL \] \[ UNIQUE \] \[ DEFAULT value \]
\[column_constraint_clause | PRIMARY KEY } \[ ... \] \]
\[, ... ]
\[, PRIMARY KEY ( column \[, ...\] ) \]
\[, CHECK ( condition ) \]
\[, table_constraint_clause \]
) \[ INHERITS ( inherited_table \[, ...\] ) \]
" {code} "
TEMPORARY
The table is created only for this session, and is automatically dropped on session exit. Existing permanent tables with the same name are not visible while the temporary table exists.
" {} "
table" {italic} "
The name of a new table to be created.
" {} "
column" {italic} "
The name of a column.
" {} "
type" {italic} "
The type of the column. This may include array specifiers. Refer to the PostgreSQL User's Guide for further information about data types and arrays.
" {} "
DEFAULT value" {italic} "
A default value for a column. See the DEFAULT clause for more information.
" {} "
column_constraint_clause" {italic} "
The optional column constraint clauses specify a list of integrity constraints or tests which new or updated entries must satisfy for an insert or update operation to succeed. Each constraint must evaluate to a boolean expression. Although SQL92 requires the column_constraint_clause to refer to that column only, Postgres allows multiple columns to be referenced within a single column constraint. See the column constraint clause for more information.
" {} "
table_constraint_clause" {italic} "
The optional table CONSTRAINT clause specifies a list of integrity constraints which new or updated entries must satisfy for an insert or update operation to succeed. Each constraint must evaluate to a boolean expression. Multiple columns may be referenced within a single constraint. Only one PRIMARY KEY clause may be specified for a table; PRIMARY KEY column (a table constraint) and PRIMARY KEY (a column constraint) are mutually exclusive.. See the table constraint clause for more information.
" {} "
INHERITS inherited_table" {italic} "
The optional INHERITS clause specifies a collection of table names from which this table automatically inherits all fields. If any inherited field name appears more than once, Postgres reports an error. Postgres automatically allows the created table to inherit functions on tables above it in the inheritance hierarchy.
Aside: Inheritance of functions is done according to the conventions of the Common Lisp Object System (CLOS).
"

View File

@ -0,0 +1,20 @@
.pgaw:Help.f.t insert end "CREATE TABLE AS" {bold} " CREATE TABLE AS enables a table to be created from the contents of an existing table. It has functionality equivalent to SELECT TABLE INTO, but with perhaps a more obvious syntax.
" {} "Synopsis" {bold} "
" {} "
CREATE TABLE table \[ (column \[, ...\] ) \]
AS select_clause
" {code} "Inputs" {bold} "
" {} "table" {italic} "
The name of a new table to be created.
" {} "column" {italic} "
The name of a column. Multiple column names can be specified using a comma-delimited list of column names.
" {} "select_clause" {italic} "
A valid query statement. Refer to SELECT for a description of the allowed syntax.
" {} "Outputs" {bold} "
Refer to CREATE TABLE and SELECT for a summary of possible output messages. "

View File

@ -0,0 +1,80 @@
.pgaw:Help.f.t insert end "CREATE TRIGGER" {bold} " will enter a new trigger into the current data base. The trigger will be associated with the relation relname and will execute the specified function funcname.
The trigger can be specified to fire either before the operation is attempted on a tuple (before constraints are checked and the INSERT, UPDATE or DELETE is attempted) or after the operation \
has been attempted (e.g. after constraints are checked and the INSERT, UPDATE or DELETE has completed). If the trigger fires before the event, the trigger may skip the operation for the \
current tuple, or change the tuple being inserted (for INSERT and UPDATE operations only). If the trigger fires after the event, all changes, including the last insertion, update, or deletion, are \
\"visible\" to the trigger.
Refer to the chapters on SPI and Triggers in the PostgreSQL Programmer's Guide for more information.
" {} "Synopsis" {bold} "
CREATE TRIGGER name \{ BEFORE | AFTER \}
\{ event \[OR ...\] \}
ON table FOR EACH \{ ROW | STATEMENT \}
EXECUTE PROCEDURE funcname ( arguments )
" {code} "Inputs" {bold} "
" {} "name" {italic} "
The name of an existing trigger.
" {} "table" {italic} "
The name of a table.
" {} "event" {italic} "
One of INSERT, DELETE or UPDATE.
" {} "funcname" {italic} "
A user-supplied function.
" {} "Outputs" {bold} "
" {} "CREATE" {italic} "
This message is returned if the trigger is successfully created.
" {} "Usage" {bold} "
Check if the specified distributor code exists in the distributors table before appending or updating a row in the table films:
" {} "
CREATE TRIGGER if_dist_exists
BEFORE INSERT OR UPDATE ON films FOR EACH ROW
EXECUTE PROCEDURE check_primary_key ('did', 'distributors', 'did');
" {code} "
Before cancelling a distributor or updating its code, remove every reference to the table films:
" {} "
CREATE TRIGGER if_film_exists
BEFORE DELETE OR UPDATE ON distributors FOR EACH ROW
EXECUTE PROCEDURE check_foreign_key (1, 'CASCADE', 'did', 'films', 'did');
" {code} "Compatibility" {bold} "
" {} "SQL92" {italic} "
There is no CREATE TRIGGER in SQL92.
The second example above may also be done by using a FOREIGN KEY constraint as in:
" {} "
CREATE TABLE distributors (
did DECIMAL(3),
name VARCHAR(40),
CONSTRAINT if_film_exists
FOREIGN KEY(did) REFERENCES films
ON UPDATE CASCADE ON DELETE CASCADE
);
" {code} "
However, foreign keys are not yet implemented (as of version 6.4) in Postgres.
" {} "Notes" {bold} "
" {} "CREATE TRIGGER" {italic} " is a Postgres language extension.
Only the relation owner may create a trigger on this relation.
As of the current release (v6.4), STATEMENT triggers are not implemented.
Refer to DROP TRIGGER for information on how to remove triggers. "

View File

@ -0,0 +1,24 @@
.pgaw:Help.f.t insert end "CREATE TYPE" {bold} " allows the user to register a new user data type with Postgres for use in the current data base. The user who defines a type becomes its owner. Typename is the name of the new \
type and must be unique within the types defined for this database.
" {} "Synopsis" {bold} "
CREATE TYPE typename (
INPUT = input_function
, OUTPUT = output_function
, INTERNALLENGTH = (internallength | VARIABLE)
\[ , EXTERNALLENGTH = (externallength | VARIABLE) \]
\[ , ELEMENT = element \]
\[ , DELIMITER = delimiter \]
\[ , DEFAULT = \"default\" \]
\[ , SEND = send_function \]
\[ , RECEIVE = receive_function \]
\[ , PASSEDBYVALUE \]
)
" {code} "Notes" {bold} "
Refer to DROP TYPE to remove an existing type.
See also CREATE FUNCTION, CREATE OPERATOR and the chapter on Large Objects in the PostgreSQL Programmer's Guide.
"

View File

@ -0,0 +1,50 @@
.pgaw:Help.f.t insert end "CREATE USER" {bold} " will add a new user to an instance of Postgres.
The new user will be given a usesysid of: 'SELECT MAX(usesysid) + 1 FROM pg_shadow'. This means that Postgres users' usesysids will not correspond to their operating system(OS) \
user ids. The exception to this rule is the 'postgres' user, whose OS user id is used as the usesysid during the initdb process. If you still want the OS user id and the usesysid to match for any \
given user, use the \"createuser\" script provided with the Postgres distribution.
" {} "Synopsis" {bold} "
CREATE USER username
\[ WITH PASSWORD password \]
\[ CREATEDB | NOCREATEDB \]
\[ CREATEUSER | NOCREATEUSER \]
\[ IN GROUP groupname \[, ...\] \]
\[ VALID UNTIL 'abstime' \]
" {code} "Usage" {bold} "
Create a user with no password:
" {} " CREATE USER jonathan
" {code} "
Create a user with a password:
" {} " CREATE USER davide WITH PASSWORD jw8s0F4
" {code} "
Create a user with a password, whose account is valid until the end of 2001. Note that after one second has ticked in 2002, the account is not valid:
" {} " CREATE USER miriam WITH PASSWORD jw8s0F4 VALID UNTIL 'Jan 1 2002'
" {code} "
Create an account where the user can create databases:
" {} " CREATE USER manuel WITH PASSWORD jw8s0F4 CREATEDB
" {code} "Notes" {bold} "
CREATE USER statement is a Postgres language extension.
Use DROP USER or ALTER USER statements to remove or modify a user account.
Refer to the pg_shadow table for further information.
" {} "
Table = pg_shadow
+--------------------------+--------------------------+-------+
| Field | Type | Length|
+--------------------------+--------------------------+-------+
| usename | name | 32 |
| usesysid | int4 | 4 |
| usecreatedb | bool | 1 |
| usetrace | bool | 1 |
| usesuper | bool | 1 |
| usecatupd | bool | 1 |
| passwd | text | var |
| valuntil | abstime | 4 |
+--------------------------+--------------------------+-------+
" {code}

View File

@ -0,0 +1,27 @@
.pgaw:Help.f.t insert end "CREATE VIEW" {bold} " will define a view of a table. This view is not physically materialized. Specifically, a query rewrite retrieve rule is automatically generated to support retrieve operations on \
views.
" {} "Synopsis" {bold} "
CREATE VIEW view
AS SELECT query
" {} "Usage" {bold} "
Create a view consisting of all Comedy films:
" {} "
CREATE VIEW kinds AS
SELECT *
FROM films
WHERE kind = 'Comedy';
SELECT * FROM kinds;
code |title |did| date_prod|kind |len
-----+-------------------------+---+----------+----------+------
UA502|Bananas |105|1971-07-13|Comedy | 01:22
C_701|There's a Girl in my Soup|107|1970-06-11|Comedy | 01:36
" {code} "Notes" {bold} "
Use the DROP VIEW statement to drop views. "

View File

@ -0,0 +1,48 @@
.pgaw:Help.f.t configure -tabs {130 300 450}
.pgaw:Help.f.t insert end \
"Data types\n\n" {title} \
"Postgres has a rich set of native data types available to users. Users may add new types to Postgres using the DEFINE TYPE command described elsewhere.
In the context of data types, the following sections will discuss SQL standards compliance, porting issues, and usage. Some Postgres types correspond directly to SQL92-compatible types. In other cases, data types defined by SQL92 syntax are mapped directly into native Postgres types. Many of the built-in types have obvious external formats. However, several types are either unique to Postgres, such as open and closed paths, or have several possibilities for formats, such as the date and time types.
" {} \
"Postgres Type\tSQL92 or SQL3 Type\tDescription\n" {bold} \
"bool\tboolean\tlogical boolean (true/false)
box\t\trectangular box in 2D plane\tchar(n)
character(n)\t\tfixed-length character string
cidr\t\tIP version 4 network or host address
circle\t\tcircle in 2D plane
date\tdate\tcalendar date without time of day
float4/8\tfloat(p)\tfloating-point number with precision p
float8\treal, double precision\tdouble-precision floating-point number
inet\t\tIP version 4 network or host address
int2\tsmallint\tsigned two-byte integer
int4\tint, integer\tsigned 4-byte integer
int4\tdecimal(p,s)\texact numeric for p <= 9, s = 0
int4\tnumeric(p,s)\texact numeric for p == 9, s = 0
int8\t\tsigned 8-byte integer
line\t\tinfinite line in 2D plane
lseg\t\tline segment in 2D plane
money\tdecimal(9,2)\tUS-style currency
path\t\topen and closed geometric path in 2D plane
point\t\tgeometric point in 2D plane
polygon\t\tclosed geometric path in 2D plane
serial\t\tunique id for indexing and cross-reference
time\ttime\ttime of day
timespan\tinterval\tgeneral-use time span
timestamp\ttimestamp with time zone\tdate/time
varchar(n)\tcharacter varying(n)\tvariable-length character string
Note: The cidr and inet types are designed to handle any IP type but only ipv4 is handled in the current implementation. Everything here that talks about ipv4 will apply to ipv6 in a future release.
" {} \
"Postgres Function Constants
Postgres Function\tSQL92 Constant\tDescription" {bold} \
"
getpgusername()\tcurrent_user\tuser name in current session
date('now')\tcurrent_date\tdate of current transaction
time('now')\tcurrent_time\ttime of current transaction
timestamp('now')\tcurrent_timestamp\tdate and time of current transaction
" {}

View File

@ -0,0 +1,58 @@
.pgaw:Help.f.t insert end \
"DateTime functions\n\n" {title} \
"abstime(datetime) " {bold} "
Returns: abstime
convert to abstime
" {} "age(datetime,datetime) " {bold} "
Returns: timespan
preserve months and years
" {} "datetime(abstime) " {bold} "
Returns: datetime
convert to datetime
" {} "datetime(date) " {bold} "
Returns: datetime
convert to datetime
" {} "datetime(date,time) " {bold} "
Returns: datetime
convert to datetime
" {} "date_part(text,datetime) " {bold} "
Returns: float8
portion of date
" {} "date_part(text,timespan) " {bold} "
Returns: float8
portion of time
" {} "date_trunc(text,datetime) " {bold} "
Returns: datetime
truncate date
" {} "isfinite(abstime) " {bold} "
Returns: bool
a finite time?
" {} "isfinite(datetime) " {bold} "
Returns: bool
a finite time?
" {} "isfinite(timespan) " {bold} "
Returns: bool
a finite time?
" {} "reltime(timespan) " {bold} "
Returns: reltime
convert to reltime
" {} "timespan(reltime) " {bold} "
Returns: timespan
convert to timespan
" {} \
"PostgreSQL functions\n" {link pgfunctions} \
"Next - geometric functions" {link geomfunc}

View File

@ -0,0 +1,29 @@
.pgaw:Help.f.t insert end "DECLARE" {bold} " allows a user to create cursors, which can be used to retrieve a small number of rows at a time out of a larger query. Cursors can return data either in text or in binary foramt.
Normal cursors return data in text format, either ASCII or another encoding scheme depending on how the Postgres backend was built. Since data is stored natively in binary format, the system \
must do a conversion to produce the text format. In addition, text formats are often larger in size than the corresponding binary format. Once the information comes back in text form, the client \
application may have to convert it to a binary format to manipulate it anyway.
BINARY cursors give you back the data in the native binary representation. So binary cursors will tend to be a little faster since they suffer less conversion overhead.
" {} "Synopsis" {bold} "
DECLARE cursor \[ BINARY \] \[ INSENSITIVE \] \[ SCROLL \]
CURSOR FOR query
\[ FOR \[ READ ONLY | UPDATE \[ OF column \[, ...\] \] \]
" {code} "Usage" {bold} "
To declare a cursor:
" {} "
DECLARE liahona CURSOR
FOR SELECT * FROM films;
" {code} "Notes" {bold} "
Cursors are only available in transactions.
Postgres does not have an explicit OPEN cursor statement; a cursor is considered to be open when it is declared.
Note: In SQL92 cursors are only available in embedded applications. ecpg, the embedded SQL preprocessor for Postgres, supports the SQL92 conventions, including those \
involving DECLARE and OPEN statements. "

View File

@ -0,0 +1,43 @@
.pgaw:Help.f.t insert end "DELETE" {bold} " emoves rows which satisfy the WHERE condition, from the specified table. \
If the condition is absent, the effect is to delete all rows in the table. The result is a valid, but empty table. \
You must have write access to the table in order to modify it, as well as read access to any table whose values are read in the condition.
" {} "Synopsis" {bold} "
" {} "
DELETE FROM table \[ WHERE condition \]
" {code} "Usage" {bold} "
Remove all films but musicals:
" {} "
DETETE FROM films WHERE kind <> 'Musical';
SELECT * FROM films;
code |title |did| date_prod|kind |len
-----+-------------------------+---+----------+----------+------
UA501|West Side Story |105|1961-01-03|Musical | 02:32
TC901|The King and I |109|1956-08-11|Musical | 02:13
WD101|Bed Knobs and Broomsticks|111| |Musical | 01:57
(3 rows)
Clear the table films:
DELETE FROM films;
SELECT * FROM films;
code|title|did|date_prod|kind|len
----+-----+---+---------+----+---
(0 rows)
" {code} "Compatibility" {bold} "
SQL92
SQL92 allows a positioned DELETE statement:
DELETE FROM table WHERE CURRENT OF cursor
where cursor identifies an open cursor. Interactive cursors in Postgres are read-only. "

View File

@ -0,0 +1,17 @@
.pgaw:Help.f.t insert end "DROP AGGREGATE" {bold} " will remove all references to an existing aggregate definition. To execute this command the current user must be the owner of the aggregate.
" {} "Synopsis" {bold} "
DROP AGGREGATE name type
" {} "Usage" {bold} "
To remove the myavg aggregate for type int4:
DROP AGGREGATE myavg int4;
" {} "Notes" {bold} "
The DROP AGGREGATE statement is a Postgres language extension.
Refer to the CREATE AGGREGATE statement to create aggregate functions. "

Some files were not shown because too many files have changed in this diff Show More