How to use parameters in oracle SQL script????

Right now I am writing a SQL script to create a schema and build the objects of this schema....
I use a .net winform program to run sqlplus to parse this sql script ...
The problem is that the schema name and the tablespace's location and the sys password must be input by the user, so my SQL script should use these runtime input parameters instead of const parameters....
So, how to use parameter in SQL script ...........
Are there some example scripts in oracle home directory for me to refer to????

Hi,
UNISTD wrote:
thanks .....
what's the difference between variable , define, accept in sqlplus ???VARIABLE declares (but does not assign a value to) a bind variable. Unlike substitution variables, bind variables are passed to the back end to be compiled, and they can only be values in certain data types. You can not use a bind vaiable in place of an identifier, so to do something like
CREATE USER  &1 ...a bind variable won't work.
"DEFINE x = y" sets the substitution variable &x to have the value y. There is no user interaction (unless x or y happen to contain undefined substtiution variables).
"DEFINE x" shiows the value of the substitution variable &x, or, if it is undefined, raises a SQL*Plus error. I use this feature below.
ACCEPT sets a substitution variable with user interaction.
And if the user miss some parameters in “sqlplus /nolog ssss.sql par1 par2 par5 par6”, how to use default value of the miss parameters??Don't you need a @ befiore the script name, e.g.
sqlplus /nolog @ssss.sql par1 par2 par5 par6Sorry, I don't know of any good way to use default values.
The foloowing works, but, as you can see, it's ugly.
"DEFINE 1" display a message like
DEFINE 1            = "par1" (CHAR)if &1 is defined; otherwise,it will display a SQL*Plus error message like
SP2-035: symbol 1 is UNDEFINEDNotice that the former contains an '=' sign, but the latter does not.
The best way I know to use default values is to run the DEFINE command, save the output to a filee, read the file, and see if it's an error message or not.
So you can use a script like this:
--     This is  DEFINE_DEFAULT.SQL
SPOOL     got_define_txt.sql
DEFINE     &dd_old
SPOOL     OFF
COLUMN     dd_new_col     NEW_VALUE     &dd_new
WITH     got_define_txt     AS
     SELECT  q'[
          @got_define_txt
]'               AS define_txt
     FROM    dual
SELECT     CASE
         WHEN  define_txt LIKE '%=%'
         THEN  REGEXP_REPLACE ( define_txt
                           , '.+"
([^"]*)
                     , '\1'
         ELSE  '&dd_default'
     END        AS dd_new_col
FROM     got_define_txt
{code}
and start your real script, ssss.sql, something like this:
{code}
DEFINE          dd_new     = sv1
DEFINE          dd_old     = 1
DEFINE          dd_default     = FOO
@DEFINE_DEFAULT
DEFINE          dd_new     = sv2
DEFINE          dd_old     = 2
DEFINE          dd_default     = "Testing spaces in value"
@DEFINE_DEFAULT
{code}
when this finishes running, the substitution variable &sv1 will either have the value you passed in &1 or, if you didn't pass anything, the default value you specified, that is FOO.
Likewise, &sw2 will have the value you passed, or, if you didn't pass anything, the 23-character string 'Testing spaces in value'.
Here's how it works:
Define_default.sql puts the output of the "DEFINE x" command into a column, define_txt, in a query.  That query displays either the existing value of the substitution variable indicated by &dd_old or, if it is undefined, the default value you want to use, which is stored in the substitution variable &dd_default.  The substitution variable named in &dd_new is always set to something, but that something may be its existing value.
Notice that the paramerters to define_default.sql must be passed as global varibales.
Why didn't I just use arguments, so that we could simply say:
{code}
@DEFINE_DEFAULT  sv1  1  FOO
{code}
?  Because that would set the substitution variables &1, &2 and &3, which are miost likely the very ones in which you're interested.
I repeat: there must be a better way, but I'm sorry, I don't know what it is.
I usually don't do the method above.  Instead, I always pass the required number of parameters, but I pass dummy or plce-holder values.
For example, if I wanted to call ssss.sql, but use defulat vlaues for &1 and &3, then I would say something like:
{code}
@ssss  ?  par2  ?
{code}
and, inside ssss.sql, test to see if the values are the place holder '?', and, if so, replace them with some real default value.  The use has  to remember what the special place holder-value is, but does not need to know anything more, and only ssss.sql itself needs to change if the default values change.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Similar Messages

  • How to use OEM to moniter sql server 2000

    Hi,
    I need to learn How to use OEM to moniter sql server 2000.
    Can anyone help me and give me some website or documents
    to read?
    So I can learn to do this job.
    Thanks.

    See Note 115302.1 in Metalink.oracle.com
    in how to use OEM Diagnostic pack addon for SQL Server
    Or search for
    oem "user events"
    to build your own monitor script.

  • Can we use different Databases (Oracle & SQL Server) in one report?

    Post Author: venki5star
    CA Forum: .NET
    Hi there.
    Can we use different databases (Oracle & SQL Server) in a same report?
    If possible how?
    Another question,
    Can we change the Provider Name at runtime of the given report. If so the above question is useless...
    Thanks in Advance.

    I tried this using Oracle Provider for OLEDB (the one that supplied by Oracle Client) and Crystal Reports 9. you can drag the column into designer but the image does not appear in preview.
    I guess it's because CR does not recognized it as image, and there are no information that the blob data is an image at all.

  • How to use perform statements in sap scripts

    how to use perform statements in sap scripts . and pls send me one progam for this
    thnaks
    raja

    Hi Raja,
    <b>PERFORM</b> key work is used to include subroutine in sapscript form...
    But the processing is lttle bit different form the one we use in ABAP.
    Here the paramters passed to form is stored in internal table of name-value table. there are two table one for inbound parameter and other for outbound parameters.
    Check out the example below to see how this is used..
    <b>Definition in the SAPscript form:</b>
    /: PERFORM GET_BARCODE IN PROGRAM QCJPERFO
    /: USING &PAGE&
    /: USING &NEXTPAGE&
    /: CHANGING &BARCODE&
    /: ENDPERFORM
    / &BARCODE&
    <b>Coding of the calling ABAP program:</b>
    REPORT QCJPERFO.
    FORM GET_BARCODE TABLES IN_PAR STUCTURE ITCSY
    OUT_PAR STRUCTURE ITCSY.
    DATA: PAGNUM LIKE SY-TABIX, "page number
    NEXTPAGE LIKE SY-TABIX. "number of next page
    READ TABLE IN_PAR WITH KEY ‘PAGE’.
    CHECK SY-SUBRC = 0.
    PAGNUM = IN_PAR-VALUE.
    READ TABLE IN_PAR WITH KEY ‘NEXTPAGE’.
    CHECK SY-SUBRC = 0.
    NEXTPAGE = IN_PAR-VALUE.
    READ TABLE OUT_PAR WITH KEY ‘BARCODE’.
    CHECK SY-SUBRC = 0.
    IF PAGNUM = 1.
    OUT_PAR-VALUE = ‘|’. "First page
    ELSE.
    OUT_PAR-VALUE = ‘||’. "Next page
    ENDIF.
    IF NEXTPAGE = 0.
    OUT_PAR-VALUE+2 = ‘L’. "Flag: last page
    ENDIF.
    MODIFY OUT_PAR INDEX SY-TABIX.
    ENDFORM.
    Hope this is clear to understand...
    Enjoy SAP.
    Pankaj Singh.

  • How to see dbms_output on oracle sql developer

    ned immediate help
    how to see dbms_output on oracle sql developer

    Hi,
    In sql developer u have a tab named DBMS Output in your result sheet. In that the first Icon is Enable DBMS Output. turn it on (After on it will give the message set serveroutput on in the sheet) and then run your code.
    In the code u have to use the dbms_output.put_line package.after running the code u have to see the result in DBMS Output tab.
    Regards,
    NTR

  • How to see history in Oracle SQL

    how to see history in Oracle SQL
    i.e
    create table.....
    select * from tablename....
    delete tablename;
    Now i want to see how many command run after login.......please tell me the command...

    user12261139 wrote:
    how to see history in Oracle SQL
    i.e
    create table.....
    select * from tablename....
    delete tablename;
    Now i want to see how many command run after login.......please tell me the command...I'm not aware of an easy way to see how many commands were run after logging on. Different tools have different capabilities, though.
    The ms-dos version of SQL*PLUS offers a Doskey option to use the up and down arrows to recover recently executed commands.
    The SQL Workshop in Apex has a command history. Some of the GUI tools might offer similar functionality.

  • Send mails with csv file as an attachment through oracle(SQL SCripts / Stor

    Hello Everybody,
    I have recently come across a requirement in which I am supposed to send mails with csv file as an attachment through oracle(SQL SCripts / Stored Procedure) .
    The contents of the csv file are to be retreived from the Database as well as the content of the mail and to whom it needs to be sent has also to be picked up from the database.
    Can somebody suggest me with a suitable code for the same?
    Would be of great help..!!
    Thanks & Regards,
    - VR
    Edited by: user646716 on Dec 18, 2009 10:44 AM

    read below links
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:255615160805
    http://www.orafaq.com/wiki/Send_mail_from_PL/SQL#Send_mail_with_UTL_TCP_-withattachments
    How to send csv file as an attachment

  • How to use iframes in oracle 10g

    I have to load two jsp pages in a single html . I have done that thru iframes. But i have to dynamically load the second jsp page in the frame 2 , when the user clicks upon certain details in the frame 1 jsp page. I have wriiten the code of document.iframe in format trigger attribute. It doesn't work. Is there any other way to achieve this. I want to load the frame 2 jsp page dynamically , according to the input i get from frame 1 jsp page.

    Hi,
    >>Anybody know how to use profiler in oracle 10g
    What do you mean "profiler". About Resource Limits/Create Profiles ?
    >>i couldn't able to install the enterprise manager console.
    What OS ?
    >>because i need to trace the execution of a stored procedure.waiting the reply.
    Debug ? You can use SQL Developer, TOAD, PLSQL Developer for this purpose.
    Cheers

  • How to Use Profiler in ORACLE 10g

    Hi all,
    Anybody know how to use profiler in oracle 10g and also i couldn't able to install the enterprise manager console.is there any tools available for that.because i need to trace the execution of a stored procedure.waiting the reply.
    Sathish

    Hi,
    >>Anybody know how to use profiler in oracle 10g
    What do you mean "profiler". About Resource Limits/Create Profiles ?
    >>i couldn't able to install the enterprise manager console.
    What OS ?
    >>because i need to trace the execution of a stored procedure.waiting the reply.
    Debug ? You can use SQL Developer, TOAD, PLSQL Developer for this purpose.
    Cheers

  • How to use IF Conditon in SAP Scripts?

    Hi Guys,
                   I am having adoubt how to use IF conditon with multiple variables in SAp Scripts
    for ex If a>b and a>c and a>d
             Elseif b>a and b>c and b> d.
             Elseif .....
              endif.
              How to use above example in SAP Scripts.
    thanks,
    Gopi.

    hi Gopi,
    it is almost the same as normal ABAP, you only have to use & before and after the variable and the variable has to be in capitals and you have to make the line as command ( /: before the line )
    IF &A& > &B& AND ...
    text to print
    ELSEIF ...
    text to print
    ENDIF.
    hope this helps
    ec

  • How to define variables in toad sql script editor - newbie

    I have just pull out the script of a Function and want to run it on toad SQL editor.
    I am little bit confused how to define the VARIABLEs here in toad SQL editor to run my script.
    SELECT
    NVL(SUM(debit), 0) - NVL(SUM(credit), 0)
    INTO l_accountBalance
    FROM
    GLP_VoucherMaster vm
    INNER JOIN GLP_VoucherDetail vd ON vm.GLP_VoucherMaster_ID = vd.GLP_VoucherMaster_ID
    INNER JOIN GLP_ChartOFAccounts coa ON vd.GLP_ChartOfAccounts_ID = coa.GLP_ChartOfAccounts_ID
    WHERE
    vm.isActive = 'Y' AND vd.isActive = 'Y'
    -- *** how to define variables in toad sql script editor ***
    AND vm.voucherDate < p_cDate
    AND coa.AccountCode LIKE p_accountCode || '%';
    Thanks
    w\

    Just prefix with a colon (:)
    SELECT   NVL (SUM (Debit), 0) - NVL (SUM (Credit), 0)
      INTO   L_accountbalance
      FROM           Glp_vouchermaster Vm
                 INNER JOIN
                     Glp_voucherdetail Vd
                 ON Vm.Glp_vouchermaster_id = Vd.Glp_vouchermaster_id
             INNER JOIN
                 Glp_chartofaccounts Coa
             ON Vd.Glp_chartofaccounts_id = Coa.Glp_chartofaccounts_id
    WHERE       Vm.Isactive = 'Y'
             AND Vd.Isactive = 'Y'
             AND Vm.Voucherdate < :P_cdate
             AND Coa.Accountcode LIKE :P_accountcode || '%';
    /:p

  • How to use perform and endperform in scripts

    Can anybody cleaerly explains me how to use perform and endperform in scripts with an example to add something extra dynamically to the standard script (like rvorder01).
    thanks in advance.
    regards
    anil.

    Check this example:
    In form
    PERFORM READ_TEXTS IN PROGRAM 'Z08M1_FORM_EKFORM1'
    USING &EKKO-EKORG&
    USING &EKPO-WERKS&
    USING &EKKO-EKGRP&
    USING &EKKO-BSTYP&
    CHANGING &COMPNAME&
    CHANGING &SENDADR&
    CHANGING &INVCADR&
    CHANGING &COMPADR&
    CHANGING &COVERLTR&
    CHANGING &SHIPADR&
    CHANGING &REMINDER&
    CHANGING &REJECTION&
    CHANGING &POSTADR&
    CHANGING &LOGO&
    ENDPERFORM
    In program
    FORM READ_TEXTS TABLES IN_PAR   STRUCTURE ITCSY
                           OUT_PAR  STRUCTURE ITCSY.
      DATA : L_EKORG TYPE EKORG,
             L_WERKS TYPE WERKS_D,
             L_BSTYP TYPE BSTYP,
             L_EKGRP TYPE BKGRP.
      READ TABLE IN_PAR WITH KEY 'EKKO-EKORG' .
      CHECK SY-SUBRC = 0.
      L_EKORG = IN_PAR-VALUE.
      READ TABLE IN_PAR WITH KEY 'EKPO-WERKS' .
      CHECK SY-SUBRC = 0.
      L_WERKS = IN_PAR-VALUE.
      READ TABLE IN_PAR WITH KEY 'EKKO-EKGRP' .
      CHECK SY-SUBRC = 0.
      L_EKGRP = IN_PAR-VALUE.
      READ TABLE IN_PAR WITH KEY 'EKKO-BSTYP' .
      CHECK SY-SUBRC = 0.
      L_BSTYP = IN_PAR-VALUE.
      CLEAR Z08M1_ORG_TEXTS.
      SELECT SINGLE * FROM Z08M1_ORG_TEXTS WHERE EKORG = L_EKORG
                                              AND WERKS = L_WERKS
                                              AND EKGRP = L_EKGRP
                                              AND BSTYP = L_BSTYP.
      IF SY-SUBRC NE 0.
        SELECT SINGLE * FROM Z08M1_ORG_TEXTS WHERE EKORG = L_EKORG
                                               AND WERKS = L_WERKS
                                               AND EKGRP = L_EKGRP
                                               AND BSTYP = SPACE.
      ENDIF.
      READ TABLE OUT_PAR WITH KEY 'COMPNAME'.
      OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_COMP.
      MODIFY OUT_PAR INDEX SY-TABIX.
      READ TABLE OUT_PAR WITH KEY 'SENDADR'.
      OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_ADRS.
      MODIFY OUT_PAR INDEX SY-TABIX.
      READ TABLE OUT_PAR WITH KEY 'INVCADR'.
      OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_INVC.
      MODIFY OUT_PAR INDEX SY-TABIX.
      READ TABLE OUT_PAR WITH KEY 'COMPADR'.
      OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_CPAD.
      MODIFY OUT_PAR INDEX SY-TABIX.
      READ TABLE OUT_PAR WITH KEY 'COVERLTR'.
      OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_COVR.
      MODIFY OUT_PAR INDEX SY-TABIX.
      READ TABLE OUT_PAR WITH KEY 'SHIPADR'.
      OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_SHIP.
      MODIFY OUT_PAR INDEX SY-TABIX.
      READ TABLE OUT_PAR WITH KEY 'REMINDER'.
      OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_RMDR.
      MODIFY OUT_PAR INDEX SY-TABIX.
      READ TABLE OUT_PAR WITH KEY 'REJECTION'.
      OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_RJCT.
      MODIFY OUT_PAR INDEX SY-TABIX.
      READ TABLE OUT_PAR WITH KEY 'POSTADR'.
      OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_POST.
      MODIFY OUT_PAR INDEX SY-TABIX.
      READ TABLE OUT_PAR WITH KEY 'LOGO'.
      OUT_PAR-VALUE = Z08M1_ORG_TEXTS-TXT_LOGO.
      MODIFY OUT_PAR INDEX SY-TABIX.
    ENDFORM.
    Check and let me know if u face any problem.
    Regards

  • How to use css in oracle forms

    Hello,       I am using oracle forms 11g with weblogic server 10.3.5 at windows 7.I have to use CSS in oracle forms.i have tried to search it but no profit.please some one else tell me that how can use css in oracle forms. Thnak You regards aaditya

    Hi
    As Francois pointed out Oracle forms has nothing to do with html based technology. The way you can get the equivalent effect of creating consistancy in the way your objects are displayed is by creating a set of items you want and alter their apperance and behaviour and place them into object libraries (one library should do the trick).  From there you subclass all of you forms items off these libraries.
    Regards
    Quintin

  • How can I extract the full SQL script for a schema?

    Hi,
    How can I extract the full SQL script for a schema?
    I am looking for some method that needs jus SQL*Plus and preferably doesn’t need any extra tool.
    Thank you,
    Alan

    How can I extract the full SQL script for a schema?What are you looking for? PL/SQL code? DDL for objects?

  • How can I convert a mysql sql script to a oracle sql script

    Hi,
    We have a bunch of tables with data running on a mysql server.
    This should now be moved to an oracle 9 db.
    are there any tools to convert the import script of a mysql db
    to a format of the sql script that work for oracle ?
    Thanks
    Michael

    Oracle has a tool called Migration Toolbench, which supports MySQL 3.22 and 3.23:
    http://otn.oracle.com/tech/migration/workbench/content.html
    On this same topic, I was wondering if anybody has tried migrating from PostgreSQL to Oracle 9i. The workbench doesn't seem to support it, and feeding a pg_dump file directly into SQL*Plus is not working.

Maybe you are looking for

  • Downloading music and videos from more than one iTunes account

    We have ipads for our two granddaughters and each has an itunes account and we give them allowances and gifts now and then to buy videos music and apps. They have each bought more stuff than they can fit on their ipad.  I bought an external hard driv

  • Error message: incompatible image size when using IMAQ in image processing

    I want to do low pass filter and convolution on an acquired image. When I connect the image to the VI, the message: incompatible image size appears. I have tried to set the border to 3 in IMAQ create, but it does not help. Anyone know how to solve th

  • Integration with Ariba

    Hello, Does anybody worked with integration of SAP R/3 with Ariba.  Can I get some documentation over that. Rgds, Mallik

  • Question about 1055T and 785G-E53 Board

    I recently purchased a 1055T and 785G-E53 through a very good combo deal at a local computer store.  I know that the motherboard requires BIOS version 3.5 in order to be compatible with the 6-core processors.  However, from what I have read, it is li

  • HP Application LifeCycle Management - URL for use with another Project Management Tool

    I'm trying to find a way to get a ALM Requirement URL that will work with other applications.  The URL from the COPY URL option (when right-clicking on the requirement) works for e-mails but I can't seem to get it to work for another project manageme