Replace Text In SQL Scripts

Hi,
I would like to search and replace text in files when I run .sql files.
E.g. When user provide scripts xyz.sql, they would put table name like
INSERT INTO  xyz abc VALUES ('text');I would like to replace xyz abc with mytablename.
INSERT INTO  mytablename VALUES ('text');Besides, from the user provided sql scripts, they would be some junk create table scripts, I would like to comment off these junk table scripts.
How could I do achieve the above?
I would be calling user provided sql scripts from my sql scripts using @ ./data/temp.sql
I am using oracle 8i for these. Any help is highly appreciable.
Regards

Sorry for not providing enough information.
Oracle Version as follows:
       Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
     PL/SQL Release 8.1.7.4.0 - Production          OS:
Windows XP SP2
damorgan wrote:No clear description of what you are actually trying to do ... for example where does "mytablename" come from, where does "xyz" come from, how is the decision to be made? Based on what logic?
These scripts are provided by customers where they use other database like sysbase to generate sql scripts and customers are not in a position to change or alter the scripts as these scripts are part of the solution provided by vendors(legacy systems)
I have mapping sql script where table name is e.g. xyz abc then use script TS2 and process the customer given sql script.
Let me know if I am missing out any other information.
Regards

Similar Messages

  • How to load SQL scripts from a text file.

    Hi, i tried several time to load a text file/SQL script with 10 different tables and data, but 10g Express doesen't allows me to do that, any one can direct me or point out to me what i should do or do i need to adopt any special method to to get this done. i am sure there must be some thing where you can upload SQL scripts from a text file (in SQL command editor!). thanks

    Hi,
    see my other answer here:
    SQL command editor doesn't take more than 1 insert command
    This seems to be a duplicate question, right? Or am I missing something?
    Regards,
    ~Dietmar.

  • How can I read/write data files (text file) from PL/SQL Script

    I had an oracle forms pl/sql program to read/write a data file (text file). When this code is run on a command line as a PL/SQL script using the SQL*Plus I am getting an error:
    -- sample.sql
    DECLARE
      vLocation                 VARCHAR2(50)  := 'r:\';
      vFilename                 VARCHAR2(100) := 'sample.dat';
      vTio                   TEXT_IO.FILE_TYPE;
      vLinebuf               VARCHAR2(2000);
      vRownum               NUMBER        := 0;
      -- use array to store data FROM each line of the text file     
      TYPE           array_type IS VARRAY(15) OF VARCHAR2(100);
      vColumn      array_type := array_type('');
      PROCEDURE prc_open_file(p_filename IN VARCHAR, p_access IN VARCHAR2) is
      BEGIN
        vTio := TEXT_IO.FOPEN(vLocation||p_filename,p_access);
      EXCEPTION
        WHEN OTHERS then
          --  raise_application_error(-20000,'Unable to open '||p_filename);
          message(sqlerrm);pause;
      END;
      PROCEDURE prc_close_file is
      BEGIN
        IF TEXT_IO.IS_OPEN(vTio) then
           TEXT_IO.FCLOSE(vTio);
        END IF;
      END;
    BEGIN
      --extend AND initialize the array to 4 columns
      vColumn.EXTEND(4,1);
      prc_open_file(vFilename,'r');
      LOOP
          LTEXT_IO.GET_LINE(vTio,vLinebuf);
          vColumn(1)  := SUBSTR(vLineBuf, 1, 3);
          vColumn(2)  := SUBSTR(vLineBuf, 5, 8);
          vColumn(3)  := SUBSTR(vLineBuf,10,14);     
          Insert Into MySampleTable
          Values
            (vColumn(1), vColumn(2), vColumn(3));
          EXIT WHEN vLinebuf IS NULL;
       END LOOP;
       prc_close_file;
    END;
    SQL> @c:\myworkspace\sql\scripts\sample.sql;
    PLS-00201: identifier 'TEXT_IO.FILE_TYPE' must be declaredIt works on the oracle forms but not on the SQL*Plus. Is there an alternative method using a PL/SQL script? A simple sample would help. Thanks.

    Did you ever noticed the search box at the right side of the forum?
    A quick search (limited to this years entries) brought up this thread for example
    Re: UTL_FILE Examples

  • SQL Replace function: errors if replacement text is 8191 characters

    Oracle 10.2.0.3.0 Enterprise Edition
    I'm working on an application which has a function to generate emails.
    We have a template, which gets filled with data from the database depending on the email being sent.
    To do this I'm using the Replace function to replace certain parts of the template with the right data.
    It seems that if the replacement text (the third argument to the function) is longer than 8191 bytes the function throws a PL/SQL: numeric or value error.
    This limitation doesn't appear to be documented anywhere, certainly nowhere that I can find.
    Anyone know of a way around this short of building my own replace function?

    I've figured out what was going on.
    The database column for the replacement text is defined as a clob, but there is a front end limit of 10,000 characters for the field being used.
    When using the replace function I was assigning the value to a varchar2(32767) field in the PL/SQL.
    So in terms of datatypes the function call is:
    varchar2 := replace(varchar2, varchar2, clob)
    If the length of the clob is over 8191 characters it errors.
    (Presumably because of the bug mentioned in this thread DBMS_LOB.SUBSTR() returning 8191 characters instead of 32767
    I've fixed it by simply changing the datatype of the variable to which the value is being assigned to a clob.

  • Replace Text script returns error when dropped in automator

    Hi Friends,
    I have a series of pdfs that were saved with spaces in their file names. I need to put them into folders for a website (there's a lot). Pretty newbie on this too but I figured I'd try.
    I tried using the example script "Replace Text in Item names" which worked on it's own.
    (hd:applications:applescript:example scripts:finder scripts)
    When I applied it as an action in Automator, I would get an error about "expected end but found on."
    I think that resulted from the default script. So I deleted that. Put the replace script in.
    I cut out the dialog boxes and specified folders, search, and replacement items. And cut out the second half (after the beep)
    However as I step through, when I get to the script it returns the error: No result was returned from some part of this expression.
    So I'm not sure what I'm missing.

    It is hard to tell without seeing the mangled modified script. Your main problem is probably related to the run handler, which needs to be defined in Automator's Run AppleScript action. Every AppleScript has a run handler, but in the case of the Replace Text in Item Names it is implied (not explicitly defined). You will need to place the main statements of the script inside the Run AppleScript action on run handler, leaving the other handlers (for example, setitemname) outside of the run handler.

  • Is it possible to pass a TXT file as an input of a SQL script?

    Dear all,
    I have a question about SQL scripts running in SQL*Plus. I have a table including a list of SAP UserIDs. I would like to check for several people whether their
    ID already exists. Here is how I proceed in my script file.
    SELECT sap_userid
    FROM SAPREF_USERS
    WHERE (sap_userid
    IN
         'user1',
         'user2',
         'user3',
         'user4',
         'user5',
           .          /*  So here I write one by one each userid. Consequently if a user already exists, the script will print his/her UserID */
    GROUP BY sap_userid
    ORDER BY sap_useridWell, this works, but I'm sure there should be a more intelligent method to do the job. If I put all UserIDs in a let's say a TXT file (one userid per line) is there
    any way to pass this text file as an input for the script so I may get rid of the very long IN clause in my SQL query?
    Thanks in advance,
    Kind Regards,
    Dariyoosh

    Yet Another Post Without Version.
    Typing 4 digits and 3 dots, or running select * from v$version and paste the result here
    Qualifies as work, and the very reason you post here is you want to avoid to work, or to earn as much as possible by doing as little as possible.
    In 9i and higher, the file is best treated as an external table, so the whole list of userids is replaced by
    in (select * from external_table)
    But this requires reading documentation, which again qualifies as ... work.
    Ahh, most 'DBA's here are quite hopeless.
    Sybrand Bakker
    Senior Oracle DBA

  • How to generate sql script based on table structure

    I want to generate a sql script based on a table structure.
    For example:
    if the table is:
    cid id c_value
    1 1 zz
    2 1 yy
    3 2 zz
    4 2 xx
    5 3 ss
    6 3 tt
    The expected output is:
    WITH
    CHILD_tab as (
    SELECT 1 cid, 1 id,'zz' c_value from dual union all
    SELECT 2 cid, 1 id,'yy' c_value from dual union all
    SELECT 3 cid, 2 id,'zz' c_value from dual union all
    SELECT 4 cid, 2 id,'xx' c_value from dual union all
    SELECT 5 cid, 3 id,'ss' c_value from dual union all
    SELECT 6 cid, 3 id,'tt' c_value from dual )
    Release 11.1.0.7.0

    I'm doing a lot of XML these days (too much perhaps) so here's a solution involving XQuery.
    We pass a query string and it outputs a CLOB containing the WITH clause :
    SELECT DBMS_XMLGEN.Convert(
    XMLQuery(
    q'[concat(
    "WITH t AS (
    string-join(
    for $i in /ROWSET/ROW
    return concat( " SELECT ",
                    string-join($i/*/concat("'",ora:replace(text(),"'","''"),"' ",local-name()),", "),
                    " FROM dual" ),
    " UNION ALL
    passing dbms_xmlgen.getXMLType('SELECT * FROM scott.emp')
    returning content
    ).getClobVal(), 1) AS WITH_CLAUSE
    FROM dual;
    WITH_CLAUSE
    WITH t AS (
    SELECT '7369' EMPNO, 'SMITH' ENAME, 'CLERK' JOB, '7902' MGR, '17/12/80' HIREDATE, '800' SAL, '20' DEPTNO FROM dual UNION ALL
    SELECT '7499' EMPNO, 'ALLEN' ENAME, 'SALESMAN' JOB, '7698' MGR, '20/02/81' HIREDATE, '1600' SAL, '300' COMM, '30' DEPTNO FROM dual UNION ALL
    SELECT '7521' EMPNO, 'WARD' ENAME, 'SALESMAN' JOB, '7698' MGR, '22/02/81' HIREDATE, '1250' SAL, '500' COMM, '30' DEPTNO FROM dual UNION ALL
    SELECT '7566' EMPNO, 'JONES' ENAME, 'MANAGER' JOB, '7839' MGR, '02/04/81' HIREDATE, '2975' SAL, '20' DEPTNO FROM dual UNION ALL
    SELECT '7654' EMPNO, 'MARTIN' ENAME, 'SALESMAN' JOB, '7698' MGR, '28/09/81' HIREDATE, '1250' SAL, '1400' COMM, '30' DEPTNO FROM dual UNION ALL
    SELECT '7698' EMPNO, 'BLAKE' ENAME, 'MANAGER' JOB, '7839' MGR, '01/05/81' HIREDATE, '2850' SAL, '30' DEPTNO FROM dual UNION ALL
    SELECT '7782' EMPNO, 'CLARK' ENAME, 'MANAGER' JOB, '7839' MGR, '09/06/81' HIREDATE, '2450' SAL, '10' DEPTNO FROM dual UNION ALL
    SELECT '7788' EMPNO, 'SCOTT' ENAME, 'ANALYST' JOB, '7566' MGR, '19/04/87' HIREDATE, '3000' SAL, '20' DEPTNO FROM dual UNION ALL
    SELECT '7839' EMPNO, 'KING' ENAME, 'PRESIDENT' JOB, '17/11/81' HIREDATE, '5000' SAL, '10' DEPTNO FROM dual UNION ALL
    SELECT '7844' EMPNO, 'TURNER' ENAME, 'SALESMAN' JOB, '7698' MGR, '08/09/81' HIREDATE, '1500' SAL, '0' COMM, '30' DEPTNO FROM dual UNION ALL
    SELECT '7876' EMPNO, 'ADAMS' ENAME, 'CLERK' JOB, '7788' MGR, '23/05/87' HIREDATE, '1100' SAL, '20' DEPTNO FROM dual UNION ALL
    SELECT '7900' EMPNO, 'JAMES' ENAME, 'CLERK' JOB, '7698' MGR, '03/12/81' HIREDATE, '950' SAL, '30' DEPTNO FROM dual UNION ALL
    SELECT '7902' EMPNO, 'FORD' ENAME, 'ANALYST' JOB, '7566' MGR, '03/12/81' HIREDATE, '3000' SAL, '20' DEPTNO FROM dual UNION ALL
    SELECT '7934' EMPNO, 'MILLER' ENAME, 'CLERK' JOB, '7782' MGR, '23/01/82' HIREDATE, '1300' SAL, '10' DEPTNO FROM dual
    )It may be useful for small data sets only because we quickly hit ORA-01706.

  • Error Text = PL/SQL: ORA-00926

    Can some one tell me what the problem is with this, fairly urgent
    ERROR:Line # = 120 Column # = 28 Error Text = PL/SQL: ORA-00926: missing VALUES keyword
    Line # = 120 Column # = 2 Error Text = PL/SQL: SQL [b]Statement ignored
    Oracle Migration Workbench
    CREATE OR REPLACE FUNCTION "SA"."SPCXDB_DELIVERPRJ" (
    CurrUser_ID IN NUMBER DEFAULT NULL,
    Object_ID IN NUMBER DEFAULT NULL,
    Path_ID IN NUMBER DEFAULT NULL,
    IsLastPhase IN NUMBER DEFAULT NULL,
    NewPhase_ID IN NUMBER DEFAULT NULL,
    User_ID IN NUMBER DEFAULT NULL,
    Comment_ IN VARCHAR2 DEFAULT NULL,RC1_CALL IN OUT Omwb_emulation.globalPkg.RCT1 )
    RETURN INTEGER
    AS
    CurrUser_ID_ NUMBER(10,0) := CurrUser_ID;
    Object_ID_ NUMBER(10,0) := Object_ID;
    Path_ID_ NUMBER(10,0) := Path_ID;
    IsLastPhase_ NUMBER(3,0) := IsLastPhase;
    NewPhase_ID_ NUMBER(10,0) := NewPhase_ID;
    User_ID_ NUMBER(10,0) := User_ID;
    Comment__ VARCHAR2(255) := Comment_;
    StoO_selcnt INTEGER;
    StoO_error INTEGER;
    StoO_rowcnt INTEGER;
    StoO_crowcnt INTEGER := 0;
    StoO_fetchstatus INTEGER := 0;
    StoO_errmsg VARCHAR2(255);
    StoO_sqlstatus INTEGER;
    tempVar1 NUMBER :=3;
    tempVar2 NUMBER :=1;
    id NUMBER(10,0);
    CURSOR ptr IS
    SELECT Object_ID
    FROM TT_DVROBJECTS;
    dummy_var1 INTEGER;
    /****** Object: Stored Procedure dbo.spCXDB_deliverprj Script Date: 2003-11-12 14:21:41 ******/
    -- currently logged user id
    BEGIN
    NULL;
    /*[SPCONV-ERR(12)]:(set XACT_ABORT) Manual conversion required*/
    1) update project
    IF SPCXDB_DELIVERPRJ.IsLastPhase_ = 0 THEN
    BEGIN
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    UPDATE sa.CXDBObjects
    SET DvrPath_ID = SPCXDB_DELIVERPRJ.Path_ID_,
    DvrPhase_ID = SPCXDB_DELIVERPRJ.NewPhase_ID_,
    DvrUser_ID = SPCXDB_DELIVERPRJ.User_ID_
    WHERE Object_ID = SPCXDB_DELIVERPRJ.Object_ID_;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    -- Status = 4
    END;
    ELSE
    BEGIN
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    UPDATE sa.CXDBObjects
    SET DvrPath_ID = 0,
    DvrPhase_ID = 0,
    DvrUser_ID = 0
    WHERE Object_ID = SPCXDB_DELIVERPRJ.Object_ID_;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    -- Status = 0
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    UPDATE sa.CXDBDeliverPaths
    SET RefCount = RefCount - 1
    WHERE Path_ID = SPCXDB_DELIVERPRJ.Path_ID_;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    2) get all subobjects , subprojects and documents
    END;
    END IF;
    /* Emulating @@TRANCOUNT functionality in Oracle model */
    omwb_emulation.globalPkg.trancount:=omwb_emulation.globalPkg.trancount+1;
    /*[SPCONV-ERR(55)]:CREATE TABLE TT_DVROBJECTS_2-- TT_DVROBJECTS Will be used -- statement passed to ddl file*/
    DELETE FROM TT_DVROBJECTS;
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    INSERT INTO TT_DVROBJECTS ; /*ERROR:Line # = 120 Column # = 28 Error Text = PL/SQL: ORA-00926: missing VALUES keyword
    Line # = 120 Column # = 2 Error Text = PL/SQL: SQL Statement ignored
    SQL SERVER 2000
    BEGIN TRAN
    CREATE TABLE #DvrObjects ( Object_ID int NOT NULL )
    NSERT
    #DvrObjects
    EXEC
    spCXDB_expandtree @Object_ID,3,1 */
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    BEGIN
    /* demoDMS*/sa.spCXDB_expandtree(SPCXDB_DELIVERPRJ.Object_ID_,
    tempVar1,
    tempVar2,
    RC1 => RC1_CALL);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    3) put documents and projects onto deliver path
    NULL;/*DECLARE CURSOR ptr */
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    StoO_crowcnt := 0;
    OPEN ptr;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    StoO_crowcnt := 0;
    FETCH ptr INTO
    SPCXDB_DELIVERPRJ.id;
    EXCEPTION
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    IF ptr%NOTFOUND THEN
    StoO_sqlstatus := 2;
    StoO_fetchstatus := -1;
    ELSE
    StoO_sqlstatus := 0;
    StoO_fetchstatus := 0;
    END IF;
    <<i_loop1>>
    WHILE ( StoO_fetchstatus = 0) LOOP
    BEGIN
    -- IF (SELECT Status FROM CXDBObjects WHERE Object_ID = @id) = 4 AND
    BEGIN
    StoO_selcnt := 0;
    StoO_error := 0;
    StoO_rowcnt := 0;
    SELECT 1 INTO StoO_selcnt
    FROM DUAL
    WHERE 0 <> (
    SELECT DvrPhase_ID
    FROM CXDBObjects
    WHERE Object_ID = SPCXDB_DELIVERPRJ.id ) AND SPCXDB_DELIVERPRJ.Path_ID_
    = (
    SELECT DvrPath_ID
    FROM CXDBObjects
    WHERE Object_ID = SPCXDB_DELIVERPRJ.id );
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    IF StoO_selcnt != 0 THEN
    BEGIN
    BEGIN
    BEGIN
    StoO_selcnt := 0;
    StoO_error := 0;
    StoO_rowcnt := 0;
    SELECT 1 INTO StoO_selcnt
    FROM DUAL
    WHERE 0 = (
    SELECT type_
    FROM CXDBObjects
    WHERE Object_ID = SPCXDB_DELIVERPRJ.id );
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    IF StoO_selcnt != 0 THEN
    BEGIN
    -- update project data
    IF SPCXDB_DELIVERPRJ.IsLastPhase_ = 0 THEN
    BEGIN
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    UPDATE sa.CXDBObjects
    SET DvrPath_ID = SPCXDB_DELIVERPRJ.Path_ID_,
    DvrPhase_ID = SPCXDB_DELIVERPRJ.NewPhase_ID_,
    DvrUser_ID = SPCXDB_DELIVERPRJ.User_ID_
    WHERE Object_ID = SPCXDB_DELIVERPRJ.id;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    -- Status = 4
    END;
    ELSE
    BEGIN
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    UPDATE sa.CXDBObjects
    SET DvrPath_ID = 0,
    DvrPhase_ID = 0,
    DvrUser_ID = 0
    WHERE Object_ID = SPCXDB_DELIVERPRJ.id;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    -- Status = 0
    --decrease path reference counter
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    UPDATE sa.CXDBDeliverPaths
    SET RefCount = RefCount - 1
    WHERE Path_ID = SPCXDB_DELIVERPRJ.Path_ID_;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    END;
    END IF;
    END;
    ELSE
    BEGIN
    BEGIN
    dummy_var1 := /* demoDMS*/sa.spCXDB_deliverdocument(SPCXDB_DELIVERPRJ.CurrUser_ID_,
    SPCXDB_DELIVERPRJ.id,
    SPCXDB_DELIVERPRJ.Path_ID_,
    SPCXDB_DELIVERPRJ.IsLastPhase_,
    SPCXDB_DELIVERPRJ.NewPhase_ID_,
    SPCXDB_DELIVERPRJ.User_ID_,
    SPCXDB_DELIVERPRJ.Comment__);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    END;
    END IF;
    END;
    END;
    END IF;
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    StoO_crowcnt := 0;
    FETCH ptr INTO
    SPCXDB_DELIVERPRJ.id;
    EXCEPTION
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    IF ptr%NOTFOUND THEN
    StoO_sqlstatus := 2;
    StoO_fetchstatus := -1;
    ELSE
    StoO_sqlstatus := 0;
    StoO_fetchstatus := 0;
    END IF;
    END;
    END LOOP;
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    CLOSE ptr;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    NULL;
    /* Emulating @@TRANCOUNT functionality in Oracle model */
    IF omwb_emulation.globalPkg.trancount = 1 THEN
    COMMIT WORK;
    END IF;
    IF omwb_emulation.globalPkg.trancount > 0 THEN
    omwb_emulation.globalPkg.trancount:=omwb_emulation.globalPkg.trancount-1;
    END IF;
    RETURN (0);
    END SPCXDB_DELIVERPRJ;
    Thank's

    Hi Hilary,
    This is the original T-SQL code. Please, help me.
    CREATE PROCEDURE spCXDB_deliverPrj
    @CurrUser_ID     int,          -- currently logged user id
    @Object_ID     int,
    @Path_ID     int,
    @IsLastPhase     tinyint,
    @NewPhase_ID int,
    @User_ID     int,
    @Comment     varchar(255) = NULL
    AS
    SET XACT_ABORT ON
         1) update project
    IF @IsLastPhase = 0
    BEGIN
         UPDATE
              CXDBObjects
         SET
              DvrPath_ID = @Path_ID,
              DvrPhase_ID = @NewPhase_ID,
              DvrUser_ID = @User_ID
    --          Status = 4
         WHERE
              Object_ID = @Object_ID
    END
    ELSE
    BEGIN
         UPDATE
              CXDBObjects
         SET
              DvrPath_ID = 0,
              DvrPhase_ID = 0,
              DvrUser_ID = 0
    --          Status = 0
         WHERE
              Object_ID = @Object_ID
         UPDATE
              CXDBDeliverPaths
         SET
              RefCount = RefCount - 1
         WHERE
              Path_ID = @Path_ID
    END
         2) get all subobjects , subprojects and documents
    BEGIN TRAN
    CREATE TABLE #DvrObjects ( Object_ID int NOT NULL )
    INSERT
         #DvrObjects
    EXEC
         spCXDB_expandtree @Object_ID,3,1
         3) put documents and projects onto deliver path
    DECLARE @id int
    DECLARE ptr CURSOR FOR SELECT Object_ID FROM #dvrobjects
    OPEN ptr
    FETCH NEXT FROM ptr INTO @id
    WHILE(@@FETCH_STATUS = 0)
    BEGIN
    --     IF     (SELECT Status FROM CXDBObjects WHERE Object_ID = @id) = 4 AND
         IF     (SELECT DvrPhase_ID FROM CXDBObjects WHERE Object_ID = @id) <> 0 AND
              (SELECT DvrPath_ID FROM CXDBObjects WHERE Object_ID = @id) = @Path_ID
         BEGIN
              IF (SELECT type FROM CXDBObjects WHERE Object_ID = @id) = 0
              BEGIN
                   -- update project data
                   IF @IsLastPhase = 0
                   BEGIN
                        UPDATE
                             CXDBObjects
                        SET
                             DvrPath_ID = @Path_ID,
                             DvrPhase_ID = @NewPhase_ID,
                             DvrUser_ID = @User_ID
    --                         Status = 4
                        WHERE
                             Object_ID = @id
                   END
                   ELSE
                   BEGIN
                        UPDATE
                             CXDBObjects
                        SET
                             DvrPath_ID = 0,
                             DvrPhase_ID = 0,
                             DvrUser_ID = 0
    --                         Status = 0
                        WHERE
                             Object_ID = @id
                        --decrease path reference counter
                        UPDATE
                             CXDBDeliverPaths
                        SET
                             RefCount = RefCount - 1
                        WHERE
                             Path_ID = @Path_ID
                        END
              END
              ELSE
              BEGIN
                   EXEC spCXDB_deliverdocument @CurrUser_ID, @id,@Path_ID,@IsLastPhase,@NewPhase_ID,@User_ID, @Comment
              END
         END
         FETCH NEXT FROM ptr INTO @id
    END
    CLOSE ptr
    DEALLOCATE ptr
    COMMIT TRAN
    RETURN(0)
    Regards,
    Emilia.

  • Difference between ';' and '/' in the SQL scripts

    Hi All,
    Could anyone please let me know the difference between placing ';' and '/' in the sql scripts.
    I am placing couple of insert statements in a textfile with .sql extension and running it from the sql prompt.
    Which one( ';' or '/') should be keep at the end of each statement in the script.
    SQL> SELECT SYSDATE FROM DUAL;
    SYSDATE
    12-MAY-13
    SQL> SELECT SYSDATE FROM DUAL
      2  /
    SYSDATE
    12-MAY-13Thanks,

    968217 wrote:
    My doubt is how it understands or the difference b/w the below two view statements one with ';' and another one with '/'. Sorry if i am unclear.They are identical in SQL*Plus. These characters mean "+send entered/buffered text to Oracle to parse and execute+".
    So - SQL*Plus sends "+create or replace view ev1 as select ename , sal from emp+" to the server (via a cursor execute):
    create or replace view ev1 as select ename , sal from emp
    /And again, SQL*Plus sends "+create or replace view ev1 as select ename , sal from emp+" to the server (via a cursor execute):
    create or replace view ev2 as select ename , sal from emp;These are identical statements.
    As I mentioned in the post I referred you to. Oracle also uses the ";" character in the PL/SQL language. So when you enter PL/SQL code in SQL*Plus, you do not want SQL*Plus to send each line of PL/SQL code to the server. Instead, you want it to wait till the last statement has been entered and then send the the whole block to the server to be parsed and executed,
    SQL*Plus has a basic parser itself. It uses that to figure out what you have entered, and whether a ";" you enter is an instruction from you to it, to send the text to the server - or when you enter a ";", it is part of the text for the server and that it should not react to it.
    Thus when you enter the following, SQL*Plus recognises that you are using the SQL language, and as this language does not use ";" characters, a ";" character when entered means that it needs to send the text to the server to be parsed and executed:
    SQL> select * from emp;
    // ; character instructs SQL*Plus to create and execute cursor "select * from emp"When you enter PL/SQL code, SQL*Pus recognises that and knows that ";" characters entered indicates end-of-statement for PL//SQL and that it should not act on that,
    SQL> begin
      2    null;
      3  end;
      4  /
    // SQL*Plus ignores the ";" character - and the "/" character is used to
    // instruct SQL*Plus to create and execute cursor"begin<LF>null;><LF>end;"

  • Convert SQL script from one dialect to another.

    Hi all,
    I am trying to convert an SQL script in MySQL dialect to one for
    Firebird (Interbase Open Source fork).
    I will show you the original MySQL script, (one table of 70), what I want it to
    become and then the Java program that I have written which has gone some of
    the way - but I'm not very experienced in Java and I think my approach
    needs to be fundamentally overhauled, it's just that I don't know
    exactly how to go about it - maybe treat the table as a unit and pass my
    file table by table to a/some processing function(s)?
    Here is the original script
    CREATE TABLE `analysis` (
      `analysis_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
      `created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
      `logic_name` varchar(128) NOT NULL,
      `db` varchar(120) DEFAULT NULL,
      `db_version` varchar(40) DEFAULT NULL,
      `db_file` varchar(120) DEFAULT NULL,
      `type` enum('constitutive_exon','exon','flanking_exon') DEFAULT NULL,
      `program` varchar(80) DEFAULT NULL,
      `program_version` varchar(40) DEFAULT NULL,
      `parameters` text,
      `gff_feature` varchar(40) DEFAULT NULL,
       PRIMARY KEY (`analysis_id`),
       UNIQUE KEY `logic_name_idx` (`logic_name`)
    ) ENGINE=MyISAM AUTO_INCREMENT=261 DEFAULT CHARSET=latin1;I want this to become
    CREATE TABLE analysis
    (  -- ( on a separate line - have done this. Note also - got rid of funny quotes `
      analysis_id smallint(5),  -- see below for what happens to auto_increment
      created TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00', -- datetime now TIMESTAMP -- trivial
      logic_name varchar(128) NOT NULL,
      db varchar(120) DEFAULT NULL,
      db_version varchar(40) DEFAULT NULL,
      db_file varchar(120) DEFAULT NULL,
      type (CHECK TYPE IN ('constitutive_exon','exon','flanking_exon')) DEFAULT NULL,  -- emum becomes a CHECK constraint - parse the string in a function?
      program varchar(80) DEFAULT NULL,
      program_version varchar(40) DEFAULT NULL,
      parameters BLOB SUB_TYPE TEXT,  -- text becomes BLOB SUB_TYPE TEXT - trivial
      gff_feature varchar(40) DEFAULT NULL,
      -- PRIMARY KEY (analysis_id),  -- here's where the fun starts - see below.
      -- UNIQUE KEY logic_name_idx (logic_name) -- more fun here
    )  -- ) on new line
    -- ENGINE=MyISAM AUTO_INCREMENT=261 DEFAULT CHARSET=latin1; - this line gets obliterated - see below.
    -- only data of interest on this line is the AUTO_INCREMENT VALUE - 261
    ALTER TABLE ADD CONSTRAINT analysis_id_PK PRIMARY KEY(analysis_id) USING INDEX analysis_id_PK_IX
    ALTER SEQUENCE analysis_id_seq RESTART WITH 261 -- note auto_increment=261 at end
    -- note, take field name of AutoIncrement - add PK and PK_IX
    -- as required. I will also have to write something similar for the UNIQUE KEY - but
    -- if I can do it for PRIMARY KEY, then it should be easy...I have written a program which has started to do some of the easier stuff
    below - however, I now think that I should be treating a TABLE as a unit rather
    than the line by line processing which I have been doing so far. I would
    like some pointers as to how I could do this - the .sql file has about 70
    tables and I want to be able to process the file in one pass. Any hints,
    recommendations, URLs, tips or other help greatly appreciated - rgs,
    Paul...
    ============= Java listing so far (I have been trying 8-) ) ===========
    import java.io.*;
    import java.util.*;
    class FileProcess
      public static void main(String args[])
        try
          // Open the file that is the first
          // command line parameter
          FileInputStream fistream = new FileInputStream("analysis.sql");
          FileWriter fwstream = new FileWriter("nanalysis.sql");
          // Get the object of DataInputStream
          DataInputStream in = new DataInputStream(fistream);
          BufferedReader br = new BufferedReader(new InputStreamReader(in));
          BufferedWriter out = new BufferedWriter(fwstream);
          String strLine;
          String newLine = System.getProperty("line.separator");
          String newSQLText = "";
          String tblName = "";
          String recordDelims = "[ ]";
          Boolean inTable = false;
          String tableBegin = "(" + newLine;
          System.out.println("\nAnd tableBegin is *_" + tableBegin + "_*");
          //Read File Line By Line
          while ((strLine = br.readLine()) != null)      
            // if strLine.contains(
            // Print the content on the console
            System.out.println ("StrLine = " + strLine);
            newSQLText = getRidOfWierdQuotes(strLine);
            if(strLine.contains("CREATE TABLE"))
              StringTokenizer st = new StringTokenizer(newSQLText, "` ");
              st.nextToken();
              st.nextToken();
              tblName = st.nextToken();
              System.out.println("\nAnd the table name is *_" + tblName + "_*");
            if(strLine.contains(" (") && strLine.contains("CREATE TABLE"))
              System.out.println("\nAnd here's the start of a table!");
              newSQLText = newSQLText.replace(" (", newLine + "(");
             // br.readLine();
              //br.readLine();
            if(strLine.contains(" text,") || strLine.contains(" text "))
              newSQLText = newSQLText.replace(" text", " BLOB SUB_TYPE TEXT");
    //        String sqlTokens[] = newSQLText.split("\\s+");
    //       StringTokenizer stRecord = new StringTokenizer(newSQLText)
            System.out.println("\nNew strLine = " + newSQLText);
            out.write(newSQLText + "\n");
          //Close the input stream
          in.close();
          out.close();
        catch (Exception e)
          //Catch exception if any
          System.err.println("Error: " + e.getMessage());
      public static String getRidOfWierdQuotes(String iString)
        return iString.replace("`", "");
    } // End of class FileProcess

    >
    Your technique looks OK but I would avoid all the cosmetic changes. It doesn't make any
    difference to the script where the newline comes, and the back-quotes are legal SQL too.
    I would confine your activities to what is actually required. Otherwise you are just adding
    implementation difficulties and also running the risk of an ever-expanding scope of what
    the cosmetic improvements should include.Thanks for your reply - however, I would just make two points.
    1) The cosmetic changes are the easiest - and I've essentially implemented them already, and
    for myself, I find that when working on a system with many tables, the way they are presented
    by whatever tool one is using to modify/update/change/run various scripts is very important as
    an aid to organisation and ultimately understanding.
    2) Having essentially completed the cosmetic stuff, I now find myself turning to the group here
    for help with the real "meat" of the project - getting the PRIMARY KEYs and other INDEXES
    &c. into the mix - and this is tricky because of the significant differences between MySQL and
    Firebird SQL dialects - that and the fact that not all AUTO_INCREMENT fields are PRIMARY
    KEYs - so I am looking beyond the mere cosmetic.
    I think I said in my original post that I wanted to perform this task in "one pass". Perhaps what
    I should have said (and might have been clearer) is if I said that I just wanted to run one
    Java programme against the data.
    I now think that my Java programme will have to go through the data a couple of times - on
    the first pass - it will collect the names of those tables for which the AUTO_INCREMENT
    field is* the PRIMARY KEY - putting the name into a Vector (deprecated?) or similar
    and then go through my "cleaned up" sql file adding the KEYs/INDEXes &c. as I go.
    What do you think of this approach - or should I be looking at constructing "Table"
    objects (as arrays of String?) and manipulating those?
    This is my real question - what is the best approach to take - as a 36K guru level
    poster - you probably have an idea - I'm not asking for the work to be done for me,
    as you can see - I've made an effort myself, despite my Java not being to the highest
    pinnacle of coding perfection ;) - any snippets, help, anything appreciated (from
    anybody...) - TIA and rgs,
    Paul...

  • Applescript: open Pages doc from Templete, change filename and replace text

    Hi!
    I just got started with applescript and i want a script that does the following:
    1. open "choose from list" dialog to choose the topic of my document
    from 4 possibilities (here for example A, B, C, D)
    2. open document from TemplateXY
    3. set document name with date and topic (dd.mm.yyy) "16.02.2011 - A"
    4.inside of document: replace text "date" with the currend date (dd.mm.yyy)
    and the text "topic" with the topic chosen in (1.) "A"
    this is what i already did:
    here as colored screenshot:
    http://i55.tinypic.com/2mnhxkm.jpg
    set datum to do shell script "date \"+%d.%m.%Y\""
    --choose topic:
    set chosentopic to choose from list {"A", "B", "C", "D"}
    --text "topic" becomes replaced throug variable topic
    set searchstringT to "topic"
    set replacestringT to chosentopic
    --text "date" gets replaced by currend date (variable datum)
    set searchstringD to "date"
    set replacestringD to datum
    --open pages, define filename & do search&replace of the strings defined above
    tell application "Pages"
    activate
    set DocName to datum & " - " & chosentopic
    set (every text where it is searchstringT) to replacestringT
    set (every text where it is searchstringD) to replacestringD
    end tell
    the "choose from list" dialog works and the variables like topic, datum and the search&replace strings get defined as well
    my problems are:
    i only get an error that the text could not be replaced
    i dont know how to get a new document from a template and how to get its filename changed
    i really just started doin things with applescript for a day so i hope you can help me
    regards
    DaNylz
    Message was edited by: DaNylz

    Try something like this:
    set myFoundItems to change text text of all page items of pages 3 thru 5 of document 1
    Shane Stanley <[email protected]>
    AppleScript Pro Sessions <http://scriptingmatters.com/aspro>

  • Can't Upload SQL scripts or application scripts in APEX 3.1

    I have installed APEX 3.1 on an Oracle 10g database.
    I can log in to APEX, create applications, and run applications.
    One application I import is the sample OEHR application which imports correctly at the hosted site.
    However, when I try to upload an SQL script or import the sample application I get
    "Page not Found" for this page http://csora:7777/pls/apex/wwv_flow.accept
    I've included my dads.conf below and also some Apache error entries
    Alias /i/ "e:\oracle\product\10.1.0\Db\Apache\Apache\images/"
    AddType text/xml     xbl
    AddType text/x-component     htc
    <Location /pls/apex>
    Order deny,allow
    PlsqlDocumentPath docs
    AllowOverride None
    PlsqlDocumentProcedure      wwv_flow_file_mgr.process_download
    PlsqlDatabaseConnectString     csora:1521:ORCL ServiceNameFormat
    PlsqlNLSLanguage          AMERICAN_AMERICA.AL32UTF8
    PlsqlAuthenticationMode     Basic
    SetHandler          pls_handler
    PlsqlDocumentTablename     wwv_flow_file_object$
    PlsqlDatabaseUsername     APEX_PUBLIC_USER
    plsqlDefaultPage          apex     
    PlsqlDatabasePassword     hocking
    Allow from all
    </Location>
    I:[Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2864:2873,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/topnav2.gif
    [Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2924:2771,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/left_curve.gif
    [Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2944:2767,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/left_curve.gif
    [Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2972:2750,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/right_curve.gif
    [Mon Apr 14 15:52:35 2008] [error] [client 10.116.101.158] [ecid: 1208202755:198.30.4.195:2696:2940:2762,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/right_curve.gif
    [Mon Apr 14 16:19:33 2008] [error] [client 10.116.101.158] [ecid: 1208204373:198.30.4.195:2696:2924:2773,0] File does not exist: e:/oracle/product/10.1.0/db/apache/apache/htdocs/pls/htmldb/builder/topnav2.gif
    [Mon Apr 14 16:21:48 2008] [error] [client 10.116.101.158] [ecid: 1208204507:198.30.4.195:2696:2948:2801,0] mod_plsql: /pls/apex/wwv_flow.accept HTTP-404 ORA-00942: table or view does not exist
    [Mon Apr 14 16:23:29 2008] [error] [client 10.116.101.158] [ecid: 1208204609:198.30.4.195:2696:2788:2760,0] mod_plsql: /pls/apex/wwv_flow.accept HTTP-404 ORA-00942: table or view does not exist
    [Mon Apr 14 16:23:29 2008] [error] [client 10.116.101.158] [ecid: 1208204609:198.30.4.195:2696:2788:2761,0] mod_wchandshake: incorrect uri: name="p_t04" passed in.
    [Mon Apr 14 16:23:29 2008] [error] [client 10.116.101.158] [ecid: 1208204609:198.30.4.195:2696:2788:2761,0] Invalid URI in request -data; name="p_t04"
    Am I missing some files or directories from the 3.1 install? Any help would be appreciated since I think I'm close to having APEX fully functional.

    Val,
    In this line:
    PlsqlDocumentTablename wwv_flow_file_object$
    ...that needs to be wwv_flow_file_objects$
    Scott

  • How to test a simple PL SQL function from another PL SQL script

    Hi,
    I have created a function. Now i need to test that whether it is returning the correct values or not.
    For that, i have written anothe pl sql script and trying to call this function. Im passing all the IN parameters in that function. I assume here that OUT parameters will provide me the result. Im trying to display the OUT parameter one by one to see my result.
    I'm using toad as sql client here connected with oracle.
    pl sql script:-
    DECLARE
    BEGIN
         DBMS_OUTPUT.PUT_LINE('$$$$$$$ VINOD KUMAR NAIR $$$$$$$');
         FETCH_ORDER_PRODUCT_DATA(320171302, 1006, 6999,
    ODNumber OUT VARCHAR2, Line_Number OUT VARCHAR2,
    ServiceID OUT VARCHAR2, BilltoNumber OUT VARCHAR2,
    AnnualPrice OUT NUMBER, CoverageCode OUT VARCHAR2)
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | ODNumber );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | Line_Number );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | ServiceID );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | BilltoNumber );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | AnnualPrice );
    DBMS_OUTPUT.PUT_LINE('HERE IS THE RESULT ' | CoverageCode );
    END;
    Function:-
    Program Name : SPOT_Order_Product_Data_For_CFS.sql
    Description : Function to Validate parameters from CFS
    By : Vinod Kumar
    Date : 08/19/2011
    Modification History
    By When TAR Description
    CREATE OR REPLACE FUNCTION FETCH_ORDER_PRODUCT_DATA(orderNumber IN VARCHAR2, customerNumber IN VARCHAR2,
    productLine IN VARCHAR2, ODNumber OUT VARCHAR2,
    Line_Number OUT VARCHAR2, ServiceID OUT VARCHAR2,
    BilltoNumber OUT VARCHAR2, AnnualPrice OUT NUMBER,
    CoverageCode OUT VARCHAR2)
    RETURN VARCHAR2 IS
    lv_err_msg VARCHAR2(100) := '';
    lv_bucket_id VARCHAR2(14);
    lv_bill_number VARCHAR2(30);
    lv_anual_price NUMBER;
    lv_coverage_code VARCHAR2(8);
    lv_quote_num NUMBER(10) := NULL;
    lv_line_num NUMBER(5) := 0;
    lv_customer_number VARCHAR2(30) := customerNumber;
    lv_product_id VARCHAR2(14) := productLine;
    lv_count_quote NUMBER := 0;
    lv_quote_status VARCHAR2(5);
    lv_quote_version NUMBER(2):=0;
    BEGIN
    IF INSTR(orderNumber, '-') = 0 THEN
    lv_quote_num := orderNumber;
    ELSE
    lv_quote_num := SPT_Delimiter(orderNumber, 1, '-');
    lv_line_num := SPT_Delimiter(orderNumber, 2, '-');
    END IF;
    --Check status of the quote COM, APP
    SELECT COUNT(*) INTO lv_count_quote FROM sot_order_header WHERE ORDER_NUMBER=lv_quote_num
    AND ORDER_STATUS IN ('APP', 'COM') AND CUSTOMER_NUMBER = lv_customer_number;
    IF lv_count_quote = 0 THEN
    lv_err_msg := 'Invalid Order number';
    RETURN lv_err_msg;
    END IF;
    -- Fetch the latest version on SPOT quote
    SELECT MAX(VERSION_NUMBER) INTO lv_quote_version FROM SPT_QUOTE_HEADER WHERE QUOTE_NUMBER = lv_quote_num
    AND CUSTOMER_NUMBER = lv_customer_number;
    -- If quote is valid fetch the data in OUT parameters
    IF lv_line_num = 0 THEN
    BEGIN
    SELECT a.CUSTOMER_BILLTO_NUMBER,
    b.LINE_NUMBER, b.BUCKET_ID,
    b.ANNUAL_REF_RATE_USD, b.COVERAGE_CODE
    INTO lv_bill_number,lv_line_num,lv_bucket_id,lv_anual_price,lv_coverage_code
    FROM SPT_QUOTE_HEADER a, SPT_QUOTE_LINE b
    WHERE a.QUOTE_NUMBER = lv_quote_num
    AND a.CUSTOMER_NUMBER = lv_customer_number
    AND a.VERSION_NUMBER = lv_quote_version
    AND a.QUOTE_NUMBER = b.QUOTE_NUMBER
    AND a.VERSION_NUMBER = b.VERSION_NUMBER
    AND b.PRODUCT_ID = lv_product_id;
    ODNumber := lv_quote_num;
    BilltoNumber := lv_bill_number;
    Line_Number := lv_line_num;
    ServiceID := lv_bucket_id;
    AnnualPrice := lv_anual_price;
    CoverageCode := lv_coverage_code;
    RETURN '';
    EXCEPTION WHEN OTHERS THEN
    lv_err_msg := 'Multiple PIDs existing in the SPOT order, please provide the SPOT order + line number as input data';
    RETURN lv_err_msg;
    END;
    ELSE
    BEGIN
    SELECT a.CUSTOMER_BILLTO_NUMBER,
    b.BUCKET_ID, b.ANNUAL_REF_RATE_USD,
    b.COVERAGE_CODE
    INTO lv_bill_number,lv_bucket_id,lv_anual_price,lv_coverage_code
    FROM SPT_QUOTE_HEADER a, SPT_QUOTE_LINE b
    WHERE a.QUOTE_NUMBER = lv_quote_num
    AND a.CUSTOMER_NUMBER = lv_customer_number
    AND a.VERSION_NUMBER = lv_quote_version
    AND a.QUOTE_NUMBER = b.QUOTE_NUMBER
    AND a.VERSION_NUMBER = b.VERSION_NUMBER
    AND b.PRODUCT_ID = lv_product_id
    AND b.LINE_NUMBER = lv_line_num;
    ODNumber := lv_quote_num;
    BilltoNumber := lv_bill_number;
    Line_Number := lv_line_num;
    ServiceID := lv_bucket_id;
    AnnualPrice := lv_anual_price;
    CoverageCode := lv_coverage_code;
    RETURN '';
    EXCEPTION WHEN OTHERS THEN
              lv_err_msg := 'Multiple SPOT lines exist with same parameter';
              RETURN lv_err_msg;
    END;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    lv_err_msg := '@@@ EXCEPTION THROWN @@@ '|| SUBSTR(SQLERRM,1,120);
    RETURN lv_err_msg ;
    END;
    Don't look at the function, it might have errors but my primary concern is how to test this function. Once I start doing its testing then only i can understand any bugs(if any).
    My pl sql is not so good. Im still learning. I don't understand IN and OUT parameters are.
    I just know that IN parameters r those whick we pass in to the function wen we call it and OUT parameters are those through which we get the result.
    Thanks in advance
    Vinod Kumar Nair

    20100511 wrote:
    I wondered how I could test the output of the function from within TOAD?I usually create the following function in my developer schema:
    create or replace function BoolToChar( b boolean ) return varchar2 is
    begin
      if b then
        return( 'TRUE' );
      else
        return( 'FALSE' );
      end if;
    end;To test a function like yours, the following will do in SQL*Plus/TOAD/etc:
    begin
      DBMS_OUTPUT.put_line(
        BoolToChar( XCCC_PO_APPROVALLIST_S1.does_cpa_exist(1017934)  )
    end;
    I'm probably doing 101 things wrong here, but thought I'd ask anyway and risk being shouted at.Shout at? You reckon? I thought people risked being beaten with a lead pipe, or pelted with beer cans and stale pretzels - which makes being shouted at a really safe and viable alternative. {noformat};-){noformat}

  • Folder action to find and replace text and change line feeds

    I want to use a folder action to find and replace text and change Mac carriage returns to DOS line feeds inside text files.
    The text to be replaced is: "/Users/wim/Music/iTunes/iTunes Music/Music" (without the quotes)
    This text has to be removed (i.e. replaced by an empty string)
    The text occurs many times within each file.
    The files are playlists exported from iTunes in the M3U format (which are text files). They contain Mac carriage returns. These need to be changed to DOS line feeds.
    I have found the following two perl commands to achieve this:
    To find and replace text: perl -pi -w -e 's/THIS/THAT/g;' *.txt
    To change carriage returns to line feeds: perl -i -pe 's/\015/\015\012/g' mac-file
    I know that it's possible to make a folder action with Automator that executes a shell script.
    What I want to do is drop the exported playlists in M3U format in a folder so that the folder action will remove the right text and change the carriage returns.
    My questions are:
    Is it possible to make a folder action that executes command line commands instead of shell scripts?
    What is the correct syntax for the two commands when used in a folder action shell script? Especially, how do I escape the slashes (/) in the string to be removed?
    Thanks for your help

    Ok, I've include an applescript to run a shell command. The applesript command quoted form makes a string that will end up as a single string on the bash command line.  Depending on what you want to do, you may need multiple string on the bash command lines.  I've included some information on folder actions.
    It is easier to diagnose problems with debug information. I suggest adding log statements to your script to see what is going on.  Here is an example.
        Author: rccharles
        For testing, run in the Script Editor.
          1) Click on the Event Log tab to see the output from the log statement
          2) Click on Run
        For running shell commands see:
        http://developer.apple.com/mac/library/technotes/tn2002/tn2065.html
    on run
        -- Write a message into the event log.
        log "  --- Starting on " & ((current date) as string) & " --- "
        --  debug lines
        set desktopPath to (path to desktop) as string
        log "desktopPath = " & desktopPath
        set unixDesktopPath to POSIX path of desktopPath
        log "unixDesktopPath = " & unixDesktopPath
        set quotedUnixDesktopPath to quoted form of unixDesktopPath
        log "quoted form is " & quotedUnixDesktopPath
        try
            set fromUnix to do shell script "ls -l  " & quotedUnixDesktopPath
            display dialog "ls -l of " & quotedUnixDesktopPath & return & fromUnix
        on error errMsg
            log "ls -l error..." & errMsg
        end try
    end run
    How to set up a folder action.
    1) right click on folder. click on Enable folder actions
    2) Place script in
    /Library/Scripts/Folder Actions Scripts
    3) right click on folder. click on attach folder action
    pick your script.
    Create a new folder on the desktop & try.
    You can put multiple folder actions on a folder. There are other ways of doing this.
    Here is my test script:
    on adding folder items to this_folder after receiving dropped_items
        repeat with dropped_item_ref in dropped_items
           display dialog "dropped files is " & dropped_item_ref & " on folder " & this_folder
        end repeat
    end adding folder items to
    How to  make the text into an AppleScript program.
    Start the AppleScript Editor
    /Applications/AppleScript/Script Editor.app
    In Snow Leopard it's at: /Applications/Utilities/AppleScript Editor
    Copy the script text to the Applescript editor.
    Note: The ¬ is typed as option+return.  ption+return is the Applescript line continuation characters.
    You may need to retype these characters.
    Save the text to a file as an script and do not check any of the boxes below.

  • How to reference dynamic parameters in the PL/SQL script

    The meaning of dynamic parameter is the position and name of parameters will be changed based on the data structure of a referenced text file reading by the concerned PL/SQL script. Anybody can post a sample code will be very appreciated.

    The SQL and PL/SQL discussion forum is a good source for this kind of information.
    The URL is:
    PL/SQL

Maybe you are looking for

  • When I'm printing a photo it tells me there are no themes installed.

    When I am printing photos in iphoto it tells me I can't because there are no themes attatched.

  • Convenience Key on my Torch does not work

    Hi Everyone! Seek your help as the convenience key on my torch does not work. I have changed the setting as well but to no avail. Regards - Nitin Solved! Go to Solution.

  • Business Role

    Hi, When changed the Business Role to Service Professional in the Position in the Organisation but it is not showing any impact in the Web UI screen. It is still showing the same earlier one--> Sales. I would highly appreciate if someone helps to res

  • Help! JDev will not validate JSTL 1.1 c.tld from Jakarta

    What schema or DTD does JDev use to validate tlds (or any XML, for that matter)? I am using JDev Version 10.1.2.0.0 (Build 1811). Following is a list of the first 10 (of 101) errors produced when trying to run a project using the JSTL 1.1 c.tld from

  • User Exit for Material Plan Costs

    I have an escenario where the client needs another option to calculate the material plan costs, but need to identify the correct user exit. In transaction OKYF exist the option "U Valuation Price with User Exit" but need the user exit to use. Hope to