[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


PL/SQL equivalent of T-SQL REPLICATE statement

Posted on 2007-10-18
Medium Priority
Last Modified: 2013-12-19
I have the following code in a T-SQL script and it works well to put asterisks in to hide the code number.

SUBSTRING(columnA, 1, 1) + REPLICATE('*', Length(columnA) - 5) + SUBSTRING(columnA, Length(columnA) - 3, 4)

I have to update the DTS package that pulls the values from Oracle and I want to transform the code number during the select.  

I have the script changed to:

SUBSTR(columnA, 1, 1) || '********' || SUBSTR(columnA, Length(columnA) - 3, 4)

This works BUT instead of hardcoding the '*****' I'd rather just put in a replication of asterisks for the LENGTH - 5 of the columnA.  

How can I do that in the DTS package or in Oracle PL/SQL that's going through an ODBC connection?  I DON'T have the capability of creating a package to write a DUPLICATE function.    
Question by:safair
LVL 143

Assisted Solution

by:Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3] earned 200 total points
ID: 20101583
lpad('*', 5, '*' )
LVL 32

Accepted Solution

awking00 earned 1800 total points
ID: 20103703
SUBSTR(columnA, 1, 1)||lpad('*',length(columnA)-5,'*')||SUBSTR(columnA, Length(columnA) - 3, 4)

Author Comment

ID: 20104116
A friend suggested RPAD, which was a similar solution.  Thanks, guys you did great.  I gave more points to the second solution because THAT code snippet showed the LPAD in context so I knew exactly where to use it.  While technically correct, the context helped me know where to put it.  Thanks.

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question