473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Invalid input for integer on VIEW

I have the following view definition

Column | Type | Modifiers
----------------+-----------------------+-----------
bcode | character varying(15) |
subhead | text |
sc_description | character varying(60) |
Budget | numeric |
expenditure | numeric |
balance | numeric |
head | integer |
period | integer |
View definition:
SELECT
CASE
WHEN vw_rec_sum.code IS NULL AND vw_pay_sum.sum IS NOT NULL
THEN vw_pay_sum.code
ELSE vw_rec_sum.code
END AS bcode,
CASE
WHEN "left"(ac_code::text, 2) = 'SA'::text THEN 'Salary
Costs'::text
WHEN "left"(ac_code::text, 2) = 'SC'::text THEN 'Startup
Costs'::text
WHEN "left"(ac_code::text, 2) = 'RC'::text THEN 'Running
Costs'::text
WHEN "left"(ac_code::text, 2) = 'TC'::text THEN 'Training
Costs'::text
ELSE NULL::text
END AS subhead, sc_description, vw_rec_sum.sum AS "Budget",
vw_pay_sum.sum AS expenditure,
CASE
WHEN vw_pay_sum.sum IS NULL THEN vw_rec_sum.sum
WHEN vw_pay_sum.sum < 0.01 THEN 0.00 - vw_pay_sum.sum +
vw_rec_sum.sum
ELSE vw_rec_sum.sum - vw_pay_sum.sum
END AS balance,
CASE
WHEN "left"(ac_code::text, 2) = 'SA'::text THEN 1
WHEN "left"(ac_code::text, 2) = 'SC'::text THEN 2
WHEN "left"(ac_code::text, 2) = 'RC'::text THEN 3
WHEN "left"(ac_code::text, 2) = 'TC'::text THEN 4
ELSE NULL::integer
END AS head,
CASE
WHEN to_number(vw_rec_sum.code::text, '999'::text) >
194::numeric THEN 3
WHEN to_number(vw_rec_sum.code::text, '999'::text) <
195::numeric AND to_number(vw_rec_sum.code::text, '999'::text) >
50::numeric THEN 2
ELSE 1
END AS period
FROM vw_rec_sum
FULL JOIN vw_pay_sum ON vw_rec_sum.code::text = vw_pay_sum.code::text
JOIN vw_ac ON vw_rec_sum.code::text = vw_ac.id::text
ORDER BY to_number(vw_rec_sum.code::text, '999'::text);
However whenever I try to query it with criteria on the period column I
get SELECT * FROM vw_budget HAVING "period"='3';
ERROR: invalid input syntax for type numeric: " "

If I try on the head column the query runs

Getting stumped - anyone any idea what is going on here.

This is with 7.4.3

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org

Nov 23 '05 #1
3 2957
On Tue, 2004-08-24 at 15:42 +0100, mike wrote:
I have the following view definition

Column | Type | Modifiers
----------------+-----------------------+-----------
bcode | character varying(15) |
subhead | text |
sc_description | character varying(60) |
Budget | numeric |
expenditure | numeric |
balance | numeric |
head | integer |
period | integer |
View definition:
SELECT
CASE
WHEN vw_rec_sum.code IS NULL AND vw_pay_sum.sum IS NOT NULL
THEN vw_pay_sum.code
ELSE vw_rec_sum.code
END AS bcode,
CASE
WHEN "left"(ac_code::text, 2) = 'SA'::text THEN 'Salary
Costs'::text
WHEN "left"(ac_code::text, 2) = 'SC'::text THEN 'Startup
Costs'::text
WHEN "left"(ac_code::text, 2) = 'RC'::text THEN 'Running
Costs'::text
WHEN "left"(ac_code::text, 2) = 'TC'::text THEN 'Training
Costs'::text
ELSE NULL::text
END AS subhead, sc_description, vw_rec_sum.sum AS "Budget",
vw_pay_sum.sum AS expenditure,
CASE
WHEN vw_pay_sum.sum IS NULL THEN vw_rec_sum.sum
WHEN vw_pay_sum.sum < 0.01 THEN 0.00 - vw_pay_sum.sum +
vw_rec_sum.sum
ELSE vw_rec_sum.sum - vw_pay_sum.sum
END AS balance,
CASE
WHEN "left"(ac_code::text, 2) = 'SA'::text THEN 1
WHEN "left"(ac_code::text, 2) = 'SC'::text THEN 2
WHEN "left"(ac_code::text, 2) = 'RC'::text THEN 3
WHEN "left"(ac_code::text, 2) = 'TC'::text THEN 4
ELSE NULL::integer
END AS head,
CASE
WHEN to_number(vw_rec_sum.code::text, '999'::text) >
194::numeric THEN 3
WHEN to_number(vw_rec_sum.code::text, '999'::text) <
195::numeric AND to_number(vw_rec_sum.code::text, '999'::text) >
50::numeric THEN 2
ELSE 1
END AS period
FROM vw_rec_sum
FULL JOIN vw_pay_sum ON vw_rec_sum.code::text = vw_pay_sum.code::text
JOIN vw_ac ON vw_rec_sum.code::text = vw_ac.id::text
ORDER BY to_number(vw_rec_sum.code::text, '999'::text);
However whenever I try to query it with criteria on the period column I
get SELECT * FROM vw_budget HAVING "period"='3';
ERROR: invalid input syntax for type numeric: " "

If I try on the head column the query runs

Getting stumped - anyone any idea what is going on here.

This is with 7.4.3

If I do the same query, except to create a new table, everything works,
so is this a view bug?

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Nov 23 '05 #2
mike <mi**@bristolreccc.co.uk> writes:
If I do the same query, except to create a new table, everything works,
so is this a view bug?


Possibly, but you haven't given enough info to let someone else
reproduce the problem. A SQL script that creates all the necessary
tables and the view and then triggers the failure would make it much
easier for us to investigate.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #3
mike <mi**@bristolreccc.co.uk> writes:
On Tue, 2004-08-24 at 12:30 -0400, Tom Lane wrote:
Possibly, but you haven't given enough info to let someone else
reproduce the problem.
Is this OK, or do you want some data as well?


I plugged in the view definition from your original mail and got

regression=# SELECT * FROM vw_budget HAVING "period"='3';
bcode | subhead | sc_description | Budget | expenditure | balance | head | period
-------+---------+----------------+--------+-------------+---------+------+--------
(0 rows)

So either the problem requires data, or there is something wrong with
your left() function, which was not included in the script. I guessed
at

create function left(text, integer) returns text as
'select substr($1,$2)' language sql ;

but I dunno if this is anything like what you are using.

Please actually *test* the script you are submitting, next time, and
verify that it reproduces the problem starting from an empty database.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Nov 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Fran?ois Bourdages | last post by:
Hi is there a way to know if object (view, function, etc) are invalid ? let say a have a table t1 (field col1, col2) and a view v1 (field t1.col1, t1.col2) if I drop t1.col2, the view v1 is not...
3
by: Paul | last post by:
I have an Access 2000 database with a form that is giving me some major headaches. When you open the form, it displays all records and allows editing, but has AllowAdditions set to False so that...
9
by: Mike MacSween | last post by:
So in preparing an export routine to send stuff to the courier company's label printing software (which is surprisingly rough, for a big company), I've discovered a few carriage returns in fields...
2
by: Brad | last post by:
I have an intranet app that has just started sporadically getting the following error "The viewstate is invalid for this page and might be corrupted." By sproadic I mean 3-4 times during the past...
1
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte.". To make clear how do I execute this, below I'm...
2
by: Hope Paka | last post by:
My web page, has an average of 1500 hits every day. Every day, i get invalid view state exception, average of 10 times. The exception message in at the bottom. When i try to parse the view state in...
1
by: Java Guy | last post by:
I'm trying to view a web page. IE tells me there are (Java?) errors on the page. Here they are: Line: 15 Char: 7 Error: Wrong number of arguments or invalid propert assignment Code: 0 URL:...
12
by: JHNielson | last post by:
I have a simple question, but I can't seem to find the answer. I have this code to count the number of records that pass through a set of processes: It counts how many records go through...
3
by: ALKASER266 | last post by:
Hey guyz I am a java beginner and I have problem with part of the code. The thing that I don't know how to do it in this code is how to show the user that he/she has input an invalid input In my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.