Quantcast
Channel: Active questions tagged powershell-3.0 - Stack Overflow
Viewing all articles
Browse latest Browse all 122

How to add single quotes to one of the columns in PowerShell?

$
0
0

I have the following lines in a file:

pc_cc_text$fx_review1  CONSTANT VARCHAR2(100) := 'For Company Review'; -- AD_PRT_AUTH_(MSP)pc_cc_text$fx_review2  CONSTANT VARCHAR2(100) := 'For Dept Review'; -- AD_PRT_AUTH_(ADX)

I need to format them as follows:

WHEN 'pc_cc_text$fx_review1' THEN 'For Company Review'WHEN 'pc_cc_text$fx_review2' THEN 'For Dept Review'

How to do this in PowerShell?

This is what I have tried so far:

(Get-Content FILE | where {$_ -match ':='} | where {$_ -notmatch '^--'} | ForEach-Object{("'" + $_ -split ";|--")[0,1] -join ''}) -replace 'CONSTANT[^ ]'  -replace 'VARCHAR2[^ ]' -replace ':=', 'THEN ' -replace '^', 'WHEN '

This prints:

WHEN 'pc_cc_text$fx_review1    THEN  'For Company Review'WHEN 'pc_cc_text$fx_review2    THEN  'For Dept Review'

It is almost correct but the second single tick on the second column needs to be added. How to do this?


Viewing all articles
Browse latest Browse all 122

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>