Model Context Protocol (MCP) finally gives AI models a way to access the business data needed to make them really useful at work. CData MCP Servers have the depth and performance to make sure AI has access to all of the answers.
Try them now for free →How to pipe IBM Informix Data to CSV in PowerShell
Use standard PowerShell cmdlets to access IBM Informix tables.
The CData Cmdlets Module for IBM Informix is a standard PowerShell module offering straightforward integration with IBM Informix. Below, you will find examples of using our Informix Cmdlets with native PowerShell cmdlets.
Creating a Connection to Your IBM Informix Data
Set the following properties to connect to IBM Informix
- Server: Set this to the name of the server running IBM Informix.
- Port: Set this to the port the IBM Informix server is listening on.
- Database: Set this to the name of the IBM Informix database.
- User: Set this to the username of a user allowed to access the database.
- Password: Set this to the password of a user allowed to access the database.
$conn = Connect-Informix -Server "$Server" -Port "$Port" -User "$User" -Password "$Password" -Database "$Database"
Selecting Data
Follow the steps below to retrieve data from the Books table and pipe the result into to a CSV file:
Select-Informix -Connection $conn -Table Books | Select -Property * -ExcludeProperty Connection,Table,Columns | Export-Csv -Path c:\myBooksData.csv -NoTypeInformation
You will notice that we piped the results from Select-Informix into a Select-Object cmdlet and excluded some properties before piping them into an Export-Csv cmdlet. We do this because the CData Cmdlets append Connection, Table, and Columns information onto each "row" in the result set, and we do not necessarily want that information in our CSV file.
The Connection, Table, and Columns are appended to the results in order to facilitate piping results from one of the CData Cmdlets directly into another one.Deleting Data
The following line deletes any records that match the criteria:
Select-Informix -Connection $conn -Table Books -Where "Category = US" | Remove-Informix
Inserting and Updating Data
The cmdlets make data transformation easy as well as data cleansing. The following example loads data from a CSV file into IBM Informix, checking first whether a record already exists and needs to be updated instead of inserted.
Import-Csv -Path C:\MyBooksUpdates.csv | %{ $record = Select-Informix -Connection $Informix -Table Books -Where ("Id = `'"+$_.Id+"`'") if($record){ Update-Informix -Connection $informix -Table Books -Columns ("Id","Price") -Values ($_.Id, $_.Price) -Where ("Id = `'"+$_.Id+"`'") }else{ Add-Informix -Connection $informix -Table Books -Columns ("Id","Price") -Values ($_.Id, $_.Price) } }
As always, our goal is to simplify the way you connect to data. With cmdlets users can install a data module, set the connection properties, and start building. Download Cmdlets and start working with your data in PowerShell today!