Mailing List Archive



Back to the month index Back to the list index

Joao Marcos Melo Mendes (jmmm@megamedia.pt)
Mon, 2 Sep 1996 12:04:01 +0100 (BST)


Date: Mon, 2 Sep 1996 12:04:01 +0100 (BST)
From: Joao Marcos Melo Mendes <jmmm@megamedia.pt>
Subject: Re: [mSQL] mSQL + msql PERL interface
Message-Id: <Pine.BSF.3.91.960902115615.9326C-100000@gatekeeper.megamedia.pt>

On Fri, 1 Sep 1995 jcoy@arkansas.net wrote:

> Here is a sample script I'm trying to get working, but it
> fails because the information in the getpwent() array is
> not quoted.

I had a similar problem a while ago. You have to quote the fields
yourself.

> create table pwent (
> uname char(8),
> passwd char(32),
> uid int,
> gid int,
> quota int,
> comment char(32),
> gcos char(32),
> homedir char(32),
> shell char(32)
> )

Hmm... Not all fields are text. If they were, you could do:

> $data = join(",", @info);

$data = "'".join("','",@info)."'";

Since they are not, you have to build the string by hand.

$data = "'$info[0]', '$info[1]', $info[2], etc... (put ' around the text
fields only).

Alternatively, you could do:

$data = join(",", @info(2,3,4)).",'".join("','",@info(0,1,5,6,7,8))."'";
$query = "insert into pwent
(uid,gid,quota,uname,passwd,comment,gcos,homedir,shell) values ($data)";

Remember the perl motto: There's More Than One Way To Do It.:)

I hope this helps. Best'o'Luck(tm)! :)

                                        Joao Mendes
                                        MegaMedia, S.A.

"We're fools to make war on our brothers in arms." - Mark Knopfler

--------------------------------------------------------------------------
To remove yourself from the Mini SQL mailing list send a message containing
"unsubscribe" to "unsubscribe" to msql-list-request@bunyip.com. Send a message containing
"info msql-list" to majordomo@bunyip.com for info on monthly archives of
the list. For more help, mail owner-msql-list@bunyip.com NOT the msql-list!