The following example copies a table to standard output, using a vertical bar \(\"|\"\) as the field delimiter:
COPY country TO stdout WITH 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';
...
...
@@ -93,12 +93,13 @@ The format for each instance in the file is as follows. Note that this format mu
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 WITH DELIMITER. Characters in data fields which happen to match the delimiter character will be quoted.
\(\"\\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 " {} "WITH DELIMITER" {bold} " specifies a single character to be used for all delimiters between columns.
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. "
if [catch {wpg_select $CurrentDB "select datlastsysoid from pg_database where datname='$dbname'" rec {
set maxim $rec(datlastsysoid)
}
}]{
catch {
wpg_select $CurrentDB "select oid from pg_database where datname='template1'" rec {
set maxim $rec(oid)
}
catch {
wpg_select $CurrentDB "select oid from pg_database where datname='template1'" rec {
set maxim $rec(oid)
}
}
.pgaw:Main.lb delete 0 end
...
...
@@ -301,17 +295,19 @@ catch {
}
proc {cmd_Views}{}{
global CurrentDB PgAcVar
global CurrentDB
setCursor CLOCK
.pgaw:Main.lb delete 0 end
catch {
if {! $PgAcVar(pref,systemtables)}{
set sysconstraint "where (viewname !~ '^pg_') and (viewname !~ '^pga_')"
} else {
set sysconstraint ""
wpg_select $CurrentDB "select c.relname,count(c.relname) from pg_class C, pg_rewrite R where (relname !~ '^pg_') and (r.ev_class = C.oid) and (r.ev_type = '1') group by relname" rec{
if {$rec(count)!=0}{
set itsaview($rec(relname)) 1
}
}
wpg_select $CurrentDB "select viewname from pg_views $sysconstraint order by viewname" rec {
.pgaw:Main.lb insert end $rec(viewname)
wpg_select $CurrentDB "select relname from pg_class where (relname !~ '^pg_') and (relkind='r') and (relhasrules) order by relname" rec {
# fills in an array with columns so formulas can access them
proc {design:getSourceFieldsForPreview}{}{
global PgAcVar CurrentDB
set PgAcVar(report,source_fields){}
wpg_select $CurrentDB "select attnum,attname from pg_class,pg_attribute where (pg_class.relname='$PgAcVar(report,tablename)') and (pg_class.oid=pg_attribute.attrelid) and (attnum>0) order by attnum" rec {
wpg_select $CurrentDB "select attnum,attname from pg_class,pg_attribute where (pg_class.relname='$PgAcVar(report,tablename)') and (pg_class.oid=pg_attribute.attrelid) and (attnum>0) order by attnum" rec {
.pgaw:ReportBuilder.lb insert end $rec(attname)
.pgaw:ReportBuilder:menu.lb insert end $rec(attname)
}
#setCursor DEFAULT
}
proc {hasTag}{id tg}{
if {[lsearch [.pgaw:ReportBuilder.c itemcget $id -tags] $tg]==-1} then {return 0 } else {return 1}
proc {design:hasTag}{id tg}{
if {[lsearch [.pgaw:ReportBuilder:draft.c itemcget $id -tags] $tg]==-1} then {return 0 } else {return 1}
}
proc {init}{}{
proc {design:init}{}{
global PgAcVar
set PgAcVar(report,xl_auto) 10
set PgAcVar(report,xf_auto) 10
set PgAcVar(report,xp_auto) 10
set PgAcVar(report,xo_auto) 10
set PgAcVar(report,regions){rpthdr pghdr detail pgfoo rptfoo}
set PgAcVar(report,y_rpthdr) 30
set PgAcVar(report,y_pghdr) 60
...
...
@@ -132,120 +173,319 @@ global PgAcVar
set PgAcVar(report,e_detail)[intlmsg {Detail record}]
set PgAcVar(report,e_pgfoo)[intlmsg {Page footer}]
set PgAcVar(report,e_rptfoo)[intlmsg {Report footer}]
drawReportAreas
design:drawReportAreas
}
proc {loadReport}{}{
proc {design:loadReport}{}{
global PgAcVar CurrentDB
.pgaw:ReportBuilder.c delete all
.pgaw:ReportBuilder:draft.c delete all
wpg_select $CurrentDB "select * from pga_reports where reportname='$PgAcVar(report,reportname)'" rcd {
eval $rcd(reportbody)
}
getSourceFields
drawReportAreas
design:changeDraftCoords
design:getSourceFields
design:drawReportAreas
}
# get the preview cranking
proc {design:preview}{}{
global PgAcVar
design:previewInit
set PgAcVar(report,curr_page) 1
if {$PgAcVar(report,last_page)>0}{
design:previewPage
}
}
proc {preview}{}{
# finds the record and page counts
proc {design:previewInit}{}{
global PgAcVar CurrentDB
Window show .pgaw:ReportPreview
set ol [.pgaw:ReportBuilder:draft.c find withtag ro]
set PgAcVar(report,prev_fields){}
# set up the fields we need to fill with data
foreach objid $ol {
set tags [.pgaw:ReportBuilder:draft.c itemcget $objid -tags]
if {[tk_messageBox -title [intlmsg Warning] -parent .pgaw:ReportBuilder -message [intlmsg "All report information will be deleted.\n\nProceed ?"] -type yesno -default no]=="yes"} then {
.pgaw:ReportBuilder.c delete all
init
drawReportAreas
proc {design:deleteAllObjects}{}{
if {[tk_messageBox -title [intlmsg Warning] -parent .pgaw:ReportBuilder:draft -message [intlmsg "All report information will be deleted.\n\nProceed ?"] -type yesno -default no]=="yes"} then {
showError [format [intlmsg "Schema '%s' was not found!"] $PgAcVar(schema,name)]
pg_result $pgres -clear
return
}
set tuple [pg_result $pgres -getTuple 0]
set links [lindex $tuple 1]
pg_result $pgres -clear
set linkslist {}
set PgAcVar(schema,links)$links
foreach link $PgAcVar(schema,links){
set linklist {}
foreach {tbl fld} $link {
if {$tbl==$tbl_name}{
if {$fld==$old_name}{ set fld $new_name}
}
lappend linklist $tbl $fld
}
lappend linkslist $linklist
}
sql_exec noquiet "update pga_schema set schemalinks='$linkslist' where schemaname='$schema'"
}
proc {tbl_rename}{{old_name}{new_name}}{
global PgAcVar CurrentDB
catch {
wpg_select $CurrentDB "select schemaname from pga_schema where (schematables like '$old_name %') or (schematables like '% $old_name %') order by schemaname" rec {
set pgres [wpg_exec $CurrentDB "insert into pga_schema values ('$PgAcVar(schema,name)','$tables','$PgAcVar(schema,links)')"]
} else {
set pgres [wpg_exec $CurrentDB "update pga_schema set schemaname='$PgAcVar(schema,name)',schematables='$tables',schemalinks='$PgAcVar(schema,links)' where oid=$PgAcVar(schema,oid)"]
# showError [intlmsg "$tables"]
}
setCursor DEFAULT
if {$PgAcVar(pgsql,status)!="PGRES_COMMAND_OK"} then {
wpg_select $CurrentDB "select indexrelid from pg_index, pg_class where (pg_class.relname='$PgAcVar(tblinfo,tablename)') and (pg_class.oid=pg_index.indrelid)" rec {
wpg_select $CurrentDB "select oid,indexrelid from pg_index where (pg_class.relname='$PgAcVar(tblinfo,tablename)') and (pg_class.oid=pg_index.indrelid)" rec {
lappend PgAcVar(tblinfo,indexlist) $rec(oid)
wpg_select $CurrentDB "select relname from pg_class where oid=$rec(indexrelid)" rec1 {
.pgaw:TableInfo.f2.fl.ilb insert end $rec1(relname)
}
...
...
@@ -544,8 +544,7 @@ if {$PgAcVar(mw,$wn,row_edited)==$PgAcVar(mw,$wn,last_rownum)} {
set PgAcVar(mw,$wn,newrec_values)[lreplace $PgAcVar(mw,$wn,newrec_values) $sfp $sfp]