Create script from another script using PROMPT

Oracle 11
Instead of having to link to another database I want to create 2 scripts that are executed from a shell script and run them separately. Script1 run in Database1 would create Script 2 by using PROMPT to create the second script while grabbing a date from database1 to pass into database2. I almost have it but the problem is ... Script2 uses COPY FROM and I have to put a "-" at the end of each line which the PROMPT takes as a literal instead of as part of the output.
SCRIPT1:
set pagesize 0
set trimspool on
set linesize 2000
set echo off
set verify off
set feedback off
set sqlblanklines on
spool /home/michelle/sql_scripts/sl_dtc_copy2.sql
PROMPT whenever sqlerror exit sql.sqlcode rollback
PROMPT SET ARRAYSIZE 5000
PROMPT SET COPYCOMMIT 20
PROMPT set linesize 4000
PROMPT
PROMPT COPY FROM {username}/{pswd}@{DB2}  TO {username}/{pswd}@{DB2}
PROMPT CREATE SL_DTC_TMP USING SELECT DISTINCT
PROMPT col1, col2, col3
PROMPT FROM dual
PROMPT WHERE veh_data_elements_cd = 'ODO_READ'
PROMPT and       dh.data_collected_timstm >= 
select trunc(sysdate)-7 from dual;
PROMPT and       substr(vdh.vin,10,1) in ('A','B','C','D')
PROMPT /
PROMPT spool off
PROMPT exit
spool off
exitSCRIPT2 NOW:
whenever sqlerror exit sql.sqlcode rollback
SET ARRAYSIZE 5000
SET COPYCOMMIT 20
set linesize 4000
COPY FROM {username}/{pswd}@{DB2}  TO {username}/{pswd}@{DB2}
CREATE SL_DTC_TMP USING SELECT DISTINCT
col1, col2, col3
FROM dual
WHERE veh_data_elements_cd = 'ODO_READ'
and       dh.data_collected_timstm >=
12-AUG-11
and       substr(vdh.vin,10,1) in ('A','B','C','D')
spool off
exitSCRIPT2 HOW IT NEEDS TO BE:
--- A [SPACE] AND A [-] at the end of each line
--- THE DATE NEEDS TO HAVE SINGLE QUOTES AND PREFERABLY AT THE END OF THE PREVIOUS LINE
whenever sqlerror exit sql.sqlcode rollback
SET ARRAYSIZE 5000
SET COPYCOMMIT 20
set linesize 4000
COPY FROM {username}/{pswd}@{DB2}  TO {username}/{pswd}@{DB2} -
CREATE SL_DTC_TMP USING SELECT DISTINCT -
col1, col2, col3 -
FROM dual -
WHERE veh_data_elements_cd = 'ODO_READ' -
and       dh.data_collected_timstm >= '12-AUG-11' -
and       substr(vdh.vin,10,1) in ('A','B','C','D')
spool off
exitTHANK YOU

Try
select 'whenever sqlerror exit sql.sqlcode rollback'                    ||chr(10)||
       'SET ARRAYSIZE 5000'                                             ||chr(10)||
       'SET COPYCOMMIT 20'                                              ||chr(10)||
       'set linesize 4000'                                              ||chr(10)||
       ' '                                                              ||chr(10)||
       'COPY FROM {username}/{pswd}@{DB2}  TO {username}/{pswd}@{DB2} -'||chr(10)||
       'CREATE SL_DTC_TMP USING SELECT DISTINCT -'                      ||chr(10)||
       'col1, col2, col3 -'                                             ||chr(10)||
       'FROM dual -'                                                    ||chr(10)||
       'WHERE veh_data_elements_cd = ''ODO_READ'' -'                    ||chr(10)||
       'and       dh.data_collected_timstm >= ''12-AUG-11'' -'          ||chr(10)||
       'and       substr(vdh.vin,10,1) in (''A'',''B'',''C'',''D'')'
       as Script
from dual

Similar Messages

  • New database create script using DBCA

    Hi,
    I'm trying to generate a database create script using DBCA. I have another database running on the same physical server(HP-UX and oracle 10g R2). When I run the DBCA, it is creating scripts to Clone DB and Clone RMAN restore. Why it is not generating to create a new database instead of cloning the DB.
    Thanks

    Rock2 wrote:
    Hi,
    I'm trying to generate a database create script using DBCA. I have another database running on the same physical server(HP-UX and oracle 10g R2). When I run the DBCA, it is creating scripts to Clone DB and Clone RMAN restore. Why it is not generating to create a new database instead of cloning the DB.
    ThanksWhen you launch dbca, you need to select to create a 'custom' database, not one of the pre-canned templates. The templates will all result in a script that does an rman restore from a backup that comes with the product. Selecting 'custom' database will result in scripts built around the CREATE DATABASE sql statement.

  • I have created PDF from hardcopy by using my scanner. After I run OCR option for my PDF by using Acrobat Pro 9. But "Text-to-speech" functionality of the PDF says that an error message comes up that says the page is empty when I turns on the read out loud

    I have created PDF from hardcopy by using my scanner. After I run OCR option for my PDF by using Acrobat Pro 9. But "Text-to-speech" functionality of the PDF says that an error message comes up that says the page is empty when I turns on the read out loud option in Acrobat. Kindly help me to sortout this problems?

    So I tried generating the same PDFs on two other computers that have Acrobat 9 Pro.  Results were reproduced.  The verdict is:
    - complex PDF files (that is, containing cross-references, tables of contents, and bookmarks) generated by Acrobat 9.x Pro are roughly 2-5x larger than the identical file generated with Acrobat 8.x Pro.
    - different PDF conversion settings make a negligable difference (less than 10% rather than 70-80%).
    - using the "Reduce File Size" or "Optimize PDF" option cuts the file size roughly in half, almost always resulting in a "image downsampling mask" warning message, which requires acknowledgement (that is a problem for batch processing or automation).
    - adding an Acrobat watermark to the file cuts the file size roughly in half.
    - just using Save As to another filename has no effect on file size.
    - generating the PDF in Acrobat 9 with links but no PDF bookmarks still results in the inflated file size.
    - generating the PDF in Acrobat 9 without any links or bookmarks results in approximately the same file size as the Acrobat 8 PDF with full links and bookmarks.
    It appears that Acrobat 9's manner of adding links is what's bloating  the files, and in my case it's probably not related to images or image resolution/print quality.  It's a shame, because Acrobat 9 seems to have made some  improvements to the Review Tracker interface, and a few other bells and  whistles which I haven't really gotten around to exporing yet.  But  unless I find a way to keep my links and the PDF file sizes comparable to what I was  getting with Acrobat 8 Pro, it looks like I'm going to stay with Acrobat 8.

  • FETCHING VALUES IN MULTI RECORD BLOCK FROM ANOTHER TABLE USING SELECT STATEMENT.

    Hi,
    I have one multi record block in which i want to fetch values
    (more then one record) from another table using select statement
    IN KEY NEXT ITEM.I am getting following error.
    ORA-01422: exact fetch returns more than requested number of rows
    Thanks in advance.

    In your case I see no reason to use non-database block and to try to populate it from a trigger with a query, instead of using the default forms functionality where you can associate the block and the fields with table, create where clause using bind variables and simply use execute_query() build-in to populate the block. The power of the forms is to use their build-in functionality to interact with the database.
    Also, you can base your block on a query, not on a table and you dynamically change this query using set_block_property() build-in. You can use any dynamic queries (based on different data sources) and you simply need to control the column's data type, the number of the columns and their aliases. Something like creating inline views as a block data source.
    However, you can replace the explicit cursor with implicit one like
    go_block('non_db_block_name');
    first_record();
    FOR v_tab IN (SELECT *
    FROM tab
    WHERE col_name = :variable)
    LOOP
    :non_db_block_name.field1 := v_tab.col1;
    :non_db_block_name.field2 := v_tab.col2;
    next_record();
    END LOOP;

  • I'm trying to clone a internal hard drive from another mac using a usb connection.

    I'm trying to clone a internal hard drive from another mac using a usb connection to an external drive so that I don't lose the file before reinstalling the software but I keep on getting a message:
    "Restore Failure
    Source volume is read-write and cannot be unmounted, so it can't be block copied."
    Any advice on how to make a copy of this internal drive?
    Thanks!
    ....also the internal hard drive i am trying to copying run on a mac os x 10.5 and i'm reinstalling the software because the computer is not starting and only shows a grey folder with a question marks inside.

    I've had my Maxtor external OneTouch 250GB for about 18 months now and it hasn't skipped a beat. I have hear of people having their Maxtor drive just up and die but you will probably find that goes for all manufacturers.
    By the way, Maxtor is, amongst others, an OEM supplier to Apple.

  • Best way To get data from another application using NDDE lbrary

    My vb.net application gets data from another application using NDDE Library. I got stocks prices (open,high,low,close,volume,change......(about 15 records for each stock)) (about 200 stocks) . I don't know if there is a problem in my code.
    This is my code:
    l : is the list of stocks.
    This Sub connects to server and requests the data :
    Public Shared Sub GetQuotes()
    Try
    client1 = New DdeClient(server, topic)
    client1.Connect()
    For i As Integer = 0 To l.Count - 1
    client1.StartAdvise("QO." & l(i).t & ".TAD$last", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$open", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$high", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$low", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$pclose", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$volume", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$date", 1, True, 60000)
    client1.StartAdvise("QO." & l(i).t & ".TAD$time", 1, True, 60000)
    Next
    Catch ex As Exception
    MsgBox(ex.Message)
    End Try
    End Sub
    and then I get the data from Client_advise sub (called each time a value changed )and fill the list. What I know is that client advise gets only one record for single stock each time is called..
    Example: for stock AAPL. 1st time enters client_Advise I get open price for AAPL, 2nd time I get high price for AAPL,3rd time I get low price..... and I update the value in the List (l)
    This the client_Advise Sub:
    Private Shared Sub client1_Advise(ByVal sender As Object, ByVal e As NDde.Client.DdeAdviseEventArgs) Handles client1.Advise
    For q As Integer = 0 To l.Count - 1
    If l(q).t = w(1) Then
    Dim item() As String = e.Item.Split("$")
    If l(q).Open = "#" Then
    l(q).Open = "0"
    End If
    If l(q).hi = "#" Then
    l(q).hi = "0"
    End If
    If l(q).lo = "#" Then
    l(q).lo = "0"
    End If
    If l(q).Close = "" Or l(q).Close = "#" Then
    l(q).Close = "0"
    End If
    If l(q).pclose = "#" Then
    l(q).pclose = "0"
    End If
    If item(1) = "open" Then
    l(q).Open = Format(Val(e.Text), "0.00")
    ElseIf item(1) = "last" Then
    l(q).Close = Format(Val(e.Text), "0.00")
    ElseIf item(1) = "high" Then
    l(q).hi = Format(Val(e.Text), "0.00")
    ElseIf item(1) = "volume" Then
    l(q).Volume = Val(e.Text)
    ElseIf item(1) = "low" Then
    l(q).lo = Format(Val(e.Text), "0.00")
    ElseIf item(1) = "pclose" Then
    l(q).pclose = Format(Val(e.Text), "0.00")
    If l(q).pclose <> "" And l(q).pclose <> "#" And l(q).Close <> "" And l(q).Close <> "#" Then
    l(q).c = Format(l(q).Close - l(q).pclose, "0.00")
    l(q).cp = Format(((l(q).Close - l(q).pclose) / l(q).pclose) * 100, "0.00")
    End If
    l(q).flag1 = 2
    ElseIf item(1) = "date" Then
    l(q).Date1 = e.Text
    ElseIf item(1) = "time" Then
    l(q).Time = e.Text
    End If
    Exit For
    End If
    Next
    End Sub
    Am I doing something wrong which inreases CPU usage to 80 or 90 % ?
    Thanks in advance.

    Hi MikeHammadi,
    According to your description, you'd like to get data from another app using NDDE library.
    When using the NDDE library, the CPU usage is high. As the NDDE library is third-party library, it is not supported here. I suggest you checking if the problem is caused by the NDDE library.
    If you'd like to get data from another app. I suggest you could save the data in the dataBase, and then read it in another application if necessary.
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Adobe v9 on W7 and office 2007. cannot create PDF from MS word using Adobe. But can from Excel, PPT

    Adobe v9 on W7 and office 2007. cannot create PDF from MS word using Adobe. But can from Excel, PPT and other MS office apps. Reinslalled Adobe, updated Office, and Adobe no help! Also I can create a pdf from the MS Word and it is using the Adobe 9. So one would think that's good. No it isn't when you need to combine different files to one big PDF document. Any suggetions? Thank you

    Yes, I’m saying that I can in WORD use “Save As ADOBE pdf” but cannot in ADOBE create a pdf file from a WORD (.doc or .docx) document. While I can from other MS Office apps like Excel and PowerPoint.
    I understand I can use “work around” and save doc in WORD as pdf then compile all files needed (xml, ppt, pdf) in the ADOBE v9. to one big pdf document. But that is not the point of this post.  
    Jarda @ PC+NET Solutions
    Mobile 613-532-7023
    Office  613-385-1268
    <http://www.pcplusnet.net/> www.pcplusnet.net

  • HT204350 Incorrect link to "OS X: How to migrate data from another Mac using Mountain Lion and earlier"

    Incorrect link to "OS X: How to migrate data from another Mac using Mountain Lion and earlier". Should be http://support.apple.com/kb/HT6025

    I think the OP is saying OS X: How to migrate data from another Mac using Mountain Lion and earlier (which should be a link to HT4889) just links back to OS X: How to migrate data from another Mac using Mavericks (HT5872).
    It does indeed do that, & HT4889 seems to be MIA.

  • How to view messages from another iPhone using your apple Id

    How to view messages from another iPhone using your apple Id

    Sign into iMessage using the same ID (in Settings>Messages>Send & Receive).  The other phone should then see your messages too.

  • Problem with creating site from another computer!

    Hi
    I have WebDB 2.2 and Oracle8i instaled on the same computer. I have a problem to create site from another computer. There is not any process when I try to create site. There is always 0%.
    But I have no problem with creating site on the origin computer.
    Does anybody know something about it?

    I am just not clear what to do once I have made changes and have published the new information.
    You shouldn't have to do anything. iWeb will save the information in the Domain.sites file. You can keep this file in a folder, or even on your desktop and iWeb will launch from a double-click on the file.

  • How do I install Mac OS from another computer using firewire?

    My iMac has a bad CD drive but I was told that there is a way to install Leopard from another computer using a firewire connection between the two. I put the install CD in the other computer and rebooted it using "T" (and I see the floating firewire symbol as expected). But I don't see the install disk on the iMac. What's up?

    you can try another way:
    connect a firewire drive to the good Mac. Partition the drive and make the second partition as small as you can but at least 8 gigs. Mount he Leopard DVD to desktop. Launch Disk Utility and select that external drive and the restore tab. Drag the source , ie the MacOSX DVD to source window and that second small partition to the destination window. Select restore and enter your password. Wait 30 mins, restore is done. Quit all programs. Unmount that external drive. Connect to the "bad" Mac and restart it from that external drive to install Leopard OSX. You can if you want load most of your software on the first partition of the external and install your software unless of course you did a Time Machine to make it far simpler.

  • I can't create table from another table?

    Hi everyone!
    I have a problem that I don't known the reason why?
    I'm using Oracle version 8i and I want to create a table from another table, such as:
         CREATE TABLE a_backup as SELECT * FROM a => It's OK, table a_backup is created.
    But there is only a table that I can't created like that, such as:
         CREATE TABLE b_backup AS SELECT * FROM b;
    When I run over command, SQL Plus is not responding... and clients are can't access to DB or Executing forever
    This is the first time I met this problem.
    Can Anyone help me to resolved it?
    Thanks in advance!

    xi`tin wrote:
    Hi everyone!
    I have a problem that I don't known the reason why?
    I'm using Oracle version 8i and I want to create a table from another table, such as:You realize, of course, that 8i is completely out of support .... Is your OS and hardware just as old as your rdbms software, or is it only the rdbms that your company refuses to upgrade?
         CREATE TABLE a_backup as SELECT * FROM a => It's OK, table a_backup is created.
    But there is only a table that I can't created like that, such as:
         CREATE TABLE b_backup AS SELECT * FROM b;
    When I run over command, SQL Plus is not responding... and clients are can't access to DB or Executing forever
    This is the first time I met this problem.
    Can Anyone help me to resolved it?
    Thanks in advance!

  • Create table from another db

    Basically, I need to create a table from a query that runs against another db on a separate box. Is this possible?
    Thanks

    If you're able to create a database link to the other server you could then use the query(modifying the tables in the from clause to use the dblink) in a create table statement.

  • Create table from another table including constraints

    Hi,
    Is there a way to create a table from another table including constraints.
    CREATE TABLE COPY_EMP
    as
    SELECT *
    FROM EMP
    WHERE 1 =2 ;
    This creates the table, but the constraints are not copied over.
    I was reading about DBMS_REDEFINITION - can that be used for this scenario ?
    Thanks!
    Anand

    >
    I tried that, but the constraint names are posing a problem. And unfortunately our constraints are not named in a standard, so am finding it difficult to replace them.
    Was just wondering if there were any simpler approach to this.
    >
    No - there isn't.
    You will have to use new names for the constraints. That usually means extracting the DDL and manually changing the constraint names.

  • How to create table from another in pl/sql

    Hi I need to create a table from another in pl/sql
    How can I do this

    The proper way to do this, is not to do it in PL/SQL. But do it in SQL, something like:
    create table tbl
    as
    select *
      from other_tbl;Doing it in PL/SQL is really slow compared to SQL.
    Yes, if you really want to create a table using PL/SQL then you will need to use DBMS_SQL or EXECUTE IMMEDIATE (Native Dynamic SQL) to do this.

Maybe you are looking for

  • Airport Utility can't find Airport Express after setting up as repeater station

    I wanted to extend my 2Wire-based wireless network into a specific room that never seems to be able to pick up the signal, and found the following instructions on how to do so on Apple's website: (note: these instructions were submitted by another us

  • Can I use SSD SATA III to SATA II macbook white 5.2?

    hi all I have macbook white 5.2 use technology HDD SATA2 I want to put SSD SATA 3, and combine HDD Drive. Can I put SSD SATA 3 to SATA 2 HHD. and HDD I wan to put place DVD drive? please share experience :) or mayne have knowledge. about it thank you

  • Auto-save doesn't stop!

    Hello, I'm on AE on adobe CC. While I'm stabilizing shots (using the warp stabilizer), the auto-save function always starts saving my project (during the background analyse), even though I've 1) disabled the auto-save in the preference or 2) put it o

  • Web Application Designer in 2004s has blurry fonts

    Hi We are on SP12.  When changing the fonts to bold in the charts, the fonts are blurry. Anyone had this problem and solved it? Thanks Kristen

  • How to make room for other new threads?

    When I run my program for a relatively long period of time, a memory problem occurs! There are a number of threads in my program running simultaneously (for example 16) created from a single class, and in every one of them, there are two different th