dump_results

dump_results

am 14.04.2006 00:22:19 von Peter.Loo

------_=_NextPart_001_01C65F48.BA9635C0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi,
=20
I am passing the correct arguments to dump_results, but it appears that
the records are not getting separated with new line.
=20
$maxlen =3D 500;
$lsep =3D '\n';
$fsep =3D '|';
$fh =3D \*FH;
=20
$rows =3D $sth->dump_results($maxlen, $lsep, $fsep, $fh);

The records are getting output with the line feed and instead wrapping.
=20
'28526'|'14827160'|'19901'|'4'|'13'\n'28526'|'14827160'|'199 07'|'1'|'2'\
n'28526'|'14827160'|'19940'|'1'|'1'\n'28526'|'14827160'|'199 92'|'4'|'2'\
n'28526'|'14827639'|'20000'|'1'|'8'\n'28526'|'14827639'|'199 92'|'4'|'1'\
n'28526'|'14827639'|'20005'|'2'|'2'\n'28526'|'14827639'|'200 05'|'4'|'6'\
n'28526'|'14828630'|'19901'|'4'|'1'\n'28526'|'14829031'|'200 76'|'2'|'1'\
n'28526'|'14829810'|'20000'|'4'|'2'\n'28526'|'14829810'|'199 42'|'4'|'3'\
n'28526'|'14830631'|'19899'|'4'|'8'\n'28526'|'14830631'|'199 26'|'1'|'3'\
n'28526'|'14830631'|'19971'|'4'|'2'\n'28526'|'14831785'|'199 16'|'4'|'2'\
n'28526'|'14832435'|'19971'|'2'|'1'\n'28526'|'14832435'|'200 05'|'4'|'1'\
n'28526'|'14832551'|'20004'|'4'|'4'\n'28526'|'14832759'|'198 99'|'1'|'3'\
n'28526'|'14832759'|'19972'|'4'|'6'\n'28526'|'14832759'|'200 01'|'4'|'1'\
n'28526'|'14833062'|'19940'|'2'|'3'\n'28526'|'14833062'|'200 03'|'4'|'3'\
n'28526'|'14833087'|'19916'|'2'|'1'\n'28526'|'14833127'|'200 03'|'4'|'4'\
n'28526'|'14833170'|'19926'|'1'|'2'\n'28526'|'14833170'|'199 42'|'4'|'3'\
n'28526'|'14833170'|'19973'|'4'|'3'\n'28526'|'14833170'|'200 75'|'2'|'2'\
n'28526'|'14833188'|'19897'|'4'|'3'\n'28526'|'14833188'|'200 05'|'4'|'1'\
n'28526'|'14833197'|'19926'|'1'
=20
Also, how can I force it so that the output does not have the quotes for
every field?
=20
Thanks.
=20
Peter


This E-mail message is for the sole use of the intended recipient(s) and =
may contain confidential and privileged information. Any unauthorized =
review, use, disclosure or distribution is prohibited. If you are not =
the intended recipient, please contact the sender by reply E-mail, and =
destroy all copies of the original message.

------_=_NextPart_001_01C65F48.BA9635C0--

RE: dump_results

am 14.04.2006 15:50:50 von rjk-dbi

Loo, Peter # PHX [mailto:Peter.Loo@source.wolterskluwer.com]:

> I am passing the correct arguments to dump_results, but it appears that
> the records are not getting separated with new line.
>
> $maxlen = 500;
> $lsep = '\n';
> $fsep = '|';
> $fh = \*FH;
>
> $rows = $sth->dump_results($maxlen, $lsep, $fsep, $fh);

Single quoted strings do not do backslash substitution (except for \\ and
\'). You meant $lsep = "\n";


> Also, how can I force it so that the output does not have the quotes for
> every field?

DBI::neat() won't quote the value if it knows it's a number. Unfortunately,
I'm not sure how to let it know it's a number in this case. Sorry.


Ronald

RE: dump_results

am 14.04.2006 18:04:50 von Peter.Loo

Thanks Ronald.
=20
Peter Loo
Wolters Kluwer Health
(602) 381-9553

-----Original Message-----
From: Ronald J Kimball [mailto:rjk-dbi@focalex.com]=20
Sent: Friday, April 14, 2006 6:51 AM
To: Loo, Peter # PHX; dbi-users@perl.org
Subject: RE: dump_results

Loo, Peter # PHX [mailto:Peter.Loo@source.wolterskluwer.com]:

> I am passing the correct arguments to dump_results, but it appears=20
> that the records are not getting separated with new line.
>=20
> $maxlen =3D 500;
> $lsep =3D '\n';
> $fsep =3D '|';
> $fh =3D \*FH;
>=20
> $rows =3D $sth->dump_results($maxlen, $lsep, $fsep, $fh);

Single quoted strings do not do backslash substitution (except for \\
and \'). You meant $lsep =3D "\n";


> Also, how can I force it so that the output does not have the quotes=20
> for every field?

DBI::neat() won't quote the value if it knows it's a number.
Unfortunately, I'm not sure how to let it know it's a number in this
case. Sorry.


Ronald




This E-mail message is for the sole use of the intended recipient(s) and
may contain confidential and privileged information. Any unauthorized
review, use, disclosure or distribution is prohibited. If you are not
the intended recipient, please contact the sender by reply E-mail, and
destroy all copies of the original message.


This E-mail message is for the sole use of the intended recipient(s) and =
may contain confidential and privileged information. Any unauthorized =
review, use, disclosure or distribution is prohibited. If you are not =
the intended recipient, please contact the sender by reply E-mail, and =
destroy all copies of the original message.

Re: dump_results

am 15.04.2006 04:03:36 von jseger

------=_Part_3845_43975.1145066616784
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

>
>
>
> Single quoted strings do not do backslash substitution (except for \\
> and \'). You meant $lsep =3D "\n";
>
>
> > Also, how can I force it so that the output does not have the quotes
> > for every field?
>
> DBI::neat() won't quote the value if it knows it's a number.
> Unfortunately, I'm not sure how to let it know it's a number in this
> case. Sorry.



I'm guessing that this is happening when you hit a an empty string that you
are trying to insert into a numeric field. Convert empty strings in @row
into undef and it should work.

foreach my $i (0..$#row){$row[$i] =3D undef if $row[$i] eq ''}

The only drawback to this is if you actually want empty strings in your
character fields instead of nulls.



--
------------------------------------------------------------ ---------------=
-----------------------------------
The darkest places in hell are reserved for those who maintain their
neutrality in times of moral crisis.
Dante Alighieri (1265 - 1321)

They who would give up an essential liberty for temporary security, deserve
neither liberty or security.
Benjamin Franklin

Our lives begin to end the day we become silent about things that matter.
Martin Luther King

Our government can't be bought. The oil companies will never give it up at
any price.
My opinion
------------------------------------------------------------ ---------------=
-----------------------------------

------=_Part_3845_43975.1145066616784--

Re: dump_results

am 15.04.2006 04:28:29 von loopeter

Hi Jeffrey,

But why does this work when I select the rows into memory and insert
them to the same table? I must be missing something.

Thanks.

Peter

--- Jeffrey Seger wrote:

> >
> >
> >
> > Single quoted strings do not do backslash substitution (except for
> \\
> > and \'). You meant $lsep = "\n";
> >
> >
> > > Also, how can I force it so that the output does not have the
> quotes
> > > for every field?
> >
> > DBI::neat() won't quote the value if it knows it's a number.
> > Unfortunately, I'm not sure how to let it know it's a number in
> this
> > case. Sorry.
>
>
>
> I'm guessing that this is happening when you hit a an empty string
> that you
> are trying to insert into a numeric field. Convert empty strings in
> @row
> into undef and it should work.
>
> foreach my $i (0..$#row){$row[$i] = undef if $row[$i] eq ''}
>
> The only drawback to this is if you actually want empty strings in
> your
> character fields instead of nulls.
>
>
>
> --
>
------------------------------------------------------------ --------------------------------------------------
> The darkest places in hell are reserved for those who maintain their
> neutrality in times of moral crisis.
> Dante Alighieri (1265 - 1321)
>
> They who would give up an essential liberty for temporary security,
> deserve
> neither liberty or security.
> Benjamin Franklin
>
> Our lives begin to end the day we become silent about things that
> matter.
> Martin Luther King
>
> Our government can't be bought. The oil companies will never give it
> up at
> any price.
> My opinion
>
------------------------------------------------------------ --------------------------------------------------
>


Peter Loo
Worldwide Consulting, Inc.
Phoenix, Arizona
U.S.A.

Re: dump_results

am 18.04.2006 23:51:33 von Tim.Bunce

On Thu, Apr 13, 2006 at 03:22:19PM -0700, Loo, Peter # PHX wrote:
> Hi,
>
> I am passing the correct arguments to dump_results, but it appears that
> the records are not getting separated with new line.
>
> $maxlen = 500;
> $lsep = '\n';
> $fsep = '|';
> $fh = \*FH;
>
> $rows = $sth->dump_results($maxlen, $lsep, $fsep, $fh);

> Also, how can I force it so that the output does not have the quotes for
> every field?

Don't use dump_results() for this. The docs say:

Since it uses L to format and edit the string for reading by
humans, it is not recomended for data transfer applications.

Tim.