[SQL] Re: NULL

2000-10-24 Thread Sandis Jerics

Hello,

how must i write a NULL value in a text file for the \copy command to
understand it?
NULL, \0 doesnt work..

how must i write a boolean value in a text file for the \copy command to
understand it?
t doesnt work, however in a file written by /copy command it looks as
t or f ..

tried to search archives, but it seems deadly slow...

Thanks in advance,
sandis





[SQL] HELP! ... pg_locale ???

2000-10-26 Thread Sandis Jerics

Hello folks,

I got a headache now, cause our admin played with postgres settings,
something about pg_locale, as he says. Perhaps the reason is
elsewhere, i dont know.

As result, now all queries, written inside the php code on multiply lines,
returns the following:

 ERROR: parser: parse error at or near " "
 
The same query, pasted to psql, works well.
The same query written on single line in php code works well.
But i see that my older scripts with multiply line queries works well.

Whats up?! Why?

There is no errors in this code:
--
$result = @pg_exec($db,"
 SET DATESTYLE = 'ISO';
 SELECT DISTINCT
   meznieciba,
   date_part('day',date(datums))   AS dd,
   date_part('month',date(datums)) AS mm,
   date_part('year',date(datums))  AS ,
   galvene,
   kajene
   FROM izsoles
 WHERE datums = '$datums'") or die(pg_errormessage());
--
it works fine when written on the single line
but now i see the above stupid error message..

it so funny to have to rewrite queries to single line?..

--:)-- 
Best regards,
 Sandis





[SQL] sorting the text values as integers

2000-12-20 Thread Sandis Jerics

Hi,

 i have a table with some text fields filled with a data like
 100,23
 235,12
 500
 200
 the same fields somethimes contains the values like
 100x100x25
 125x125x50
 200x80x90
 and so on.

 the client requires that rows are sorted in ascending order

 for the case there are a float values, i do:
 SELECT ... ORDER BY float4(field)

 for the case there a text values, i do:
 SELECT ... ORDER BY int2(substring(field from 1 for position('x' in field)-1));
 so i can sort them ascendingly at least by the first integer (before
 'x' char). otherwise (simply "ORDER BY field") they were sorted as text
 values - 100x100x30, 10x10x10, 400x400x30, 40x40x20, ...
 now it sorted as i need - 10x10x10, 40x40x20, 100x100x30, 400x400x30 ...

 it's almost fine, but...
 now i need to combine that 2 cases, so i try (the field called m1):
 SELECT ... ORDER BY (CASE WHEN position('x' in m1)>1 THEN int2(substring(m1 from 1 
for position('x' in m1)-1)) ELSE float4(m1) END)

 i never used CASE WHEN ... THEN ... ELSE ... END construct before,
 & assume the above is errorneus by default.

 
--:)-- 
Best regards, Sandis





[SQL] i have a big trouble

2001-01-24 Thread Sandis Jerics

Hello list,

 i expirienced that postgres seems doesn't want to eat it's own
 dump... why? even freshly created!
 whats wrong with me?

www_mod_lv=> \copy news from '/home/sites/www.mod.lv/web/news.sql'
\.
ERROR:  copy: line 2, pg_atoi: error in "
At the international humanitarian mission of KFOR the Latvian unit participates with 
10 soldiers from the National Armed Forces. The KFOR Latvian contingent  - Military 
Police and medical units - will operate within the contingent of UK.  "
: can't parse "
At the international humanitarian mission of KFOR the Latvian unit participates with 
10 soldiers from the National Armed Forces. The KFOR Latvian contingent  - Military 
Police and medical units - will operate within the contingent of UK.  "
PQendcopy: resetting connection

i tried to do \copy from stdin, than throw in a one row of data, ended
with \., it doesnt work also.

This is my table:

CREATE TABLE news(
   id SERIAL PRIMARY KEY,
   flag CHAR(1) NOT NULL,
   rubrika CHAR(1) NOT NULL,
   datums_ TIMESTAMP NOT NULL,
   datums  VARCHAR(30) NOT NULL,
   virsraksts VARCHAR(200) NOT NULL,
   teksts  TEXT,
   url VARCHAR(30),
   url_txt VARCHAR(50)
);

an example row of data (tab separated) attached.

anyone may have an idea?

-- 
 Sandis
609
9237502

45  a   2   2000-03-24 17:09:52+02  24.03.2000  ON THE RESULTS OF THE 
VISIT IN BRUSSELS Today on the 24th of March, the Minister of Defence, Mr. Ìirts 
Valdis Kristovskis, and Minister of Foreign Affairs, Mr. Indulis Bçrziòð, participated 
at the meeting of the North Atlantic Council and Latvia, led by the NATO Secretary 
General, Lord George Robertson. The Latvian representatives presented the Progress 
report on what has been accomplished and achieved in implementation of the Membership 
Action Plan (MAP) of Latvia for 2000. 
\
The Minister of Defence, Mr.Ìirts Valdis Kristovskis, in his speech informed 
ambassadors of the NATO member-countries, on what has been accomplished in the defence 
system of Latvia within MAP. Mr. Ì.V.Kristovskis noted, that Latvia's activity  and 
full determination to participate in the process, is aimed at preparing Latvia to be 
ready to accept the invitation to join the North Atlantic Treaty Organisation at the 
next round of enlargement. At the same time Minister of Defence emphasised, that a lot 
still has to be done in improvement of the systems of procurement and military 
education. 
\
During the meeting it was noted that Latvia is one of the best NATO candidate - states 
as concerns the execution of the Membership Action Plan. It was also concluded at the 
session, that Membership Action Plan of Latvia for 2000 is well prepared, realistic, 
and financially well founded. The ambassadors of NATO member countries, acknowledged 
that Latvia has a systemic and purposeful approach in solving state defence related 
issues.  
\
Ambassadors of the NATO members states also positively evaluated Latvia's readiness to 
contribute to European security, more precisely - to participate by providing officers 
of the Latvian National Armed Forces for peace-keeping and peace - support missions in 
Bosnia - Hercegovina and Kosovo, as well as noting the close co-operation among the 
Baltic States themselves. 
\
Participants at the session also discussed the need for Latvia to enlarge her defence 
budget to 2% of the GDP, which is the average level of NATO countries. To this the 
Latvian representatives responded that the Government of Latvia has expressed the 
political will increasing state defence expenditures. Today at the session in 
Brussels, both the Minister of Defence, Ì.V.Kristovskis, and Minister of Foreign 
Affairs, once more stressed Latvia's strong determination to continue the initiated 
process of preparation for joining NATO.