Back to forum list… Back to How Do I?...

Multiple Statements in a DB Reader (11 replies)

Arline Welty
6 years ago
Arline Welty 6 years ago

I’ve noticed that when I have a transformation type of DB read that includes multiple DB statements (which is probably a bad IMAN hack anyway) I get the attached results in the audit.

What’s a better way to do what I want to do? I guess I am looking for some design advice. Details below.

Audit email:

What I’m trying to do (which works but gives me the audit notice of failure):

--- this job finds the current records where a price list exists that starts today, inserts them to a staging table, and then directly deletes from Sage.

https://www.realisable.co.uk/wp-content/uploads/2018/04/MultipleDatabaseStatementsAuditReport.png
Support
6 years ago
Support 6 years ago

Arline, unfortunately you're not able to have multiple statements in a database reader, furthermore you cannot have a DML Statement (Insert, Update or Delete) in a DB Reader. DB Readers must be a select statement returning a result set.

To achieve this, you would need to have a Script Task which issues the statement.

I will try to find a script and send it to you.

Arline Welty
6 years ago
Arline Welty 6 years ago

Just checking in on the script?

Support
6 years ago
Support 6 years ago

Arline, apologies....see attached.

What you need to do:

  1. Copy the script into a Script task.
  2. Alter the SCRIPT_FILE and DB_CONNECTION constants at the top of the script accordingly.
  3. Save your SQL script in the location specified by the SCRIPT_FILE constant (we recommend somewhere in the \IMan directory).

Thanks

Arline Welty
6 years ago
Arline Welty 6 years ago

Hello and thanks for the script- copied it into a script task, altered the constants, and saved the actual SQL to the SCRIPT_FILE location. When I went to run this I got an error:

"Invalid procedure call or argument

Line=17 Pos=0"

which corresponds to "ts.Close" in my file. 

 

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(SCRIPT_FILE, ForReading, False)
sScript = ts.ReadAll
ts.Close

 

?

Support
6 years ago
Support 6 years ago

Arline, please find the revised script.

Thanks

Arline Welty
6 years ago
Arline Welty 6 years ago

Ok, revised script results:

This time I got "File Not Found" Line=17 Pos=0 which corresponds to the same ts.Close element.

 

Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.OpenTextFile(SCRIPT_FILE, 1, False)
sScript = ts.ReadAll
ts.Close

Other suggestions?

 

 

Support
6 years ago
Support 6 years ago

Did you update the SCRIPT_FILE and DB_CONNECTION constants?

Arline Welty
6 years ago
Arline Welty 6 years ago

Yes and I've tried a couple iterations. SCRIPT_FILE is straightforward, but I get various issues when testing variations on the DB_CONNECTION details, for example:

When DB_CONNECTION is set to:

Const DB_CONNECTION = "Provider=SQLNCLI11;Server=SERVERNAME\SQL2;Database=DBNAME;Uid=USERHERE;Pwd=PASSWORDHERE;"

the error is "File Not Found" Line=17 Pos=0 

Same issue when I set it to:

Const DB_CONNECTION = "Driver={SQL Server Native Client 11.0};Server=SERVERNAME\SQL2;Database=DBNAME;Uid=USERHERE;Pwd=PASSWORDHERE;"

 

Support
6 years ago
Support 6 years ago

Arline, the likelihood is the file path referred to by the SCRIPT_FILE constant is:

  1. Incorrect or;
  2. Or cannot be read by IMan due to file permissions.

Thanks

Arline Welty
6 years ago
Arline Welty 6 years ago

Confirmed- got the permissions resolved and now it's working. Thanks!

Contact

Realisable Software Ltd provides code-free, cost-effective applications integration solutions for SMEs. Our core IMan product is designed to integrate almost any application with a number of Sage solutions and online payment processors.

Looking to purchase IMan, please see our resellers here.

Realisable Software
Ph: +44 (0) 208 123 1017

Copyright © Realisable. All rights reserved.
Realisable is a registered trademark

Close

Request Demo

Realisable Software Ltd provides code-free, cost-effective applications integration solutions for SMEs. Our core IMan product is designed to integrate almost any application with a number of Sage solutions and online payment processors.

Looking to purchase IMan, please see our resellers here.

Realisable Software
Ph: +44 (0) 208 123 1017

Copyright © Realisable. All rights reserved.
Realisable is a registered trademark

Close

Access Downloads

Realisable Software Ltd provides code-free, cost-effective applications integration solutions for SMEs. Our core IMan product is designed to integrate almost any application with a number of Sage solutions and online payment processors.

Looking to purchase IMan, please see our resellers here.

Realisable Software
Ph: +44 (0) 208 123 1017

Copyright © Realisable. All rights reserved.
Realisable is a registered trademark

Close