How to assign the variable in the SQL script?

I have the below running to generate the XML from the file.
set long 100
set pages 0
set trimspool on
set serveroutput on
set echo off
set terminal off
variable out CLOB
begin
        pack.proc('&&1','&&2',:out);
end;
/
spool /dir/loc/file1.xml
select :out from dual;
spool off
I'm queue in the order of the coil, the output to a file named file1.xml. I invoke this SQL script from a shell script, I will pass variable association 3rd since the shell script which I want to use in the file ' & & 3'.xml. Help me set this variable to the DIGITAL field in this SQL script and how can I add to the command of the coil?
set long 100
set pages 0
set trimspool on
set serveroutput on
set echo off
set terminal off
variable out CLOB
define var1='&1' -- to allow for more readable code
define var2='&2'
define var3 ='&3'
begin
        pack.proc('&var1','&var2',:out);
end;
/
spool /dir/loc/file&var3..xml -- note the substition variable has  . appended
print out
spool off

------------
Sybrand Bakker
Senior Oracle DBA

Tags: Database

Similar Questions

  • How to assign the next value in the sequence directly in a variable?

    How to assign the next value in the sequence directly in a variable without using a table TWICE in PL/SQL.

    BluShadow wrote:

    How about a quick test on 11g, just to see if you directly select a sequence in a variable is significantly better than the mark of DOUBLE.

    ...

    Nope... no obvious difference.

    This is because there is none: Oracle's SELECT sequence. NEXTVAL FROM DUAL under the covers. The direct assignment is just a convenient encoding for us, but it does not change the work that accomplishes Oracle.

    create sequence s;
    alter system flush shared_pool;
    declare
    l_num number;
    begin
    l_num := s.nextval;
    end;
    /
    select sql_text from v$sql where parsing_schema_name = user;
    
    SQL_TEXT
    Report the number of l_num; begin l_num: = s.nextval; end;
    Select sql_text from v$ sql where parsing_schema_name = user
    Select double S.NEXTVAL
  • How to get the SQL if I get exception

    I get this exception and do not know what was the actual sql with the variables of liaison who was executed.



    sqlmesg = error in the select query to retrieve the segment associated with a pair of cables: ORA-01006: there is no bind variable

    y at - it a way to get the real sql executed so I know what mistake I did.

    I thought your question was about how to view the SQL statement and bind variables in the exception. The answer to that is to put variables in the exception message.

    The root cause of the problem seems to be that your dynamic SQL statement may require 3 or4 variable bind but your USING clause specifies always 4 values if the underlying SQL statement has 3 positions, it will lead to an error.

    Justin

  • How to accept entries of user of the sql script

    I want to create Tablespace using the sql script, but the location of the data file that I need to accept the user. (for the location of the data file).

    How can I accept the user input to pl/sql.

    Example:
      CREATE TABLESPACE  TSPACE_INDIA LOGGING 
         DATAFILE 'H:\ORACLE_DATA\FRSDB\TSPACE_INDI_D1_01.dbf' 
         SIZE 500M  AUTOEXTEND ON NEXT  1280K MAXSIZE UNLIMITED 
         EXTENT MANAGEMENT LOCAL;
    Here, I need to accept the location of the user data file IE: "H:\ORACLE_DATA\FRSDB\TSPACE_INDI_D1_01.dbf".

    Maybe something like this...

    declare
      flocation varchar2(300) := '&Enter_The_Path';
    begin
      EXECUTE IMMEDIATE 'CREATE TABLESPACE SRC_TSPACE_INDIA LOGGING DATAFILE '''||flocation||
                        '\SRC_TSPACE_INDI_D1_01.dbf'' SIZE 500M AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL';
    end;
    

    You will need to properly explain the quotes in your channel and also make sure you have spaces where they should be (for example, after the key word of the DATA file).

    You'd better start with something like this:

    set serverout on
    declare
      flocation varchar2(300) := '&Enter_The_Path';
      v_sql varchar2(32767);
    begin
      v_sql := 'CREATE TABLESPACE SRC_TSPACE_INDIA LOGGING DATAFILE '''||flocation||
               '\SRC_TSPACE_INDI_D1_01.dbf'' SIZE 500M AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL';
      dbms_output.put_line(v_sql);
    end;
    

    and see what SQL it generates. When you're happy it generates a valid statement, then you can replace the statement dbms_output with your immediate statement execution.

  • How to assign the temporary tablespace to a table

    How to assign the temporary tablespace to a table

    temporary tablespace can be attributed to the user.

  • How to import the .sql file in oracle apex?

    I am new to oracle apex...

    How to import the .sql file in oracle apex?

    I have to import a table in apex...

    This script I have to write in the .sql file...

    pls help...

    Published by: 794244 on January 31, 2011 21:31

    Hi Manu

    You can import and browse workshop SQL, SQL Scripts .sql files. If you have multiple SQL statements in your script, make sure that they are separated by the / character

    Andy

  • Effect of NLS_LANG in the SQL scripts

    DB version: 11.2.0.2
    Platform: RHEL 5.6


    We have a software provider who occasionally sends SQL scripts to deploy.

    The scripts contain usually few CFDS and many LMD

    Textpad, I can see, the LMD (inserts, updates) in the SQL Script. It usually contains some non-English characters (Dutch, German, French) as
    'Übersicht Buchungssätze' .
    'Fehler beim Löschen der zugeordneten Referenzen!'
    They always ask us set NLS_LANG as follows.
    export NLS_LANG="AMERICAN_AMERICA.WE8ISO8859P15"
    After INSERTION, I questioned the inserted values of PL/SQL Developer. Values appear exactly as it appears in the SQL Script text file as shown above.
    So, what was the effect of the NLS_LANG setting? What would have happened if I had not set NLS_LANG?


    NLS in the DB Info
    SQL > select * from nls_Database_parameters;
    
    PARAMETER                      VALUE
    ------------------------------ ----------------------------------------
    NLS_LANGUAGE                   ENGLISH
    NLS_TERRITORY                  UNITED KINGDOM
    NLS_CURRENCY                   #
    NLS_ISO_CURRENCY               UNITED KINGDOM
    NLS_NUMERIC_CHARACTERS         .,
    NLS_CHARACTERSET               AL32UTF8
    NLS_CALENDAR                   GREGORIAN
    NLS_DATE_FORMAT                DD-MON-RR
    NLS_DATE_LANGUAGE              ENGLISH
    NLS_SORT                       BINARY
    NLS_TIME_FORMAT                HH24.MI.SSXFF
    NLS_TIMESTAMP_FORMAT           DD-MON-RR HH24.MI.SSXFF
    NLS_TIME_TZ_FORMAT             HH24.MI.SSXFF TZR
    NLS_TIMESTAMP_TZ_FORMAT        DD-MON-RR HH24.MI.SSXFF TZR
    NLS_NCHAR_CHARACTERSET         AL16UTF16
    NLS_DUAL_CURRENCY              ?
    NLS_COMP                       BINARY
    NLS_LENGTH_SEMANTICS           BYTE
    NLS_NCHAR_CONV_EXCP            FALSE
    NLS_RDBMS_VERSION              11.2.0.2.0
    
    20 rows selected.

    If our supplier had chosen to save the script with the UTF-8 encoding, then, we have set NLS_LANG. Right?

    Evil. You need to AMERICAN_AMERICA. AL32UTF8. If you don't set NLS_LANG, it uses default AMERICAN_AMERICA. US7ASCII. Therefore, only pure ASCII 7-bit scripts can be executed in such environment. The Oracle Client does not use the default database character. It uses the platform default (usually US7ASCII) or UTF-16 in the case of JDBC, ODBC (Unicode mode) and ODP .NET pilots.

    -Sergiusz

  • call a batch file in the sql scripts

    Hi friends,
    I'm looking for a way to call any batch file in sql scripts. I avoid using the DBMS_SCHEDULER package because my application server and database server are deparaments.
    I use the sql script using the server.plz application.


    Ah, I see. Of course, this explains everything.

    Now to be serious: there is no way to run a batch SQL script. The Tools that present SQL statements to the database are often able to do; host in SQL * Plus may issue commands to the OS, the host of builtin forms is it too and with dbms_scheduler , you can run a shell script on the database server.

    So depending on the tools you use, there are several ways to run the OS commands. So far you didn't tell us what you want to do with what tools in the version you want to do. So to only answer is: it is not possible. You cannot run a simple SQL command script.

    see you soon

  • How to assign the variable element of dynamic page?

    Hello

    I am facing following problem:
    I need assign a variable with a value of a page element - for example apex_application.g_f04 (i).
    My problem is, that f04 maybe everthing between f04 and f52 (or whatelse was number of page elements?).
    I've tried several things, among others, something like this:

    v_test: = apex_application.g_f | x | (i) / * where x can be another variable * /.

    or

    v_stat: = 'SELECT apex_application.g_f ' | x | "(i) the double '.
    EXECUTE IMMEDIATE v_stat INTO v_test

    but I do not understand so far...
    Any ideas?

    Published by: DFiles on 06.01.2011 13:57

    apex_application.g_f0x variable package are associative arrays and are not accessible to the dynamic SQL. You must use the dynamic PL/SQL:

    declare
    
      i pls_integer;
      x pls_integer;
      v varchar2(32767);
    
    begin
    
      /* However you get values for x and i... */
      i := 1;
      x := 4;
    
      execute immediate 'begin :1 := apex_application.g_f' || to_char(x, 'fm09') || '(:2); end;'
        using out v, i;
    
      return v;
    
    end;
    
  • How to assign the value to the variable of project in the Jython script

    Hello

    I want to assign a value to the variable of project in the jython script.
    I tried to assign the following, but it is throwing some errors.

    < @.
    int noOfRecords = 10;
    #var1 = noOfRecords;
    @ >


    Can you please help me in this regard.

    Concerning
    Shyam

    Perfect! Good to know that!

    Please, don't forget to close the thread and assign the status to 'correct' or 'comfortable' to each response that helped you!

    Thank you

    Cezar Santos
    http://odiexeperts.com

  • How to assign the ID of group for each group in the SQL query.

    Hi all

    I want to assign the ID of group for each group (group ID of series). I tried with the row_number function but did not work for my requiredment. Here is my sample data and my requirement.

    Col1
    A
    A
    A
    A
    A
    B
    C
    D
    D
    D
    D
    E
    E
    E
    F
    G
    G
    G

    I want to get number of each column with ID group assign to it value. Here is my example output

    Col1 County Group ID
    A 5 1
    A 5 1
    A 5 1
    A 5 1
    A 5 1
    B 1 2
    C 1 3
    D 4 4
    D 4 4
    D 4 4
    D 4 4
    E 3 5
    E 3 5
    E 3 5
    F 1 6
    G 3 7
    G 3 7
    G 3 7

    Select col1, count (1) NTC (col1 partition).

    ROW_NUMBER() over (partition by col1 by col1 order) tbl_test grp_id.

    Please help me solve this problem.

    SELECT

    COL1,

    COUNT (*) ON MYCOUNT (COL1 PARTITION).

    DENSE_RANK () OVER (ORDER BY COL1) GROUPID

    Of

    T1;

  • How to assign the value to the application-level element

    Hello

    I'm learning to APEX.  I use version 4.2.6.

    My question is, I set a text field called 'FINANCIAL_YEAR' in the login page.  I wanted to know how to assign this value to a text element of Application level (on page sent), so that I can get this value through at my request.

    Thank you

    -Anand

    anand_gp wrote:

    Yes, I created a 'text area' under 'HTML' in the 'Home' page  Who accepts the exercise of a table through LOV.  I intend to assign this value to a global variable so that this variable can be read in any of the application to filter the result set from different tables (not yet built the rest of the application).  To do this, I was intending to use "Shared components"-> "Elements of Application".  I'm still not quite sure how it works.

    Start by reading the documentation on elements of application.

    Go to the shared components > Application parts and create your G_FINANCIAL_YEAR item. Value Session State Protection Restricted - can not be set the browser so that the value is not editable by the user, falsification of URLS or scripts.

    On the home page, if there is not already a button to submit the value of the fiscal year, add one in the HTML area, with the Action as a submit Pageclick. Otherwise, you can do without the button and using submit Page in Page Action when the changed value select the parameter in the list so he can undergo.

    Then, in the section of the Page processing, create a calculation:

    Point Type: Application-level element

    Calculate Item: Application: G_FINANCIAL_YEAR

    Point calculation: After submit

    Type of calculation: Value of the element

    Calculation:

    Run the application, select a value in the list of the fiscal year and submit the page. Review of current session state in the viewer of session state by clicking on the link of Session in the toolbar developer. Select the Elements of Application in the view list, and then click set. The element of your application and its current value must be visible. You can now reference value throughout your application by using the appropriate syntax.

    You should also consider if a default value (for example the current year) using a calculation Application from the point of calculation on the new Instance and coordinate the application point and part of the homepage using point application as the Source of value or an expression with Source page element, the value always, replacement of value that exists in the session state.

  • How to get the sql query result?

    Hello

    Currently I use LV2012 to connect to an Oracle database server. After the Oracle Express and Oracle ODBC driver facilities/settings made.

    I managed to use the SQL command to query the data through my command prompt window.

    Now the problem is, how to do the same task in Labview using database connectivity tools?

    I have build a VI to query as being attached, but I have no idea of what range to use to get the result of the query.

    Please help me ~ ~

    Here is a piece of code that I use to test the SQL commands, you can use the part that retrieves the results of sql.

    It is also possible to get the rear column headers, but it's for the next lesson!

    ;-)

  • T440p how to assign the new function to a certain key?

    I have a T440p and I was wondering if anyone knows how to change the function of a key on the keyboard? I want to assign a different function to one of the 'F' keys Thank you!

    Try KeyTweak (re) Mapper tool or the same.

  • How to assign the TAB sequence?

    Hey...

    Can someone tell me how to assign tab...? I mean if I have a few buttons and controls on the front panel are trying to view the login Panel; whenever I press TAB on the keyboard, I want that the selection of buttons & controls should be in order... Can someone tell me how...?

    See the order of Edit\Tabbing, and with the right button on the control of Navigation Advanced\Key

    See you soon!

Maybe you are looking for