[SQL] Unexplained SQL behavior

2002-08-17 Thread JOE
I am debugging a performance problem with a view.  I have narrowed down the problem to when I adeed columns to my view. In the examples below I have a view with 10 columns.  I run an explain plan and it uses the primary key of the driver table (enrollment table) as to be expected and execu

[SQL] union optimization in views

2002-08-28 Thread JOE
and didn't see anything (of course I could have missed references).    thanks - Joe   snip of an Article from SQL archives    CREATE VIEW two_tables AS SELECT t1.id, t1.name, t1.abbreviation, t1.juris_id FROM t1 UNION ALL SELECT t2.id, t2.name, NULL, t2.juris_id FROM t2;This works fine as a vie

Re: [SQL] Question about One to Many relationships

2006-03-24 Thread Joe
d), PRIMARY KEY (band_id, album_id) ) This of course precludes the same band being listed twice in a given album. If you do need that info, then you're really asking for "tracks". Joe ---(end of broadcast)--- TIP 9: In versions belo

Re: [SQL] MySQL DB to PostgresSQL DB

2006-05-18 Thread Joe
t; tables (with a textual representation of the columns). An interesting side effect was discovering data inconsistencies in the MySQL database since as part of the conversion I implemented foreign key constraints under PostgreSQL (which were missing in the former). Joe ---

[SQL] Repetitive code

2006-06-15 Thread Joe
or 2). Another redundancy is the "date_trunc('day', updated) != created" which is there to avoid selecting "changed" records when they're actually new. However, although creating these views may simplify the subqueries it doesn't seem there is a way to

Re: [SQL] Repetitive code

2006-06-16 Thread Joe
mention that because in essence the query is used to materialize a view, i.e., it's part of an INSERT / SELECT into a table which is then joined back to the other tables to construct a web page as well as an RSS feed. Joe ---(end of broadcast)---

Re: [SQL] Repetitive code

2006-06-16 Thread Joe
good idea too because schema changes would be somewhat insulated by the layered views. Best regards, Joe ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq

Re: [SQL] avg(interval)

2006-06-26 Thread Joe
days 22:47:41.749756";"*2420" "3 days 06:05:59.456947";"*2420" which should average to just over nine days - Uh ... how do you arrive at that conclusion? I haven't done the math, but by eyeball an average of four-something days doesn't look out of

Re: [SQL] avg(interval)

2006-06-26 Thread Joe
2; t - 2006-06-07 22:24:00 2006-06-09 22:21:00 2006-05-31 23:21:00 2006-06-04 22:47:00 2006-06-03 06:05:00 (5 rows) test=> select avg(t - '2006-5-31 0:0'::timestamp) from x2; avg - 5 days 09:47:36 (1 row) Joe -

Re: Fwd: [SQL] Start up question about triggers

2006-06-27 Thread Joe
two locations: that's a matter of safety. Slony does it automatically, as long as the daemon is running. No need to control it. But with file-based log shipping (see http://linuxfinances.info/info/logshipping.html) one could write a Java app to control when the updates are applied.

Re: [SQL] Data Entry and Query forms

2006-06-29 Thread Joe
Aaron Bono wrote: Are there any web based management tools for PostgreSQL (like Mysql PHP Admin except for PostgreSQL)? I thought I saw a post sometime back about one but don't remember the name. Yes, that's phpPgAdmin (http://phppgadmin.com). Joe

Re: [SQL] ERROR: SELECT query has no destination for result data

2006-08-31 Thread Joe
or; You haven't declared numRegistros. Joe ---(end of broadcast)--- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq

Re: [SQL] Evaluation of if conditions

2006-09-06 Thread Joe
. Expression Evaluation Rules of the manual: The order of evaluation of subexpressions is not defined. In particular, the inputs of an operator or function are not necessarily evaluated left-to-right or in any other fixed order. There's more examples there too. Joe --

Re: [SQL] Is this a bug? Deleting a column deletes the constraint.

2006-10-12 Thread Joe
ed if > they reference just the one single column. Ick. I didn't realize before that you can also drop all columns, leaving a table without *any* columns. Is that a SQL92 "feature"? Joe ---(end of broadcast)--- TIP 4: Have

Re: [SQL] Case Preservation disregarding case sensitivity?

2006-10-27 Thread Joe
ier names, you have to use double quotes wherever you refer to the identifier. Without the double quotes, the SQL implementor can either use UPPERCASE (as I believe Oracle and DB2 do) or lowercase (as PG does) when it displays those identifiers. Joe ---(end of broadcas

Re: [SQL] show privileges

2006-11-06 Thread Joe
ntation under the GRANT privileges section that would help > immensely. I always have to hunt this down when I need it. You mean something like \du at the psql prompt? Joe ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Between and miliseconds (timestamps)

2006-11-10 Thread Joe
uisition. I think you want to cast the field, not the constant, e.g., testdb=> select * from t2 where date(tm) = '2006-9-6'; tm --- 2006-09-06 00:00:01-04 2006-09-06 23:59:59.99-04 (2 rows) Joe

Re: [SQL] Question about time

2006-11-16 Thread Joe
HOUR:MINUTE:SECOND > > the question is how I drop the millisecond?? Take a look at date_trunc() under Date/Time Functions and Operators. Joe ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at

Re: [SQL] Numbers

2006-11-24 Thread Joe
nd remember to take any numbers with a large grain of salt, YMMV, etc. Joe ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate

Re: [SQL] Need to subtract values between previous and current row

2006-12-15 Thread Joe
gt; 510/30/2006 > > Now I need a query that will subtract atime of row 1 from row 2, row2 > from row3 and so on... > > Can anyone please help? How about something like this select x.id, x.atime, x.atime - y.atime as diff from yourtable x, yourtable y where x.id + 1 = y.id;

Re: [SQL] Log, Logs and more Logs

2007-01-31 Thread Joe
Did you look at the setting of redirect_stderr, and the various logging settings just above it? Joe ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate

Re: [SQL] Open a Transaction

2007-02-08 Thread Joe
, > 41504, > 41505, > 41506, > 41507, > 41508, > 41509, > 41510, > 41511, > 41512, > 41513, > 41514, > 41515, > 41516, > 41517, > 41518, > 41519, > 41520, > 41521, > 41522, > 41523, > 41524, > 41525, > 41526, > 41527, > 41528, R

Re: [SQL] huge disparities in =/IN/BETWEEN performance

2007-02-08 Thread Joe
fore cannot transform one expression into another? What about "x = 10 AND x < 5"? Can't it reduce that to FALSE? Joe ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscri

Re: [SQL] huge disparities in =/IN/BETWEEN performance

2007-02-08 Thread Joe
ecution" may not be that obvious to the "naked eye" but it would be to a boolean logic analyzer. As to whether these query instances represent few or are typical is arguable, and will depend on the type of application, level of knowledge among users, and what k

Re: [SQL] COPY FROM query.

2007-02-11 Thread Joe
hat on Windows you need to use double backslashes, i.e., 'c:\ \autodrs_appraisal_new.txt', although the regular slash may also work, i.e., 'c:/autodrs_appraisal_new.txt'. Joe ---(end of broadcast)--- TIP 5: don't forget to increase your free space map settings

Re: [SQL] simple web search

2007-02-23 Thread Joe
show.show_name, > story.title, person.firtname, person.lastname, etc. > > What is the most elegant way to build a single query to match search > words with multiple columns? You may want to take a look at contrib/tsearch2. Joe ---(end of broadcast)---

Re: [SQL] how do I to generate a sequence Range or Set of integer constants

2007-02-23 Thread Joe
IntId FROM MyDataTable ORDER BY id; The id_seq is the sequence on your ID column, assuming it has one, or you can replace the (SELECT ... FROM id_seq) by 1000. Joe ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] pg_dump inquiry

2007-03-01 Thread Joe
gt; rules used by psql's \d commands (see Patterns), so multiple tables can > also be selected by writing wildcard characters in the pattern." But note that this is a new feature in 8.2. In 8.1 and earlier, multiple -t switches will only get you the last one specified. Joe

Re: [SQL] Statistics

2007-03-09 Thread Joe
erpriseDB and Pervasive may have some of what you're looking for since they have to measure themselves against the competition. And remember to take any numbers with a large grain of salt, YMMV, etc. Joe ---(end of broadcast)--- TIP 1: if p

Re: [SQL] Dummy question

2007-03-22 Thread Joe
= tb2.id Try select tb1.* from tabel1 as tb1, table2 as tb2 where tb2.id = 2 and tb1.fk_tb2ID = tb2.id; Joe ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL

Re: [SQL] exception handling in postgres plpgsql

2007-04-03 Thread Joe
tion condition "no_data_found" > CONTEXT: compile of PL/pgSQL function "audio_format_func" near line > 15 The constant is no_data. See http://www.postgresql.org/docs/8.2/static/errcodes-appendix.html Joe ---(end of broadcast)--

Re: [SQL] Urgent help in bit_string data type

2007-04-11 Thread Joe
rewrite or cast the expression. As suggested by the error, you should use a cast, e.g., insert into test_a values 9::bit(3); This will result in binary '001' being inserted because you need 4 bits to represent decimal 9. Joe ---(end of broadcast)

Re: [ADMIN] [SQL] Urgent help in bit_string data type

2007-04-11 Thread Joe
using the bit string operators, as someone pointed out a couple of days ago. In case you haven't looked at them, please see: http://www.postgresql.org/docs/8.2/static/functions-bitstring.html Joe ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate

Re: [ADMIN] [SQL] Urgent help in bit_string data type

2007-04-11 Thread Joe
licit cast, and finally it has to convert back to text for the to_number function. The result of to_number is numeric and you're trying to cast it to bit, which is what the ERROR was telling you can't do. Joe ---(end of broadcast)--- TIP 7:

Re: [SQL] A long-running transaction

2007-04-13 Thread Joe
expire, and that test isn't free. Therefore, you do it the same way > any other row gets expired. Just curious: is there a way to defeat MVCC? i.e., if you can lock the database exclusively, there won't be any readers or writers? Joe ---(end of broadcas

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Joe
yone on this list) will be out of a job and PHP/Perl/etc. will be relegated to the dustbin of programming languages. [Sorry, couldn't resist :-) ] Joe * see http://en.wikipedia.org/wiki/Geico ---(end of broadcast)--- TIP 3: Have you checked

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-20 Thread Joe
n as to how this will be accomplished or ensured that it is correct. Second is how does TML handle relational manipulations such as restriction, projection or aggregation. It appears TML is primarily for joins. Lastly, Dmitry, I think you'll be better off discussing this in comp.databases.theory.

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-23 Thread Joe
n a real web application. Show us what TML can do for the users, bboard and classified_ads tables (http://philip.greenspun.com/sql/data-modeling.html), and how it can answer the simple and complex queries in the next two chapters (or as I said, pick a real-life example of your own) and then maybe w

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-24 Thread Joe
all about. The POSTGRES UCB project had a language called PostQUEL, which may have been technically superior to SQL, but market forces (unfortunately not all "free") pushed Postgres95 and then PostgreSQL to adopt the latter in preference to PostQUEL. Maybe one day we'll ha

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-25 Thread Joe
agree and converge on those choices. > > 1. Not users, but programmers. > 2. Needs are produced also, as goods and capital goods. > Karl Marks >For example, look at yourself. We are on diametrically opposed sides of that argument, but it's off-to

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-04-26 Thread Joe
Dmitry, On Thu, 2007-04-26 at 11:33 +0300, Dmitry Turin wrote: > Joe, i speak not about you, but about statistics. Do you actually have statistics of how many people in the general population have learned SQL? And furthermore, how many of those people didn't already know or didn&#

Re: [SQL] We all are looped on Internet: request + transport = invariant

2007-05-02 Thread Joe
t you seem to be having a hard time convincing those of us who've taken even a mild interest in TML that it's really needed or is a better solution than what exists today. Joe ---(end of broadcast)--- TIP 1: if posting/reading through Usenet

Re: [SQL] Argentinian timezone change at the last moment. How to change pgsql tz db?

2008-01-02 Thread Joe
ocal/share/postgresql/timezone. Joe ---(end of broadcast)--- TIP 7: You can help support the PostgreSQL project by donating at http://www.postgresql.org/about/donate

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Joe
did happen, code points 1777 and nearby are not digits; they're something or other in Arabic, apparently. Precisely. 1777 through 1780 decimal equate to code points U+06F1 through U+06F4, which correspond to the Arabic numerals 1 through 4. Joe ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] UTF8 encoding and non-text data types

2008-01-14 Thread Joe
hat it's application specific. The HTML/Perl script ought to convert to Western numerals. Joe ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

Re: [SQL] Select into

2008-03-20 Thread Joe
col1 = 3; will result in: col1 | col2 | col3 --+--+--- 1 | 789 | third record 2 | 456 | second record 3 | 789 | third record So, it is a join ... of a table with a virtual copy of itself. Joe -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To

Re: [SQL] Select into

2008-03-20 Thread Joe
nd above. I don't see why my query would fail in subsequent releases. Joe -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Protection from SQL injection

2008-04-27 Thread Joe
xample using the pyformat style: http://www.devx.com/opensource/Article/29071/0/page/3. Joe -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Protection from SQL injection

2008-04-27 Thread Joe
t support prepared statements. I assume you didn't check the PEP 249 (http://www.python.org/dev/peps/pep-0249/). The execute() and executemany() Cursor object methods are precisely to prepare and execute database operations. Joe -- Sent via pgsql-sql mailing list (pgsql-sq

Re: [SQL] bcp.exe Fix Triggers

2008-06-02 Thread Joe
Use an underscore (_) instead of a minus (-), i.e., $bcp_fix$. Joe -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] Cursor

2008-08-16 Thread Joe
loop, you can check sqlca.sqlcode for 100 (NOT FOUND) or a SQLSTATE of 02000. Joe -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] ORDER BY collation order

2008-09-18 Thread Joe
ter since it's shared with others at our hosting provider. Is there some way to override the cluster setting, or plans to allow for database-specific collation orders? Joe -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresq

Re: [SQL] ORDER BY collation order

2008-09-18 Thread Joe
27;s even trickier than this simple example, because on Debian which is using the en_US locale, the double quotes are disregarded for ordering purposes, e.g., Medical "Meet" Message Joe -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

Re: [SQL] ORDER BY collation order

2008-09-21 Thread Joe
a -- Abc 123 "quoted" (3 rows) Those operators give me "C"-style collation in the database that is using "en_US" collation, but what I would really prefer is the reverse. BTW, where are those operators documented? Neither Google nor Yahoo nor postgresql.org s

Re: [SQL] grouping/clustering query

2008-10-23 Thread Joe
ce transaction 1 was applied to both invoices A and B, you need to group the invoices so that you can compare total invoiced against total paid. Joe -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] CREATE USER through SQL possible?

2000-08-17 Thread Adams, Joe
print "USER HAS BEEN ADDED$ADDstatement"; } Has anyone done this before? If so I could use some guidence because I can't seem to get it working. Joe Adams

[SQL] psql question

2000-11-23 Thread Joe Conway
e escape/tab key for command completion, but on my remote web host (webpipe.net) those keys don't work. What do I need to do to get these features working on my remote web host? I've seen reference to .psqlrc in the psql man file, but not much else (no syntax, etc). Thanks in advance! Joe

Re: [SQL] psql question

2000-11-23 Thread Joe Conway
meantime I found my own work-around -- I copied local copies of psql and libpq up to my account on the web host. Then I put my own account folder to the front of the PATH and added a LD_LIBRARY_PATH. Now when I run 'psql' it works just like on my own machine! Thanks again for the response. Joe

Re: [PHP] Re: [PHP-DB] Re: [SQL] a script that queries database periodically

2000-11-27 Thread Joe Stump
> Because PHP is supposed to solve web development problems. And this is > one of them. It's very useful. Why solve one that is already solved? PHP isn't here to reinvent the wheel - get crontab and quit crying. --Joe > > -Roberto &g

[SQL] Fw: Optimization recommendations request

2000-12-23 Thread Joe Conway
large tables (>10M tuples). Thanks, Joe > Hello, > > I'm working on an application where I need to design for one table to grow > to an extremely large size. I'm already planning to partition the data into > multiple tables, and even possibly multiple servers, but e

[SQL] Optimization recommendations request

2000-12-29 Thread Joe Conway
; -- then tried create index foo_idx1 on foo using HASH (guid); SELECT ks FROM foo WHERE guid = 'f9ee1930f4010ba34cc5ca6efd27d988eb4f921d'; The query currently takes in excess of 40 seconds. I would appreciate any suggestions for optimizing to bring this down substantially. Thanks in advance, Joe Conway

Re: [SQL] Optimization recommendations request

2000-12-29 Thread Joe Conway
hit rate. I also repeated my test with 15 million records with similar results. Not bad at all! I am still interested in any generic optimization tips for very large tables. Thanks for taking the time to reply! Joe

[SQL] single byte unsigned integer datatype

2001-01-14 Thread Joe Conway
Hello, I was looking for a datatype to represent a single byte unsigned integer. The closest thing I can find looking through the online manual is a one byte char. Are there any side-effects of using a char datatype for this purpose? Is there a better datatype to use? Thanks in advance, Joe

[SQL] current host and dbname info

2001-01-27 Thread Joe Conway
d populate some sort of identification table. Thanks, Joe

[SQL] Fw: C function for use from PLpgSQL trigger

2001-02-03 Thread Joe Conway
xtend PLpgSQL using C functions like this. Anyway, any help or advice will be much appreciated! Thanks, Joe > Hi, > > I'm trying to create a C function that I can call from within a PLpgSQL > trigger function which will return a list of all the values in the NEW > record formatt

Re: [SQL] RE: C function for use from PLpgSQL trigger

2001-02-06 Thread Joe Conway
ll probably just write all of my logic into a C function and skip PLpgSQL entirely. That's too bad because it would be far simpler (and preferrable IMHO) to write a generic trigger function in PLpgSQL and call C functions for only certain operations that PLpgSQL does not directly support. Joe

Re: [SQL] Oracle to PostgreSQL help: What is (+) in Oracle select?

2001-03-16 Thread Joe Conway
eSQL? Hi Chris, The (+) in Oracle is for an outer join. See http://www.postgresql.org/devel-corner/docs/postgres/sql-select.html , in the join-type description, left outer join. Outer joins are only available in PostgreSQL 7.1, which is currently in the late stages of beta testing.

Re: [SQL] Help

2001-03-25 Thread Joe Conway
$HOME/bin/monthend.sh) might look like: #!/bin/sh psql -U postgres mydatabasename < $HOME/bin/monthend.sql then run (see "man 5 crontab" for more on cron) crontab -e and add an entry like # run at 2:15 AM on the 30th of every month 15 2 30 * * $HO

Re: [SQL] Help

2001-03-26 Thread Joe Conway
ico filename.) Please tell me some > description how to save the file in cron and to achive > this. I will be thankful to you. > Instead of "ctrl+z", press ":wq" (colon for command mode, w for write, q for quit). This assumes that vi is your default edit

Re: [SQL] Problems handling errors in PL/pgSQL

2001-04-23 Thread Joe Conway
other results status" at http://postgresql.readysetnet.com/users-lounge/docs/7.1/postgres/plpgsql-des cription.html. Hope this helps, Joe ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://www.postgresql.org/search.mpl

Re: [SQL] How can we match a condition among 2 diff. tables?

2001-07-13 Thread Joe Conway
need to accompolish in a single query! This should work: select e.emp_id from employee as e left join salesorder as s on e.emp_id = s.emp_id where s.emp_id is null; -- Joe ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html

Re: [SQL] Big table - using wrong index - why?

2001-07-30 Thread Joe Conway
Type > ---+-- > entity| character varying(3) > loaddate | date > loadtime | time > btree Just a guess, but what happens if you build i_pl_pseq(pseq, entity), i.e. reverse the key fields? Also, has the table been vacuum analyzed? -- Joe ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] Fuzzy matching?

2001-07-31 Thread Joe Conway
d be fairly easy to port to a Postgres C function. The algorithm itself comes from Donald Knuth in "The Art Of Computer Programming, vol. 3: Sorting And Searching", Addison-Wesley (1973), pp. 391-392. HTH, -- Joe ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html

Re: [SQL] Fuzzy matching?

2001-07-31 Thread Joe Conway
r English words) than soundex, and levenshtein offers an entirely different and interesting approach. Any interest in having all three of these in the backend? -- Joe ---(end of broadcast)--- TIP 2: you can get off all lists at once wit

Re: [SQL] Fuzzy matching?

2001-07-31 Thread Joe Conway
ot sure if that's soon enough to make it into 7.2. Should it be a contrib, or in the backend? -- Joe ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html

Re: [SQL] Outer Join Syntax

2001-08-01 Thread Joe Conway
Postgres dosen't seem to support. I am confused on how > to replicate the behavior however. We often link together many tables via See http://www.postgresql.org/idocs/index.php?queries.html You also might want to take a look at http://www.postgresql.org/idocs/index.php?explici

Re: [SQL] Name Alike Challenge

2001-08-07 Thread Joe Conway
> The "Name Alike" PL/pgSQL function has been posted on Roberto Mello's > cookbook: > > http://www.brasileiro.net/postgres/cookbook/view-one-recipe.adp?recipe_id=96 7 > > This function requires Joe Conway's port of the Metaphone and > Levenshtein functio

Re: [SQL]

2001-09-03 Thread Joe Conway
tmt in one command). If anyone has any answers, or > workarounds pls do email me Well, that syntax doesn't work on SQL Server either. I think what you want is: insert into table1(field1,field2) select field1, field2 from table2; HTH, -- Joe

Re: [SQL] Auto Increment

2001-10-24 Thread Joe Barrero
create table mytable ( myfield serial primary key, myotherfield integer); Using the SERIAL data type automatically creates the sequence and default statements for you. -Original Message- From: Mayuresh Kadu [mailto:[EMAIL PROTECTED]] Sent: Monday, October 22, 2001 2:36 AM To: [EMAIL PROT

Re: [SQL] How to use BYTEA type?

2001-11-01 Thread Joe Conway
mple: $sql = "select image from fax_info "; $sql .= "where serial = 1"; $rs = pg_exec($conn, $sql); $image = stripcslashes(pg_result($rs,0,0)); header("content-type: image/jpeg"); echo $image; Hope this helps, Joe ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly

Re: [SQL] Search by longitude/latitude

2001-10-08 Thread Joe Conway
lpgsql function that will do what you need. You might also look at the earthdistance code in contrib if you'd rather have a C function. HTH, Joe geodist.sql Description: Binary data ---(end of broadcast)--- TIP 2: you can get off all list

Re: [SQL] ROUND function ??

2001-10-08 Thread Joe Conway
orm dependent?). I do recall at least one interpretation of rounding that calls for rounding a 5 to the even digit (ASTM), so the rint behavior may not be strictly speaking a bug -- but certainly having two different interpretations is. In any case, use "select round(2.5,0)" for now.

Re: [SQL] Please help me out on this insert error

2002-06-13 Thread Joe Conway
^^^ From the error message, looks like you spelled haveChildren wrong. HTH, Joe ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

Re: [SQL] SQL Challenge: Skip Weekends

2002-06-20 Thread Joe Conway
uture_work_date end from ( select $1 + (($2 / 5)::text || '' weeks'') + (($2 % 5)::text || '' days'') as future_work_date ) as t1 ' language sql; CREATE testslv=# select get_future_work_day('2002

Re: [SQL] Returning rows from functions

2002-07-10 Thread Joe Conway
elp? The short answer is "yes, but..."; see the thread at: http://archives.postgresql.org/pgsql-interfaces/2002-06/msg00042.php for a recent discussion about this. HTH, Joe ---(end of broadcast)--- TIP 2: you can get off all lists at

Re: [SQL] contrib/dblink suggestion

2002-07-30 Thread Joe Conway
reported something like 500 million records transferred without error. I use it myself, but not in what I'd call heavy use. If you are aware of any specific problems, please point me to them, and I'll fix them before the next release. Thanks, Joe ---(end of br

Re: [SQL] VACUUM not doing its job?

2002-08-03 Thread Joe Conway
lar, see: http://archives.postgresql.org/pgsql-general/2002-07/msg00972.php HTH, Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] VACUUM not doing its job?

2002-08-03 Thread Joe Conway
as the tuples are actually freed, I believe. After that you can adjust 'max_fsm_pages' and your vacuum frequency to achieve an equilibrium. Joe ---(end of broadcast)--- TIP 2: you can get off all lists at once with the unregister comman

Re: [SQL] Hardware performance for large updates

2002-09-05 Thread Joe Conway
u on a Linux server -- if so I found that fdatasync works better than (the default) fsync for wal_sync_method. HTH, Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Hardware performance for large updates

2002-09-06 Thread Joe Conway
d that >>fdatasync works better than (the default) fsync for wal_sync_method. > > Yes, I am. Any particular reason why fdatasync works better? I can't remember the technical reason (although I've seen one on the list before), but I have determined it empirically true,

Re: [SQL] writing a function to mimic mysql last_insert_id

2002-09-11 Thread Joe Conway
and then wrap a last_insert_id() (or whatever it is called) function around a call to currval('my_global_seq'). HTH, Joe ---(end of broadcast)--- TIP 5: Have you checked our extensive FAQ? http://www.postgresql.org/users-lounge/docs/faq.html

Re: [SQL] [GENERAL] Latitude / Longitude

2002-09-12 Thread Joe Conway
at1d,$lon1d,lat,long) <= $dist and z.zip = az.zipcode ORDER BY LIMIT $numtoshow; "; return $sql; } The "X * 60 * 1.15078" converts differences in degrees lat/long into rough distances in miles. The zipdist function returns

Re: [SQL] function return multiply rows

2002-09-27 Thread Joe Conway
themselves. Version 7.3, in beta testing now, will do what you are looking for. If you can, please give it a try. See: http://developer.postgresql.org/docs/postgres/xfunc-tablefunctions.html for more info and examples. HTH, Joe ---(end of broadcas

Re: [SQL] split function for pl/pgsql

2002-10-02 Thread Joe Conway
nt array in pl/pgsql returned by the pl/perl > function ? I don't know if it is possible to construct a PostgreSQL array in pl/perl, but I would imagine that should work. Any pl/perl users out there? Joe ---(end of broadcast)--- TIP 1: sub

Re: [SQL] Stored Procedures

2002-10-02 Thread Joe Conway
oid int, foosubid int, fooname text); CREATE test=# INSERT INTO foo VALUES(1,1,'Joe'); INSERT 304822 1 test=# CREATE FUNCTION getfoo(int) RETURNS foo AS ' test'# SELECT * FROM foo WHERE fooid = $1; test'# ' LANGUAGE SQL; CREATE test=# select fooid(getfoo(1)), f

Re: [SQL] split function for pl/pgsql

2002-10-02 Thread Joe Conway
'"''; ELSE result := result || ''"'' || word || ''"''; END IF; END LOOP; result := result || ''}''; result_arr := result; RETURN result_arr; END ' LANGUAGE '

Re: [SQL] Stored Procedures

2002-10-02 Thread Joe Conway
search_path='s1','$user','public'; SET select current_schema(); current_schema s1 (1 row) -- create the table CREATE TABLE foo (fooid int, foosubid int, fooname text); CREATE TABLE INSERT INTO foo VALUES(1,1,'Joe'); INSERT 794076 1 -- change

Re: [SQL] rows in order

2002-10-04 Thread Joe Conway
row5 | row2 | 1 | row2~row5 row9 | row5 | 2 | row2~row5~row9 (6 rows) This allows completely dynamically generated trees. There is also a contrib/ltree, which I believe creates a persistent structure for the tree information, and gives you tools to manipulate it (but I have never used it, so my discription may not be completely accurate). HTH, Joe ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Suggestion: md5/crypt functions in sql

2002-10-06 Thread Joe Conway
Aasmund Midttun Godal wrote: > It would be very usefull to have these in sql, so that it is even easier to create >tables with encrypted passwords. > See contrib/pgcrypto Joe ---(end of broadcast)--- TIP 6: Have you searched

Re: [SQL] Get A Tree from a table

2002-10-07 Thread Joe Conway
| 1 | A1~B3 B4 | A1 | 1 | A1~B4 (8 rows) test=# SELECT * FROM connectby('nodes','childid','parentid','B1',0,'~') AS t(childid varchar, parentid varchar, level int, branch text); childid | parentid | level | branch -+--+---+-- B1 | | 0 | B1 C1 | B1 | 1 | B1~C1 D1 | C1 | 2 | B1~C1~D1 C2 | B1 | 1 | B1~C2 C5 | B1 | 1 | B1~C5 (5 rows) HTH, Joe ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

  1   2   3   >