Re: [SQL] Domains, casts, and MS Access

2010-08-04 Thread Justin Graf
On 8/4/2010 1:56 PM, Richard Broersma wrote: On Wed, Aug 4, 2010 at 11:51 AM, Peter Koczanpjkoc...@gmail.com wrote: This is one of my first forays into ODBC, so I didn't know that was a possibility. Is there any place where these are documented? Searching for ODBC options yields info on

Re: [SQL] how to escape _ in select

2010-07-28 Thread Justin Graf
On 7/28/2010 12:35 PM, Wes James wrote: I'm trying to do this: select * from table where field::text ilike '%\_%'; but it doesn't work. How do you escape the _ and $ chars? The docs say to use \, but that isn't working. ( http://www.postgresql.org/docs/8.3/static/functions-matching.html

Re: [SQL] strangest thing happened

2010-07-08 Thread Justin Graf
On 7/7/2010 5:41 PM, John wrote: On Wednesday 07 July 2010 03:14:40 pm Justin Graf wrote: I would be looking at the log files for the Inserts into that table as a means to track down what is the cause. If there are no log files or don't have enough detail, crank up the logging level

Re: [SQL]

2010-07-07 Thread Justin Graf
On 7/7/2010 12:00 AM, silly sad wrote: On 07/06/10 21:52, Justin Graf wrote: I wrote an article covering this on the wiki http://wiki.postgresql.org/wiki/BinaryFilesInDB there are some red flags in communication (particularly reading papers) one of them is binary data which

Re: [SQL] strangest thing happened

2010-07-07 Thread Justin Graf
On 7/7/2010 3:42 PM, Ross J. Reedstrom wrote: Justin, you're missing that John reported that the sequences are _behind_ the table. This only happens for me if I've been doing bulk data loads. Then I use: select setval(sequence_name,max(serial_id_column)) from table_with_serial_id; You do

Re: [SQL]

2010-07-06 Thread Justin Graf
I wrote an article covering this on the wiki http://wiki.postgresql.org/wiki/BinaryFilesInDB I need to update to for 9.0 as bytea now allows HEX format strings http://developer.postgresql.org/pgdocs/postgres/datatype-binary.html All legitimate Magwerks Corporation quotations are sent

Re: [SQL] how to construct sql

2010-06-02 Thread Justin Graf
On 6/2/2010 12:31 PM, Wes James wrote: On Wed, Jun 2, 2010 at 10:55 AM, Oliveiros oliveiros.crist...@marktest.pt wrote: Hi, Have you already tried this out? select MAX(page_count_count) - MIN(page_count_count) from page_count group by page_count_pdate. Best, Oliveiros

Re: [SQL] how to construct sql

2010-06-02 Thread Justin Graf
On 6/2/2010 2:52 PM, Wes James wrote: **snip*** Thx it is closer (with an end in the case): select case when MAX(page_count_count) - MIN(page_count_count) 0 then MAX(page_count_count) - MIN(page_count_count) else MAX(page_count_count) end as day_max from page_count

Re: [SQL] user function and bind

2010-05-19 Thread Justin Graf
On 5/19/2010 9:56 AM, David Harel wrote: Hi, I need an example how to write user function with columns binding and how to use it on PHP -- Thanks. I'm not sure i understand your question. You want a function to return record type correct?? All legitimate Magwerks

Re: [SQL] best paging strategies for large datasets?

2010-05-13 Thread Justin Graf
On 5/13/2010 4:41 AM, silly sad wrote: First u count(*) the rows and select a requested page returning to a client the count result bundled with a page of rows (1) client renders the acquired rows (2)__memorize__ what part of the data he just got (3) and stores the count result to calculate

Re: [SQL] best paging strategies for large datasets?

2010-05-13 Thread Justin Graf
On 5/13/2010 3:43 AM, Louis-David Mitterrand wrote: **snip*** What do you mean by quite slow?? Like several seconds. I have to cache the results. Well then i suggest posting the queries to Performance or here and let us take a look them don't forget to include the explain/analyze,

Re: [SQL] best paging strategies for large datasets?

2010-05-12 Thread Justin Graf
On 5/12/2010 1:41 AM, Louis-David Mitterrand wrote: Hi, I have a large dataset (page 1 at http://www.cruisefish.net/stat.md) and am in the process of developping a pager to let users leaf through it (30K rows). That's not that big of a record set. Ideally I'd like to know when

Re: [SQL] best paging strategies for large datasets?

2010-05-12 Thread Justin Graf
oops typos On 5/12/2010 1:41 AM, Louis-David Mitterrand wrote: Hi, I have a large dataset (page 1 at http://www.cruisefish.net/stat.md) and am in the process of developping a pager to let users leaf through it (30K rows). That's not that big of a record set. Ideally I'd like to know when

Re: [SQL] Celko take on EAV

2010-05-07 Thread Justin Graf
On 5/7/2010 12:33 PM, Richard Broersma wrote: This question isn't a flame bait for the merits of the EAV. I'm rereading my Joe Celko's SQL Programming Style and I noticed an interesting comment regarding the EAV model (of course he discourages its use): There are better tools for collecting

Re: [SQL] Column Specific Update Trigger Routine

2010-05-06 Thread Justin Graf
On 5/6/2010 4:12 PM, Plugge, Joe R. wrote: I am trying to create a update trigger on a table that basically will only fire when a specific column is updated. I am using version 8.4.3. My plan of attack was to always fire on any row update, and pass in the OLD and NEW column that I want to

Re: [SPAM]-D] [SQL] How to find broken UTF-8 characters ?

2010-04-29 Thread Justin Graf
On 4/28/2010 10:34 PM, Andreas wrote: Hi, while writing the reply below I found it sounds like beeing OT but it's actually not. I just need a way to check if a collumn contains values that CAN NOT be converted from Utf8 to Latin1. I tried: Select convert_to (my_column::text, 'LATIN1')

Re: [SQL] Inserting Multiple Random Rows

2010-04-28 Thread Justin Graf
On 4/28/2010 1:48 PM, Gary Chambers wrote: pen? The clouds parting, choirs of angels singing, and fireworks celebrating the veil of my obtuseness being lifted, and my grasp and command of SQL to be complete and infinite. None of which appears will ever happen... -- Gary Chambers /*

Re: [SQL] MSSQL to PostgreSQL - Issue trying to generate unique ID using actual date

2010-03-18 Thread Justin Graf
On 3/17/2010 9:52 AM, Ignacio Balcarce wrote: Hi all, I am facing a problem trying to convert from MSSQL procedure to PostgreSQL function. CREATE PROCEDURE dbo.THUBAN_SP_GENERATEID @NEWID VARCHAR(20) OUTPUT AS SET @NEWID = ( SELECT

Re: [SQL] MSSQL to PostgreSQL - Issue trying to generate unique ID using actual date

2010-03-18 Thread Justin Graf
On 3/18/2010 12:53 PM, Ignacio Balcarce wrote: Justin, Thanks in advance for your email. I forgot to tell than everyday IDs must start from 0. So… sequence id would look like: MMDD 0001, MMDD 0002, etc. Is there any way to make this sequence start from 0 every day?

Re: [SQL] MSSQL to PostgreSQL - Issue trying to generate unique ID using actual date

2010-03-18 Thread Justin Graf
OOPS did not mean to click send On 3/18/2010 12:53 PM, Ignacio Balcarce wrote: Justin, Thanks in advance for your email. I forgot to tell than everyday IDs must start from 0. So… sequence id would look like: MMDD 0001, MMDD 0002, etc. Is there any way to make this

Re: [SQL] plpgsql loop question

2010-02-10 Thread Justin Graf
On 2/10/2010 11:29 AM, Andrea Visinoni wrote: hi, i have a table called zones: idzone, zone_name and several tables called zonename_records (same structure), where zonename is one of the zone_name in the zones table. What i want to do is a function that union all of this tables dinamically

Re: [SQL] 'image' table with relationships to different objects

2010-02-10 Thread Justin Graf
On 2/9/2010 6:59 AM, Richard Huxton wrote: On 09/02/10 07:49, Louis-David Mitterrand wrote: Hello, In my database I have different object types (person, location, event, etc.) all of which can have several images attached. What is the best way to manage a single 'image' table with