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

Tags: Database

Similar Questions

  • 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.

  • 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 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

  • How to pass arguments to the SQL Script in command prompt

    I don't know about the ' & nom_de_variable "to request a value in the command line.

    But, how can I pass arguments from the command line for the following script to the command - prompt

    Example:

    ex_proc. SQL

    CREATE OR REPLACE PROCEDURE ex_proc (employee_id NUMBE IN)
    IS
    v_emp_id Number (38);
    BEGIN

    v_emp_id: = employe_id;

    UPDATE emp_employee SET sal = 2000 WHERE emp_id = v_emp_id;

    END;
    /


    call_ex_proc. SQL

    Appellant for procedure above:

    BEGIN

    ex_proc (100); -The employee id is 100.

    END;
    /

    Here are the General controls that we use to run the scripts above-

    SQL > @ex_proc.sql

    SQL > @call_ex_proc.sql



    But my requirement is to pass the employee id as an argument in the command line as.
    SQL > @call_ex_proc.sql 100

    Is it possible to pass command line arguments?

    Usually this question start with reading documentation, wouldn't it?

    Solomon Yakobson showed you the method gross and unreadable.

    You will use best

    set = '& 1' '.

    -use & in the rest of the code

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

  • Insert the SQL script for BLOBs

    Hello

    I managed to upload my word and pdf documents in the database using blob support APEX and have these columns in the MY_DOC table

    , VARCHAR2 (400) FILE NAME NOT NULL
    BLOB_CONTENT BLOB
    , VARCHAR2 (48) MIME_TYPE

    Now I want to migrate the data to another environment by using an insert SQL script, how to respond to the BLOB column in the insert script?

    Kind regards

    ADE

    You cannot migrate data blob with insertion of scripts. However, you can achieve this by using the datapump...

    Example:

    expdp sysadm/sysadm tables = dumpfile = dump.dmp logfile = expdp_dump.log patterns =
    Impdp sysadm/sysadm dumpfile = dump.dmp

    BR,

    Nico

  • either or in the sql script

    Hi all

    Oracle db 10g

    I have a sql script that is like
    CURSOR c IS
    select s.sid,s.serial#
              from gv$session s, gv$process p, gv$locked_object l
                where l.session_id = s.sid
                and floor(mod(last_call_et,3600)/60) > 3
                and l.object_id in (438239,332790,46237,362927)
                and s.module in ('JSWPKSLIPN','OEXOEORD','ICPCKLOT','JSWPKSHIPHRM','JAINEORD')
                and s.status='INACTIVE'
                and s.paddr = p.addr;
    
    c_row c%ROWTYPE;
    
    l_sql VARCHAR2(100);
    
    BEGIN
    
    OPEN c;
    
    LOOP
    FETCH c INTO c_row;
    EXIT WHEN c%NOTFOUND;
    l_sql := 'alter system kill session '''||c_row.sessionid||','||c_row.serialid||'''';
    EXECUTE IMMEDIATE l_sql;
    END LOOP;
    
    CLOSE c;
    END;
    /
    In the above script as I must include conditions
    s.module in ('JSWPKSLIPN','OEXOEORD','ICPCKLOT','JSWPKSHIPHRM','JAINEORD') and
    s.last_call_et/1800 > 1
    and
    s.action like 'FRM%'
    and
    s.status='INACTIVE'
    So that the cursor c gets all the inactiive and serial No. session id and put loop and kills the session... ? He must check the two conditions and if any condition returns the lines, he should kill?

    Thank you
    Baskar.l

    Loops of slider like the one you posted since out-of-date Oracle 8i over 12 years ago.

    Learn how to process rows tables not simple.
    http://www.morganslibrary.org/reference/array_processing.html

  • Where the SQL Scripts running after the installation of the ODAC for Oracle Client?

    I just installed ODAC for Oracle Client on a windows server that runs a database of sql server, allowing developers to connect to a web application to an Oracle/Unix database. The installation States to run SQL scripts, located in the $ORACLE_HOME\ASP.NET\SQL directory after installation. I don't know where to run them? On the ORACLE DB on the Unix server? If someone could let me know, I'd appreciate it. Thank you.

    You must run on the Oracle database server, but they are necessary only if you use Oracle for ASP.NET providers.

    If you just install the software, so you can use OLEDB with SQL Server linked server, for example, you don't need them. What do you need to run although if this is the case is the oramtsadmin.sql script that creates the objects used by the Oracle MTS Recovery Service (if you do not have these objects created on the database) that SQL Server uses a distributed transaction for Oracle connections I think.

    It will be useful,
    Greg

  • Compensation of the sequences, run the sql script

    Hello

    I use OWB 10.1.0.4.0 and I use a sequence to create a surrogate key in my paintings. For the tabels deleted during the process, I want these sequences set to 1 again.

    Is it possible to run an sql script in a mapping or the flow of process (with a drop, create, grant the declaration for the sequence)?

    Thanks in advance,

    Arjan

    Write these SQL statements in a procedure and the procedure in the import map.

  • delay the SQL script

    Hello

    I use oracle10g (10.2.0.4) in windows xp service pack 2. I create a batch file and I want to as the next line of my script to run within a period of 5 to 10 seconds. can someone help me do the command in windows?

    Syntax SQL * Plus on Windows is:

    host sleep 
    

    A better solution would be to use DBMS_LOCK. SLEEP because it is a PL/SQL package that runs in the database and do not depend on some OS executable.

    Edited by: P. Forstmann on 28 Dec. 2010 08:50

  • Automate the sql script

    I have a simple select statement that should be automated (execution per day) in an oracle database. It essentially selects data in multiple tables and the resulting data then fill an excel file. How to achieve them.

    I guess I can write a cron job. Are there other ways easirer to do? Can I do this using the OEM?

    Thank you!

    You can use DBMS_JOB / DBMS_SCHEDULER to automate one of the PL/SQL solutions, Yes. If you do not specifically need an Excel file and need a source for DTS, you can certainly write a small procedure that stores the results of a query in a table and then use DTS to extract the data from the Oracle table.

    Justin

  • Detection of parameter NLS_LANG clientside in SQL * more script

    Our company has developed an application that uses an Oracle database as backend. Companies can purchase our application and run it against their own installation of Oracle.

    A new version of our application often requires an update to the Oracle database schema.
    As well as from new application files, we send our customers an update.sql script, they must run to their database using SQL * more.
    This update script can contain international characters such as é for example:
    UPDATE SHOPS SET DESCRIPTION = 'Café'
    WHERE SHOP_ID=1
    Save us the SQL script file in the windows-1252 encoding the character e is encoded by 0xE9 in the script file.

    When the ADMINISTRATOR runs him upgrade script is set NLS_LANG =. WE8MSWIN1252 it works perfectly.
    When the ADMINISTRATOR has set the NLS_LANG = US7ASCII the e is replaced by an exclamation mark the upside. Other NLS_LANG settings can also be embarrassing.

    To avoid this, we give very clear instructions. However, nobody reads. This raises two questions:

    (A) is there a way to prevent this problem, so I do not the parameter NLS_LANG by the DBA to run the upgrade script depend on?
    (B) otherwise: is there a way to test the NLS_LANG setting in the script and give up if it's not WE8MSWIN1252?

    Info:
    Database is 10.2.0.3/10.2.0.4 and sometimes 10.2.0.5, always the database character set WE8MSWIN1252.
    Client software: I don't know what are the uses each s/n, but it will be mainly the software client 10g
    Client OS: Some DBA will run the script from Windows, others of some varieties of Unix. I can't control that.

    (A) is there a way to prevent this problem, so I do not the parameter NLS_LANG by the DBA to run the upgrade script depend on?

    Yes. Use the UNISTR function to encode strings with Unicode, for example UNSITR('\00e9') exhausts to code 'e '. The set conversion implicit character in the set to the national character of database character set will do. You can use the ASCIISTR function to simplify the creation of arguments to UNISTR based on the input text.

    -Sergiusz

  • How to format the output of a .sql script that has select statements.

    Hello

    I have a .sql script which is having several select statements. Each Select statement is to have hundreds of Table columns.

    When we run the .sql script, we are unable to read the output.

    Please let know us the commands that we include for better readable output format.

    You work with the lin standard set 80.
    Increase this setting to set lin 3000 or more.

  • Convert the Sql for Oracle script

    Could someone help me convert the sql script in oracle below

    -- EXEC SP_smpAGENCY_MYWS_LAPSE_GET_USP_AMSurrenderMngtReport '2005','2010','09048','IL'    
    ALTER PROCEDURE SP_smpAGENCY_MYWS_LAPSE_GET_USP_AMSurrenderMngtReport    
    --DECLARE     
    @StartYY AS VARCHAR(4),    
    @EndYY AS VARCHAR(4),    
    @AgentCode AS VARCHAR(9),    
    @CompanyCode AS VARCHAR(4)    
        
    AS    
        
    DECLARE @ProfileYYYYMM AS VARCHAR(6), @SQLStr1 AS VARCHAR(8000),@SQLStr2 AS VARCHAR(8000), @SQLStr3 AS VARCHAR(8000)    
        
    SET @ProfileYYYYMM = '201005'    
        
    SET @SQLStr1 = ''    
        
    SET @SQLStr1 = @SQLStr1 + ' DECLARE @CompAvgCount AS  DECIMAL(38,2), @CompAvgAP AS  DECIMAL(38,2), @CompInforceAP AS DECIMAL(15,2), @CompSurrenderAP AS DECIMAL(15,2), '    
    SET @SQLStr1 = @SQLStr1 + ' @CompInforceCount NUMERIC, @CompSurrenderCount NUMERIC,@ALCompInforceAP AS DECIMAL(15,2), @ALCompSurrenderAP AS DECIMAL(15,2), '    
    SET @SQLStr1 = @SQLStr1 + ' @ALCompInforceCount NUMERIC, @ALCompSurrenderCount NUMERIC,@ILCompInforceAP AS DECIMAL(15,2), @ILCompSurrenderAP AS DECIMAL(15,2), '    
    SET @SQLStr1 = @SQLStr1 + ' @ILCompInforceCount NUMERIC, @ILCompSurrenderCount NUMERIC '    
      
    SET @SQLStr1 = @SQLStr1 + ' DECLARE @tblAgentNumber TABLE '    
    SET @SQLStr1 = @SQLStr1 + ' ( '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentName] VARCHAR(255), '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentNumber] VARCHAR(9), '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentRank] VARCHAR(10) '    
    SET @SQLStr1 = @SQLStr1 + ' ) '    
      
    SET @SQLStr1 = @SQLStr1 + '  DECLARE @tblmineInForce TABLE '    
    SET @SQLStr1 = @SQLStr1 + ' ( '    
    SET @SQLStr1 = @SQLStr1 + '  [company_code] VARCHAR(50), '    
    SET @SQLStr1 = @SQLStr1 + '  [mine_policy_no] VARCHAR(50), '    
    SET @SQLStr1 = @SQLStr1 + '  [Annl_premium] NUMERIC(28, 2) '    
    SET @SQLStr1 = @SQLStr1 + ' ) '    
        
    SET @SQLStr1 = @SQLStr1 + ' DECLARE @tblmineSurrender TABLE '   
    SET @SQLStr1 = @SQLStr1 + ' ( '    
    SET @SQLStr1 = @SQLStr1 + '  [company_code] VARCHAR(50), '    
    SET @SQLStr1 = @SQLStr1 + '  [mine_policy_no] VARCHAR(50), '     
    SET @SQLStr1 = @SQLStr1 + '  [Annl_premium] NUMERIC(28, 2) '    
    SET @SQLStr1 = @SQLStr1 + ' ) '    
        
    SET @SQLStr1 = @SQLStr1 + ' INSERT INTO @tblAgentNumber '    
    SET @SQLStr1 = @SQLStr1 + ' SELECT AgentName, AgentNumber, AgentRank '    
    SET @SQLStr1 = @SQLStr1 + ' FROM [SUMYOLAP0001].aetnaildb.dbo.agentprofile'+ @ProfileYYYYMM +' AgtProfile '    
    SET @SQLStr1 = @SQLStr1 + ' WHERE (LEN(agentnumber) = 5 and (left(agentnumber,1) between ''0'' and ''8'' or left(agentnumber,1) = ''A'')) '    
    SET @SQLStr1 = @SQLStr1 + ' AND (Amname not like ''%COMPANY%'' OR Amname not like ''%DIRECT%'' OR Amname not like ''%MARKETsmp%'') '    
    SET @SQLStr1 = @SQLStr1 + ' AND agencynumber not in (''ILS'',''PLS'',''99999'') '    
    SET @SQLStr1 = @SQLStr1 + ' AND LEFT(agencynumber,2) not in (''CD'',''DR'') AND LEFT(agencynumber,3) <> ''DIR'' '    
    SET @SQLStr1 = @SQLStr1 + ' AND RIGHT(RTRIM(agencynumber),2) not in (''CD'',''DR'') AND RIGHT(RTRIM(agencynumber),3) <> ''DIR'' '    
    SET @SQLStr1 = @SQLStr1 + ' AND companycode = ''IL'' '    
        
    SET @SQLStr1 = @SQLStr1 + ' INSERT INTO @tblmineSurrender '    
    SET @SQLStr1 = @SQLStr1 + ' SELECT company_code, mine_policy_no, Annl_premium '    
    SET @SQLStr1 = @SQLStr1 + ' FROM odsmine_policy '    
    IF @CompanyCode = 'All'    
    BEGIN    
     SET @SQLStr1 = @SQLStr1 + ' WHERE company_code IN (''IL'',''AL'') '    
    END    
    ELSE    
    BEGIN    
     SET @SQLStr1 = @SQLStr1 + ' WHERE company_code IN ('''+ @CompanyCode +''') '    
    END    
    SET @SQLStr1 = @SQLStr1 + ' AND cont_status = ''S'' '    
    SET @SQLStr1 = @SQLStr1 + ' AND YEAR(effective_date) BETWEEN '+ @StartYY +' AND '+ @EndYY +' '    
        
    SET @SQLStr1 = @SQLStr1 + ' SELECT @CompSurrenderCount = COUNT(1), @CompSurrenderAP = SUM(Annl_premium) '    
    SET @SQLStr1 = @SQLStr1 + ' FROM @tblmineSurrender S '    
    SET @SQLStr1 = @SQLStr1 + ' INNER JOIN odsagent_role R '    
    SET @SQLStr1 = @SQLStr1 + ' ON S.company_code = R.company_code '    
    SET @SQLStr1 = @SQLStr1 + ' AND S.mine_policy_no = R.mine_policy_no '    
    SET @SQLStr1 = @SQLStr1 + ' INNER JOIN @tblAgentNumber A '    
    SET @SQLStr1 = @SQLStr1 + ' ON R.servicsmpagent_code = A.AgentNumber '    
        
    SET @SQLStr1 = @SQLStr1 + ' INSERT INTO @tblmineInforce '    
    SET @SQLStr1 = @SQLStr1 + ' SELECT company_code, mine_policy_no, Annl_premium '    
    SET @SQLStr1 = @SQLStr1 + ' FROM odsmine_policy '    
    IF @CompanyCode = 'All'    
    BEGIN    
     SET @SQLStr1 = @SQLStr1 + ' WHERE company_code IN (''IL'',''AL'') '    
    END    
    ELSE    
    BEGIN    
     SET @SQLStr1 = @SQLStr1 + ' WHERE company_code IN (''' + @CompanyCode + ''') '    
    END    
    SET @SQLStr1 = @SQLStr1 + ' AND cont_status = ''I'' '    
    SET @SQLStr1 = @SQLStr1 + ' AND YEAR(effective_date) BETWEEN '+ @StartYY +' AND '+ @EndYY +' '    
        
    SET @SQLStr1 = @SQLStr1 + ' SELECT @CompInforceCount = COUNT(1), @CompInforceAP = SUM(Annl_premium) '    
    SET @SQLStr1 = @SQLStr1 + ' FROM @tblmineInforce I '    
    SET @SQLStr1 = @SQLStr1 + ' INNER JOIN odsagent_role R '    
    SET @SQLStr1 = @SQLStr1 + ' ON I.company_code = R.company_code '    
    SET @SQLStr1 = @SQLStr1 + ' AND I.mine_policy_no = R.mine_policy_no '    
    SET @SQLStr1 = @SQLStr1 + ' INNER JOIN @tblAgentNumber A '    
    SET @SQLStr1 = @SQLStr1 + ' ON R.servicsmpagent_code = A.AgentNumber '    
        
    SET @SQLStr1 = @SQLStr1 + ' SET @CompAvgCount = ROUND(ISNULL(@CompSurrenderCount,0) * 100 / ( ISNULL(@CompSurrenderCount,0) + @CompInforceCount),2) '     
    SET @SQLStr1 = @SQLStr1 + ' SET @CompAvgAP = ROUND(ISNULL(@CompSurrenderAP,0) * 100 / ( ISNULL(@CompSurrenderAP,0) + @CompInforceAP),2) '     
        
    SET @SQLStr1 = @SQLStr1 + ' DECLARE @tblODSmine_Policy TABLE '    
    SET @SQLStr1 = @SQLStr1 + ' ( '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentName] VARCHAR(255), '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentNumber] VARCHAR(9), '    
    SET @SQLStr1 = @SQLStr1 + '  [AgentRank] VARCHAR(10), '    
    SET @SQLStr1 = @SQLStr1 + '  [Company_Code] VARCHAR(4), '    
    SET @SQLStr1 = @SQLStr1 + '  [mine_Policy_No] VARCHAR(10), '    
    SET @SQLStr1 = @SQLStr1 + '  [Cont_Status] VARCHAR(1), '    
    SET @SQLStr1 = @SQLStr1 + '  [Annl_Premium] DECIMAL(15,2), '    
    SET @SQLStr1 = @SQLStr1 + '  [No_count] NUMERIC '    
    SET @SQLStr1 = @SQLStr1 + ' ) '    
        
    SET @SQLStr2 = 'INSERT INTO  @tblODSmine_Policy '    
    SET @SQLStr2 = @SQLStr2 + ' SELECT DISTINCT AgtProfile.AgentName, AgtProfile.AgentNumber, '    
    SET @SQLStr2 = @SQLStr2 + ' AgtProfile.AgentRank,mine.company_code, mine.mine_policy_no, mine.cont_status, mine.Annl_Premium, 1.0 as no_count '    
    SET @SQLStr2 = @SQLStr2 + ' FROM @tblAgentNumber AgtProfile '    
    SET @SQLStr2 = @SQLStr2 + ' INNER JOIN [SUMYOLAP0001].aetnaildb.dbo.COMAGH COMAGH '    
    SET @SQLStr2 = @SQLStr2 + ' ON AgtProfile.AgentNumber = COMAGH.AHAGTN '    
    SET @SQLStr2 = @SQLStr2 + ' AND (AHAMNO = ''' + @AgentCode + ''' OR AHUMNO = ''' + @AgentCode + ''' OR AHAGNO = ''' + @AgentCode + ''') '    
        
    IF @CompanyCode = 'ALL'    
    BEGIN    
     SET @SQLStr2 = @SQLStr2 + ' AND AHCO IN (''AL'',''IL'') '    
    END    
    ELSE    
    BEGIN    
     SET @SQLStr2 = @SQLStr2 + ' AND AHCO = ''' + @CompanyCode + ''' '    
    END    
        
    SET @SQLStr2 = @SQLStr2 + ' INNER JOIN odsagent_role Role '    
    SET @SQLStr2 = @SQLStr2 + ' ON AgtProfile.AgentNumber = Role.servicsmpagent_code '    
    SET @SQLStr2 = @SQLStr2 + ' INNER JOIN odsmine_policy mine '    
    SET @SQLStr2 = @SQLStr2 + ' ON Role.company_code = mine.company_code '    
    SET @SQLStr2 = @SQLStr2 + ' AND Role.mine_policy_no = mine.mine_policy_no '    
    SET @SQLStr2 = @SQLStr2 + ' AND mine.cont_status IN (''S'',''I'') '    
        
    IF @CompanyCode = 'ALL'    
    BEGIN    
     SET @SQLStr2 = @SQLStr2 + ' AND mine.company_code IN (''AL'',''IL'') '    
    END    
    ELSE     
    BEGIN    
     SET @SQLStr2 = @SQLStr2 + ' AND mine.company_code = ''' + @CompanyCode + ''' '    
    END    
        
    SET @SQLStr2 = @SQLStr2 + ' AND YEAR(mine.effective_date) BETWEEN '+ @StartYY +'  AND  '+ @EndYY +' '    
        
    SET @SQLStr3 = 'SELECT AgentName, AgentRank, AgentNumber, '    
    SET @SQLStr3 = @SQLStr3 + ' CONVERT(INT,SUM(CASE WHEN cont_status = ''S'' THEN no_count ELSE 0 END)) AS Surrrender_Count, '    
    SET @SQLStr3 = @SQLStr3 + ' CONVERT(INT,SUM(CASE WHEN cont_status = ''I'' THEN no_count ELSE 0 END)) AS InForce_Count, '    
    SET @SQLStr3 = @SQLStr3 + ' SUM(CASE WHEN cont_status = ''S'' THEN Annl_premium ELSE 0 END) AS SurrenderAP, '    
    SET @SQLStr3 = @SQLStr3 + ' SUM(CASE WHEN cont_status = ''I'' THEN Annl_premium ELSE 0 END) AS InForceAP, '    
    SET @SQLStr3 = @SQLStr3 + ' CASE WHEN count(*) = 0 THEN 0 ELSE CONVERT(DECIMAL(38,2),(SUM(CASE WHEN cont_status = ''S'' THEN no_count ELSE 0 END) * 100 / count(*))) END AS AgtSurrenderCount, '    
    SET @SQLStr3 = @SQLStr3 + ' CASE WHEN SUM(Annl_premium) = 0 THEN 0 ELSE CONVERT(DECIMAL(38,2),(SUM(CASE WHEN cont_status = ''S'' THEN Annl_premium ELSE 0 END) * 100 / SUM(Annl_premium))) END AS AgtSurrenderAP, '    
    SET @SQLStr3 = @SQLStr3 + ' CONVERT(varchar(100),@CompAvgCount) AS CompAvgCount, '    
    SET @SQLStr3 = @SQLStr3 + ' CONVERT(varchar(100), @CompAvgAP) AS CompAvgAP '    
    SET @SQLStr3 = @SQLStr3 + ' FROM @tblODSmine_Policy '    
    SET @SQLStr3 = @SQLStr3 + ' GROUP BY AgentName, AgentRank, AgentNumber '    
        
    EXEC (@SQLStr1 + @SQLStr2 + @SQLStr3)    
    --PRINT (@SQLStr1 + @SQLStr2 + @SQLStr3)    

    Yes.

    1. the scrap code.
    2. get the specification of the requirements of business origin.
    3. learn PL/SQL.
    4. write the PL/SQL code to meet the requirements of the company.

  • Installer for the simultaneous program defined with the parameters - Script SQL

    I wrote a very simple sql script and I want to save it as a simultaneous Oracle program. I have included a parameter field in the sql script to allow the entry of a value to determine the number of days prior to the script. The script runs correctly in SQL * Plus, but when I try to record it as a competitor Oracle program I get the following errors below:
    This works in SQL* PLUS
    
    SELECT emp_id, amount
    FROM tblSalaries
    WHERE hire_date > SYSDATE-&Days;
    
    Enter value for Days: 7
    old    3: hire_date > SYSDATE-&Days
    new  3: hire_date > SYSDATE-7
    
    And it provides my results....
    Although when I save this as a simultaneous program and set the configuration setting and run the simultaneous program and enter the number in the parameter field, work ends with an ERROR with the following:
                                                                                                             
    Enter value for Days: EXEC FND_CONC_STAT.COLLECT;
    hire_date > SYSDATE-EXEC FND_CONC_STAT.COLLECT; and
                                        *
    ERROR at line 3:
    ORA-00933: SQL command not properly ended 
    If I put single quotes around '& days', in line 3, I get a different error:
    ERROR at line 3:
    ORA-01722: invalid number 
    Do you know what could be the problem?
    Thanks for the review!

    You can try one of these approaches-

    1. replace '& days' in your script with "& 1"- or-".

    2. Add the following to your script at the beginning

    Days := &1;
    

    PL see the developer's Guide Application for your specific version http://www.oracle.com/technology/documentation/applications.html EBS

    HTH
    Srini

Maybe you are looking for