Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Can SQL be used without a database?

by thegoaltender (Sexton)
on Dec 31, 2003 at 14:56 UTC ( [id://317892]=note: print w/replies, xml ) Need Help??


in reply to Re: Can SQL be used without a database?
in thread Can SQL be used without a database?

First, thanks for everyone's help.
Let me better explain what I am doing. I have 4 tables of data and I am trying to do joins between them without using a database.
I changed my hashes to arrays of arrays and tried to use DBI::AnyData. It seems to be having trouble getting my arrays into table format. I am getting the following error:

Can't coerce array into hash at C:/Perl/site/lib/DBD/AnyData.pm line 247.

Here is the some of the test code I am using for 1 join:

$dbh = DBI->connect('dbi:AnyData(RaiseError=>1):'); $dbh->func( 'rdbtable', 'ARRAY', @rdb, 'ad_import'); $dbh->func( 'asitable', 'ARRAY', @asi, 'ad_import'); $dbh->func( 'bomtable', 'ARRAY', @bom, 'ad_import'); $dbh->func( 'mpttable', 'ARRAY', @mpt, 'ad_import'); $rdbtable_sth = $dbh->prepare( "SELECT SIGNAL_NAME,LOCATION,X_COORDINA +TE,Y_COORDINATE,Z_COORDINATE,COMPONENT_SIDE,ETCH_SIDE,GROUND,GROUND_L +OCATION FROM rdbtable" ); $asitable_sth = $dbh->prepare( "SELECT SIGNAL_NAME,LOCATION,REFERENC +E_DESIGNATOR,PIN_NUMBER,DEVICE_NAME,PACKAGE_TYPE,CS_PART_NUMBER FROM +asitable WHERE LOCATION = ?" ); $rdbtable_sth->execute; while (($location,$rdb_signal_name) = $rdbtable_sth->fetchrow_array) { $asitable_sth->execute($location); $row = $asitable_sth->fetchrow_arrayref; $asi_signal_name = $row ? $row->[0] : ''; print "$rdb_signal_name : $asi_signal_name\n"; }

Here are the 2 tables:

rdbtable:

SIGNAL_NAME,LOCATION,X_COORDINATE,Y_COORDINATE,Z_COORDINATE,COMPONENT_SIDE,ETCH_SIDE,GROUND,GROUND_LOCATION
A_AD0,BP1.19E25,-895.0390,3277.3700,0.0000,0,1,GND,BP1.19245
A_AD0,F6_54.W4VIA,1825.0000,3975.0000,0.0000,0,1,GND,F6_54.W7VIA
A_AD1,F6_54.Y3VIA,1775.0000,3925.0000,0.0000,0,1,GND,F6_54.AB4VIA
A_AD1,BP1.18A3,-1210.0000,3513.5910,0.0000,0,1,,
A_AD2,BP1.19C25,-1052.5200,3277.3700,0.0000,0,1,GND,BP1.19254
A_AD2,F6_54.W3VIA,1825.0000,3925.0000,0.0000,0,1,GND,F6_54.AB4VIA

asitable:

SIGNAL_NAME,LOCATION,REFERENCE_DESIGNATOR,PIN_NUMBER,DEVICENAME,PACKAGE_TYPE,CS_PART_NUMBER
A_AD0,F6_54.W4VIA,F6_54,W4,XC2V4000,BGA957XBTF-XC2V4000_9B,059-000-408
A_AD1,F6_54.Y3VIA,F6_54,Y3,XC2V4000,BGA957XBTF-XC2V4000_9B,059-000-408
A_AD2,F6_54.W3VIA,F6_54,W3,XC2V4000,BGA957XBTF-XC2V4000_9B,059-000-408
A_AD3,F6_54.AA5VIA,F6_54,AA5,XC2V4000,BGA957XBTF-XC2V4000_9B,059-000-408
A_AD4,F6_54.Y5VIA,F6_54,Y5,XC2V4000,BGA957XBTF-XC2V4000_9B,059-000-408
A_AD5,F6_54.Y6VIA,F6_54,Y6,XC2V4000,BGA957XBTF-XC2V4000_9B,059-000-408

Any suggestions for fixing what I have or better ways to handle this situation would be greatly appreciated.

Thanks again,
Jim

Replies are listed 'Best First'.
Re: Re: Re: Can SQL be used without a database?
by thegoaltender (Sexton) on Dec 31, 2003 at 17:11 UTC
    Can't coerce array into hash at C:/Perl/site/lib/DBD/AnyData.pm line 247.

    This appears to be caused by the way my array of arrays is created.

    I am creating it in the following manner:

    $test[0][0] = 'No'; $test[0][1] = 'Letter'; $test[0][2] = 'Roman'; $test[1][0] = 1; $test[1][1] = 'a'; $test[1][2] = 'i'; $test[2][0] = 2; $test[2][1] = 'b'; $test[2][2] = 'ii'; $test[3][0] = 3; $test[3][1] = 'c'; $test[3][2] = 'iii'; $test[4][0] = 4; $test[4][1] = 'd'; $test[4][2] = 'iv'; $test[5][0] = 5; $test[5][1] = 'e'; $test[5][2] = 'v'; $test[6][0] = 6; $test[6][1] = 'f'; $test[6][2] = 'vi';

    I don't currently see what the difference is from the following (which works):

    @test = [ ['No','Letter','Roman'], [1,'a','i'], [2,'b','ii'], [3,'c','iii'], [4,'d','iv'], [5,'e','v'], [6,'f','vi'] ];

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://317892]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (1)
As of 2024-04-26 02:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found