Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^9: SQL query using elements from array

by poj (Abbot)
on Oct 13, 2014 at 18:03 UTC ( #1103656=note: print w/replies, xml ) Need Help??


in reply to Re^8: SQL query using elements from array
in thread SQL query using elements from array

Try running this script
#!perl use strict; use DBI; my $dbh = dbh(); my $sql ="select * from information_schema.columns where table_name = ?"; my @tables = ('TopsData.dbo.AUDT_AuditChrt','TopsData.dbo.AUDT_AuditMe +dication'); for my $table (@tables){ my $ar = $dbh->selectall_arrayref($sql,undef,$table); for (@$ar){ print join ":",@$_,"\n"; } } # connect sub dbh { my $dsn = "dbi:ODBC:DSN=TEST-DB1"; my $dbh = DBI->connect($dsn, 'SA', 'pass', {RaiseError => 1, PrintError => 1}) or die (Error connecting " $DBI::errstr"); }
poj

Replies are listed 'Best First'.
Re^10: SQL query using elements from array
by AllPaoTeam (Acolyte) on Oct 15, 2014 at 15:42 UTC
    Odd, it ran successfully but did not print anything, would you have an idea why?
      Try using just the table name in the select
      my @tables = ('AUDT_AuditChrt','AUDT_AuditMedication');
      poj
        Hey it worked, below is what it spit out:
        TopsData:dbo:AUDT_AuditChrt:AuditChrt_ID:1: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditChrt:AuditChrt_RecordState:2: CREATE DEFAULT D_Zero AS 0 :NO:tinyint:::3:10:0::::::::TopsData:dbo:T_RecordState: TopsData:dbo:AUDT_AuditChrt:AuditDgphAlias_ID:3: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditChrt:AuditDgphType_ID:4: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditChrt:Login_ID:5: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditChrt:AuditChrt_Description:6: CREATE DEFAULT D_EmptyString AS '' :NO:varchar:400:400:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:::: TopsData:dbo:AUDT_AuditChrt:AuditChrt_Update:7: CREATE DEFAULT D_Boolean AS 0 :NO:bit:::::::::::::TopsData:dbo:T_Boolean: TopsData:dbo:AUDT_AuditChrt:AuditChrt_RecordID:8: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditChrt:AuditChrt_TimeStamp:9::YES:datetime::::::3 +:::::::::: TopsData:dbo:AUDT_AuditChrt:AuditChrt_RowGuid:10:(newid()):NO:uniqueid +entifier:::::::::::::::: TopsData:dbo:AUDT_AuditChrt:Patient_ID:11: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditChrt:AuditChrt_Workstation:12: CREATE DEFAULT D_EmptyString AS '' :NO:varchar:40:40:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:::: TopsData:dbo:AUDT_AuditChrt:AuditReason_ID:13: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditMedication:AuditMedication_ID:1: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditMedication:AuditMedication_RecordState:2: CREATE DEFAULT D_Zero AS 0 :NO:tinyint:::3:10:0::::::::TopsData:dbo:T_RecordState: TopsData:dbo:AUDT_AuditMedication:AuditDgphAlias_ID:3: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditMedication:AuditDgphType_ID:4: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditMedication:Login_ID:5: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditMedication:Pharmacy_ID:6: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditMedication:AuditMedication_Description:7: CREATE DEFAULT D_EmptyString AS '' :NO:varchar:400:400:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:::: TopsData:dbo:AUDT_AuditMedication:AuditMedication_Update:8: CREATE DEFAULT D_Boolean AS 0 :NO:bit:::::::::::::TopsData:dbo:T_Boolean: TopsData:dbo:AUDT_AuditMedication:AuditMedication_RecordID:9: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditMedication:AuditMedication_TimeStamp:10::YES:da +tetime::::::3:::::::::: TopsData:dbo:AUDT_AuditMedication:AuditMedication_SendMethod:11: CREATE DEFAULT D_Zero AS 0 :NO:tinyint:::3:10:0::::::::::: TopsData:dbo:AUDT_AuditMedication:AuditMedication_RowGuid:12:(newid()) +:NO:uniqueidentifier:::::::::::::::: TopsData:dbo:AUDT_AuditMedication:Patient_ID:13: CREATE DEFAULT D_TableKey AS '0000000000' :NO:char:10:10:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS:TopsData:dbo +:T_TableKey: TopsData:dbo:AUDT_AuditMedication:AuditMedication_Workstation:14: CREATE DEFAULT D_EmptyString AS '' :NO:varchar:30:30:::::::iso_1:::SQL_Latin1_General_CP1_CI_AS::::
        OK now what does this mean in terms of my issue?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2020-11-29 05:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?