Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8729325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:48:51+00:00 2026-06-13T08:48:51+00:00

I have two files. One is a file of table creation strings dumped from

  • 0

I have two files. One is a file of table creation strings dumped from database, the other is the name of tables, with a “prompt” as a prefix and a “…” as suffix. Just as below:
file A (index):

prompt branch...
prompt branch_param...
prompt branch_pre_param...
prompt business...
prompt business_map...
prompt business_type...

file B (dump):

CREATE TABLE "KS"."BRANCH"
 ("BRANCH_CODE"       CHARACTER(3)    NOT NULL  DEFAULT '',
  "BRANCH_NAME"       CHARACTER(40)   NOT NULL  DEFAULT '',
  "PARAM_LEVEL"       INTEGER         NOT NULL  DEFAULT 0
 )
  DATA CAPTURE NONE
 IN "LONG_DATA_TBS";


CREATE TABLE "KS"."BRANCH2BANK"
 ("BRANCH_CODE"         CHARACTER(3)    NOT NULL  DEFAULT '',
  "BANK_CODE"           CHARACTER(6)    NOT NULL  DEFAULT '',
  "ACC_COMP_RESULT"     CHARACTER(1)    NOT NULL  DEFAULT ''
 )
  DATA CAPTURE NONE
 IN "SMALL_TBS";

CREATE TABLE "KS"."BRANCH2BOND"
 ("BRANCH_CODE"        CHARACTER(3)    NOT NULL  DEFAULT '',
  "BOND_CODE"          CHARACTER(8)    NOT NULL  DEFAULT '',
  "BOND_NAME"          CHARACTER(20)   NOT NULL  DEFAULT '',
  "TOTAL_AMT"          DECIMAL(19, 4)  NOT NULL  DEFAULT 0,
  "FINANCING_CUST_NO"  CHARACTER(10)   NOT NULL  DEFAULT '',
  "SET_DATE"           CHARACTER(8)    NOT NULL  DEFAULT '',
  "SET_TIME"           CHARACTER(8)    NOT NULL  DEFAULT '',
  "SET_EMP"            CHARACTER(6)    NOT NULL  DEFAULT '',
  "SPARE1"             CHARACTER(20)   NOT NULL  DEFAULT '',
  "SPARE2"             CHARACTER(20)   NOT NULL  DEFAULT ''
 )
  DATA CAPTURE NONE
 IN "SMALL_TBS";

CREATE TABLE "KS"."BRANCH_PARAM"
 ("BRANCH_CODE"    CHARACTER(3)    NOT NULL  DEFAULT '',
  "PARAM_CODE"     CHARACTER(4)    NOT NULL  DEFAULT '',
  "SET_DATE"       CHARACTER(8)    NOT NULL  DEFAULT '',
  "SET_TIME"       CHARACTER(8)    NOT NULL  DEFAULT ''
 )
  DATA CAPTURE NONE
 IN "SMALL_TBS";

CREATE TABLE "KS"."BRANCH_RESERVE_CREDIT_STOCK"
 ("BRANCH_CODE"  CHARACTER(3)    NOT NULL  DEFAULT '',
  "SET_TIME"     CHARACTER(8)    NOT NULL  DEFAULT ''
 )
  DATA CAPTURE NONE
 IN "TX_DATA_TBS"
 INDEX IN "TX_INDEX_TBS";

I have written a perl implementation, but I think it is much too ugly and inefficient. Is there a better way to improve this?

my code: (rewritten with Richard and lilydjwg’s advice) (last version)

#!/usr/bin/perl
use 5.016;

my (%hash,$cont);
open IN,'<',shift;
while(<IN>){
    chomp;
    $hash{$1}=1 if /prompt (\w+)\.\.\./;
}
close IN;
open IN,'<',shift;
while(<IN>){
    chomp;
    $cont = (defined $hash{lc $1}?say "prompt $1..." : 0) if /CREATE TABLE "KS"\."(\w+)"/;
    say if $cont == 1;
}
close IN;                   
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:48:52+00:00Added an answer on June 13, 2026 at 8:48 am

    Presumably it’s the repeated reads you don’t like.

    So – read the CREATE TABLE file once, checking for:

    CREATE TABLE "KS"."(\w+)"
    

    Then you can build up the table definition until the next CREATE TABLE at which point you put the table-definition into a hash keyed by the table-name.

    Then, read your prompts and grab the definitions one by one from the hash printing them out.

    Alternatively, you could just read the CREATE TABLE file into a single string and search+replace the table-name part since that’s all you seem to be changing at the moment. The first approach is more flexible though.


    Edit:
    You could make the defined bit a little clearer perhaps with:

    while ($line=<IN>) {
        chomp($line);
        if (/CREATE TABLE "KS"\."(\w+)"/ && $hash{lc $1}) {
            $line = ...
        }
        say $line;
    }
    

    I like to use an explicit variable in my while-loops once I get beyond a couple of lines too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created two JavaScript files. One file is "validators.js" and the other is
Say I have two files where there is one number per line File 1
I have two project, one which generates some artifacts from a WSDL file using
I have an array of images, and two nib files. One nib file has
I am searching a way to combine two MHT-Files. I have one MHT-File and
I have two tables: one table (okay, it's a view), vComputer, lists many computers
I have two ms access 2003(.mdb) file one is student record the other is
I have two different modules that need access to a single file (One will
I have a file named file with three lines: line one line two line
I have two files one with senators who are retiring and one of complete

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.