472,330 Members | 1,302 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,330 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 1492
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...
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...
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...
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...
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...
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...
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...
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...
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. ...
0
by: tammygombez | last post by:
Hey everyone! I've been researching gaming laptops lately, and I must say, they can get pretty expensive. However, I've come across some great...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...

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.