473,385 Members | 1,445 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,385 software developers and data experts.

no records returned


running - (PostgreSQL) 7.1.3

I have loaded a table with stock market data.

-
-
-
ZRAN |2003-09-29| 20030929| 731487| 20.81| 20.
ZRAN |2003-09-30| 20030930| 731488| 19.43| 20.1
ZRAN |2003-10-01| 20031001| 731489| 19.82| 19.9
ZRAN |2003-10-02| 20031002| 731490| 19.56| 20.3
ZRAN |2003-10-03| 20031003| 731491| 20.25| 21.
(609398 rows)

pma=> select count(*) from stck_dta_tbl_oprtnl;
count
------
609398

When I do a select * from stck_dta_tbl_oprtnl; I get the whole table
just fine; but when I try and retrieve just 1 record which is out
put when doing the select * ie:

pma=> select * from stck_dta_tbl_oprtnl where stck_sym = 'ZRAN';
stck_sym|dta_date|dta_date_num|dta_date_dys|opn|hi |lw|cls|vol|unk
--------+--------+------------+------------+---+--+--+---+---+---
(0 rows)

I get 0 rows, and no errors from postmaster.

Is there a limit to the number of rows in a table?
I have also tried building a unique index composed of the stck_sym and
dta_date but I still get 0 rows.

I have also noticed that when setting up a cursor that the first fetch
does NOT get the first record in the table, it also returns nothing with
no errors from the postmaster. I am wondering if these bugs are related.

Thanks all for your help!!!!

Lynn

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #1
8 1536
On Fri, Oct 24, 2003 at 04:27:16PM -0700, Ly********@asu.edu wrote:
....
ZRAN |2003-10-03| 20031003| 731491| 20.25| 21.
(609398 rows) pma=> select * from stck_dta_tbl_oprtnl where stck_sym = 'ZRAN';


How about

pma=> select * from stck_dta_tbl_oprtnl where stck_sym like 'ZRAN%';

? (What is the definition of your table?)

Cheers,

Patrick

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 12 '05 #2
is it possible that there are spaces on the end? what type is
stck_sym? if it's varchar or text the padding won't be removed
automatically.

example:

basement=# create table test (t varchar(6));
CREATE TABLE
basement=# INSERT into test values( 'ZRAN ');
INSERT 92249850 1
basement=# select * from test where t = 'ZRAN';
t
---
(0 rows)

basement=#
On Oct 24, 2003, at 5:27 PM, Ly********@asu.edu wrote:

running - (PostgreSQL) 7.1.3

I have loaded a table with stock market data.

-
-
-
ZRAN |2003-09-29| 20030929| 731487| 20.81| 20.
ZRAN |2003-09-30| 20030930| 731488| 19.43| 20.1
ZRAN |2003-10-01| 20031001| 731489| 19.82| 19.9
ZRAN |2003-10-02| 20031002| 731490| 19.56| 20.3
ZRAN |2003-10-03| 20031003| 731491| 20.25| 21.
(609398 rows)

pma=> select count(*) from stck_dta_tbl_oprtnl;
count
------
609398

When I do a select * from stck_dta_tbl_oprtnl; I get the whole table
just fine; but when I try and retrieve just 1 record which is out
put when doing the select * ie:

pma=> select * from stck_dta_tbl_oprtnl where stck_sym = 'ZRAN';
stck_sym|dta_date|dta_date_num|dta_date_dys|opn|hi |lw|cls|vol|unk
--------+--------+------------+------------+---+--+--+---+---+---
(0 rows)

I get 0 rows, and no errors from postmaster.

Is there a limit to the number of rows in a table?
I have also tried building a unique index composed of the stck_sym and
dta_date but I still get 0 rows.

I have also noticed that when setting up a cursor that the first fetch
does NOT get the first record in the table, it also returns nothing
with
no errors from the postmaster. I am wondering if these bugs are
related.

Thanks all for your help!!!!

Lynn

---------------------------(end of
broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to ma*******@postgresql.org so that your
message can get through to the mailing list cleanly

Nov 12 '05 #3
Are the fields you are usiong varchar or char.

If they are char fields they will be getting padded if you do not have the
exact amount in the field. i.e.

char(5)

da will be padded da and 0s on the end up to the sizeof the char field.

If varchar then you will be ok.

If you do have a char then use the trim function to do the selects

HTH
Darren

On Fri, 24 Oct 2003 Ly********@asu.edu wrote:

running - (PostgreSQL) 7.1.3

I have loaded a table with stock market data.

-
-
-
ZRAN |2003-09-29| 20030929| 731487| 20.81| 20.
ZRAN |2003-09-30| 20030930| 731488| 19.43| 20.1
ZRAN |2003-10-01| 20031001| 731489| 19.82| 19.9
ZRAN |2003-10-02| 20031002| 731490| 19.56| 20.3
ZRAN |2003-10-03| 20031003| 731491| 20.25| 21.
(609398 rows)

pma=> select count(*) from stck_dta_tbl_oprtnl;
count
------
609398

When I do a select * from stck_dta_tbl_oprtnl; I get the whole table
just fine; but when I try and retrieve just 1 record which is out
put when doing the select * ie:

pma=> select * from stck_dta_tbl_oprtnl where stck_sym = 'ZRAN';
stck_sym|dta_date|dta_date_num|dta_date_dys|opn|hi |lw|cls|vol|unk
--------+--------+------------+------------+---+--+--+---+---+---
(0 rows)

I get 0 rows, and no errors from postmaster.

Is there a limit to the number of rows in a table?
I have also tried building a unique index composed of the stck_sym and
dta_date but I still get 0 rows.

I have also noticed that when setting up a cursor that the first fetch
does NOT get the first record in the table, it also returns nothing with
no errors from the postmaster. I am wondering if these bugs are related.

Thanks all for your help!!!!

Lynn

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


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

Nov 12 '05 #4
On Sat, Oct 25, 2003 at 08:19:49PM -0700, Ly********@asu.edu wrote:
....
Could you explain to a newbie WHY the like and % at
the end of the literal works when the normal select does
not?

ZRAN |2003-10-03| 20031003| 731491| 20.25| 21.

12345678

From that row, it looks as though your table definition says the first
column is a CHAR(8), rather than say varchar(8) or text. This means that
ZRAN is padded to 8 characters with spaces:

test=# create table zran (a char(8), b varchar(8), c text);
CREATE TABLE
test=# insert into zran values ('ZRAN','ZRAN','ZRAN');
INSERT 28334686 1
test=# select * from zran;
a | b | c
----------+------+------
ZRAN | ZRAN | ZRAN
(1 row)

test=# select * from zran where a='ZRAN ';
a | b | c
----------+------+------
ZRAN | ZRAN | ZRAN
(1 row)

Because we were guessing your table definition, we couldn't just add 4 spaces
after ZRAN, so we suggested "where a like 'ZRAN%'". LIKE understands % to
mean "0 or more anything", so it would match 'ZRANNN' too, which might not
be what you want.. Most sensible might be to change your table definition..

Cheers,

Patrick

---------------------------(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 12 '05 #5

Darren,

Thanks for the thoughts...

stck_sym is a varchar the rest are int's and floats's.

Do you think that the size of the table could be part of the problem,
at 600000+ records?

Lynn
exact amount in the field. i.e.

char(5)

da will be padded da and 0s on the end up to the sizeof the char
field.

If varchar then you will be ok.

If you do have a char then use the trim function to do the selects

HTH
Darren

On Fri, 24 Oct 2003 Ly********@asu.edu wrote:

running - (PostgreSQL) 7.1.3

I have loaded a table with stock market data.

-
-
-
ZRAN |2003-09-29| 20030929| 731487| 20.81| 20.
ZRAN |2003-09-30| 20030930| 731488| 19.43| 20.1
ZRAN |2003-10-01| 20031001| 731489| 19.82| 19.9
ZRAN |2003-10-02| 20031002| 731490| 19.56| 20.3
ZRAN |2003-10-03| 20031003| 731491| 20.25| 21.
(609398 rows)

pma=> select count(*) from stck_dta_tbl_oprtnl;
count
------
609398

When I do a select * from stck_dta_tbl_oprtnl; I get the whole table
just fine; but when I try and retrieve just 1 record which is out
put when doing the select * ie:

pma=> select * from stck_dta_tbl_oprtnl where stck_sym = 'ZRAN';
stck_sym|dta_date|dta_date_num|dta_date_dys|opn|hi |lw|cls|vol|unk
--------+--------+------------+------------+---+--+--+---+---+---
(0 rows)

I get 0 rows, and no errors from postmaster.

Is there a limit to the number of rows in a table?
I have also tried building a unique index composed of the stck_sym

and
dta_date but I still get 0 rows.

I have also noticed that when setting up a cursor that the first

fetch
does NOT get the first record in the table, it also returns nothing

with
no errors from the postmaster. I am wondering if these bugs are

related.

Thanks all for your help!!!!

Lynn

---------------------------(end of

broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


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

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

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

Nov 12 '05 #6

Hi All,

Solved this problem with a tip from
James Moe <ji***@sohnen-moe.com> as follows:

Try this:

select * from stck_dta_tbl_oprtnl where stck_sym like 'ZRAN%';

It works PERFECTLY....

THANKS James!!!

Lynn

Quoting Brian Hirt <bh***@mobygames.com>:
is it possible that there are spaces on the end? what type is
stck_sym? if it's varchar or text the padding won't be removed
automatically.

example:

basement=# create table test (t varchar(6));
CREATE TABLE
basement=# INSERT into test values( 'ZRAN ');
INSERT 92249850 1
basement=# select * from test where t = 'ZRAN';
t
---
(0 rows)

basement=#
On Oct 24, 2003, at 5:27 PM, Ly********@asu.edu wrote:

running - (PostgreSQL) 7.1.3

I have loaded a table with stock market data.

-
-
-
ZRAN |2003-09-29| 20030929| 731487| 20.81| 20.
ZRAN |2003-09-30| 20030930| 731488| 19.43| 20.1
ZRAN |2003-10-01| 20031001| 731489| 19.82| 19.9
ZRAN |2003-10-02| 20031002| 731490| 19.56| 20.3
ZRAN |2003-10-03| 20031003| 731491| 20.25| 21.
(609398 rows)

pma=> select count(*) from stck_dta_tbl_oprtnl;
count
------
609398

When I do a select * from stck_dta_tbl_oprtnl; I get the whole table
just fine; but when I try and retrieve just 1 record which is out
put when doing the select * ie:

pma=> select * from stck_dta_tbl_oprtnl where stck_sym = 'ZRAN';
stck_sym|dta_date|dta_date_num|dta_date_dys|opn|hi |lw|cls|vol|unk
--------+--------+------------+------------+---+--+--+---+---+---
(0 rows)

I get 0 rows, and no errors from postmaster.

Is there a limit to the number of rows in a table?
I have also tried building a unique index composed of the stck_sym

and
dta_date but I still get 0 rows.

I have also noticed that when setting up a cursor that the first

fetch
does NOT get the first record in the table, it also returns nothing
with
no errors from the postmaster. I am wondering if these bugs are
related.

Thanks all for your help!!!!

Lynn

---------------------------(end of
broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


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

Nov 12 '05 #7

Patrick,

James Moe <ji***@sohnen-moe.com>
also suggested this...

It WORKS!!!

Could you explain to a newbie WHY the like and % at
the end of the literal works when the normal select does
not?

Thanks,
Lynn

Quoting Patrick Welche <pr***@newn.cam.ac.uk>:
On Fri, Oct 24, 2003 at 04:27:16PM -0700, Ly********@asu.edu wrote:
...
ZRAN |2003-10-03| 20031003| 731491| 20.25| 21.
(609398 rows)

pma=> select * from stck_dta_tbl_oprtnl where stck_sym = 'ZRAN';


How about

pma=> select * from stck_dta_tbl_oprtnl where stck_sym like 'ZRAN%';

? (What is the definition of your table?)

Cheers,

Patrick

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

Nov 12 '05 #8
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sat, 25 Oct 2003 20:19:49 -0700 (MST), Ly********@asu.edu wrote:
Could you explain to a newbie WHY the like and % at
the end of the literal works when the normal select does
not?

The "%" is a wildcard character in SQL, the same as "*" in many file systems. It
matches 0 or more characters. Also "_" matches any single character, similar to
"?", or "." in regular expressions.
There is likely one or more spaces after the visible characters. Using a "%"
after ZRAN matches ZRAN plus anything else following that pattern.
The implementation of the LIKE operator is a somewhat uneven in my experience.
Depending on the database it can only be used to match strings, or to do a
case-insensitive compare, or is equivalent to "=" with "=" extended to string
operations. In most cases, though, the best practice is to use it for strings
especially when using regular expressions like "%"; and to use "=" for numeric and
exact matching.
- --
jimoe at sohnen-moe dot com
pgp/gpg public key: http://www.keyserver.net/en/
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0 OS/2 for non-commercial use
Comment: PGP 5.0 for OS/2
Charset: cp850

wj8DBQE/nE7isxxMki0foKoRAkJjAJ9lpqeC8y+Go0tXclwIM8XzvaRd1Q Cgtn8i
26WzEwf8HNPY5iqY6ZckrmY=
=DY5x
-----END PGP SIGNATURE-----

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Nov 12 '05 #9

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

Similar topics

4
by: Keith Griffiths | last post by:
I'm trying to do a search under a set criteria followed by a selection of random entries meeting this criteria. But I don't seem to be able to achieve this. The idea being to search on say...
20
by: Guru | last post by:
Hi I have a table which contains number of rows. I want to fetch the last 5 records from the table. I know for the first 'n' records we can use FETCH FIRST n ROWS ONLY command. But i want to...
13
by: Jan | last post by:
Hi I have a database that I use to keep track of the sales promotions that we send to companies. I normally send a mailing based on a subset of the companies in the database (found using the...
3
by: deko | last post by:
Is there any way to limit the number of records loaded into a ListBox? I looked at qdf.MaxRecords (to apply to the query that is the RowSource of the ListBox) but that only applies to ODBC data...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
2
by: willwmagic | last post by:
Hi everyone, I feel as this is a very simple question, but I cannot find any information pertaining to it. I want to be able to update a set of records that were returned through a select...
1
by: dfw1417 | last post by:
I have used a query and report filter to return records related to a specific account id. I want to print a report including only the latest 6 records out of the set returned by the record filter. I...
12
by: binky | last post by:
Quick question that I can't find a solution to: I have an ADP application that uses SQL Server 2000 backend, along with stored procedures that populate my forms. I do not want to use subforms for...
3
by: bmyers404 | last post by:
I need to update values in a table for a subset of rows returned from a select statement. The select statement may return any number of records. I'll use 15 in this example. I want to update the...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.