Stored Procedure - Split one Input Paramater into two Paramater

What is expected from me
1) I am getting a input parameter as a string (url+id)with two delimiters(, and |) i.e 'html\abc.com,http\efc.com|112'
Logic: If ID is not in the table or if ID is not there in input parameter then return null
else
send ID and URL from the table
The way I am tackling aforesaid as I am new in Oracle PL/SQL
1) I have two separate split function one to tackle , (comma) other to tackle |(pipe) which i got from NET
2) I am creating 2 table with 2 columns (ID(identity),val)
3) I am splitting input parameter and pushing result in first table where ID will always be second record
so if count(*) = 1
then return nothing (as there is no ID to map in the table)
else
4) splitting first row and pushing result in second table and then mapping with the table if its there then returning the val back...
Here is the code Please let me know where i am going wrong?? where i have to correct??
CREATE OR REPLACE
PROCEDURE ap_dbi_ps_PM_Search
v_PAGE_CTX IN VARCHAR2,
v_CTX_ID IN NUMBER DEFAULT NULL ,
v_Count IN NUMBER DEFAULT NULL ,
cv_1 IN OUT SYS_REFCURSOR )
AS
---tblPM table 2 columns id (idendity) and val
CREATE SEQUENCE tb1PM_id START WITH 1 INCREMENT BY 1;
CREATE TABLE tb1PM
( id NUMBER(10,0) PRIMARY KEY, Val VARCHAR2(400)
CREATE OR REPLACE TRIGGER tb1PM_id_TRG BEFORE
INSERT ON tb1PM FOR EACH ROW BEGIN
SELECT tb1PM_id.NEXTVAL INTO :NEW.id FROM DUAL;
END;
-- tblPM1 table 2 columns id (idendity) and val
CREATE SEQUENCE tb1PM1_id START WITH 1 INCREMENT BY 1;
CREATE TABLE tb1PM1
( id NUMBER(10,0) PRIMARY KEY, Val VARCHAR2(400)
CREATE OR REPLACE TRIGGER tb1PM1_id_TRG BEFORE
INSERT ON tb1PM1 FOR EACH ROW BEGIN
SELECT tb1PM1_id.NEXTVAL INTO :NEW.id FROM DUAL;
END;
--Split the input paramater and push result in tblPM*
INSERT
INTO tb1PM
val
(SELECT * FROM TABLE ( CAST(split('v_PAGE_CTX') AS split_tbl))
DECLARE
v_Count NUMBER
10,0
DECLARE
V_CTX_ID NUMBER
10,0
SET V_CTX_ID =
(SELECT DISTINCT TO_NUMBER(val) FROM tb1PM WHERE id = 2
SET v_Count =
(SELECT COUNT(*) FROM tb1PM
BEGIN
IF v_Count = 2 THEN
INSERT
--Split URL's from tblPM*
INTO tb1PM1
val
(SELECT *
FROM TABLE(splitcomma(
JOIN(CURSOR
(SELECT val FROM tb1PM WHERE id =1
OPEN cv_1 FOR SELECT PAGE_DISPLAY_URL,
CTX_ID FROM portal_mapping WHERE CTX_ID = V_CTX_ID group by V_CTX_ID HAVING v_PAGE_DISPLAY_URL IN
( SELECT DISTINCT val FROM tb1PM1
RETURN;
DROP TABLE tb1PM;
DROP TRIGGER tb1PM_id_TRG;
DROP SEQUENCE tb1PM_id;
DROP TABLE tb1PM1;
DROP TRIGGER tb1PM1_id_TRG;
DROP SEQUENCE tb1PM1_id;
ELSE
EXCEPTION
WHEN OTHERS THEN
-- NULL;
END IF;
END;
show errors;
ERROR which I am getting is
Warning: execution completed with warning
PROCEDURE ap_dbi_ps_PM_Search Compiled.
24/1 PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
begin function pragma procedure subtype type <an identifier>
<a double-quoted delimited-identifier> current cursor delete
exists prior external language

You have to learn how to write the procedure before you could write one. I just corrected the syntax errors. I did not paid attention to your logical errors. This one compiled without errors other than the table does not exists. My doubt is If you are creating the tables in the procedure, how will the tables already have data?
CREATE OR REPLACE PROCEDURE ap_dbi_ps_PM_Search ( v_PAGE_CTX IN VARCHAR2, v_CTX_ID IN NUMBER DEFAULT NULL , v_Count IN NUMBER DEFAULT NULL , cv_1 IN OUT SYS_REFCURSOR )
AS
BEGIN
---tblPM table 2 columns id (idendity) and val
execute immediate 'CREATE SEQUENCE tb1PM_id START WITH 1 INCREMENT BY 1';
execute immediate 'CREATE TABLE tb1PM ( id NUMBER(10,0) PRIMARY KEY, Val VARCHAR2(400) )';
execute immediate ' CREATE OR REPLACE TRIGGER tb1PM_id_TRG BEFORE INSERT ON tb1PM FOR EACH ROW BEGIN  SELECT tb1PM_id.NEXTVAL INTO :NEW.id FROM DUAL; END';
-- tblPM1 table 2 columns id (idendity) and val
execute immediate 'CREATE SEQUENCE tb1PM1_id START WITH 1 INCREMENT BY 1';
execute immediate 'CREATE TABLE tb1PM1 ( id NUMBER(10,0) PRIMARY KEY, Val VARCHAR2(400) )';
execute immediate 'CREATE OR REPLACE TRIGGER tb1PM1_id_TRG BEFORE INSERT ON tb1PM1 FOR EACH ROW BEGIN SELECT tb1PM1_id.NEXTVAL INTO :NEW.id FROM DUAL; END';
--Split the input paramater and push result in tblPM
execute immediate 'INSERT INTO tb1PM ( val ) (SELECT * FROM TABLE ( CAST(split( ''v_PAGE_CTX '') AS split_tbl)) )';
-- SET V_CTX_ID = (SELECT DISTINCT TO_NUMBER(val) FROM tb1PM WHERE id = 2 ) ;
select distinct to_number(val)  into v_ctx_id from tb1PM where id = 2;
-- SET v_Count = (SELECT COUNT(*) FROM tb1PM ) ;
select count(*) into v_count from tb1PM;
IF v_Count = 2 THEN
INSERT INTO tb1PM1 ( val )
    (SELECT * FROM TABLE(splitcomma( JOIN(CURSOR (SELECT val FROM tb1PM WHERE id =1 ) ) ) ) );
OPEN cv_1 FOR SELECT PAGE_DISPLAY_URL, CTX_ID FROM portal_mapping WHERE CTX_ID = V_CTX_ID group by V_CTX_ID HAVING v_PAGE_DISPLAY_URL IN
    ( SELECT DISTINCT val FROM tb1PM1 );
RETURN;
END IF;
END;
EXCEPTION
WHEN OTHERS THEN
  DROP TABLE tb1PM;
  DROP TRIGGER tb1PM_id_TRG;
  DROP SEQUENCE tb1PM_id;
  DROP TABLE tb1PM1;
  DROP TRIGGER tb1PM1_id_TRG;
  DROP SEQUENCE tb1PM1_id;
END;

Similar Messages

  • Split one salesorder item into two items in delivery

    We want to split one salesorder item into two different items in the same delivery.
    This is because we will pick the material from two different storage locations.
    Any user-exit to use for solving this?
    Best regards,
    Terje

    Hi,
    We are not using batch management.
    I have looked into the foreign trade/customs standard functionality in SAP, but I can not see that them difference in stock in SAP what is duty paid or not.
    We need to have documentation in the system for the custom goverement for what stock is duty paid and not.
    For the same material we can have stock which are duty paid and not duty paid. This is decided when we do the goods receipt.
    For stock coming from Asia, it is profitable to have this on not duty paid stock since we are exporting it back to Europe and Asia later.
    We will send import and export EDI messages to a third party custom application handling all the papers with the custom goverement.
    The only we need to make track on in SAP is the stock for what is duty paid and not.
    In some situations we need to take stock from both duty paid stock and not duty paid stock when we deliver the same material to a customer. Therefor I asked the question of splitting one delivery item into two items.
    Best regards,
    Terje

  • SLT - Splitting one source table into two tables in the destination

    Hi,
    I am wondering if we can split content of one source table into two different tables in the destination (HANA DB in my case) with SLT based on the codified mapping rules?
    We have the VBAK table in ERP which has the header information about various business objects (quote, sales order, invoice, outbound delivery to name a few). I want this to be replicated into tables specific to business object (like VBAK_QUOT, VBAK_SO, VBAK_INV, etc) based on document type column.
    There is one way to do it as far as i know - have multiple configurations and replicate to different schema. But we might have to be content with 4 different config at the max.
    Any help here will be highly appreciated
    Regards,
    Sesh

    Please take a look at these links related to your query.
    http://stackoverflow.com/questions/5145637/querying-data-by-joining-two-tables-in-two-database-on-different-servers
    http://stackoverflow.com/questions/7037228/joining-two-tables-together-in-one-database

  • How do I split one Apple account into two accounts?

    I have 2 iphones using one Apple ID.  The apps are completely different on the 2 phones (wife's stuff, my stuff).  I would like to split them into two Apple ID's so I can keep them completely separate.  Any ideas?

    Sorry, but there is no way to "move" an app from one iTunes Store account to another.
    Regards.

  • Split one column value into two columns using t-sql

    Hi All,
    I have one varchar column in a table.
    Col1
    ABC-12C4
    BC-A345
    CD
    XYZ
    How to split this into two columns like this using t-sql
    Col1   Col2
    ABC    12C4
    BC      A345
    CD     
    XYZ
    Thanks,
    RH
    sql

    assuming a static delimiter, and the split will end up with a max of 2 columns, something like this would work.  basically you just need to determine where the delimiter is, and then use the left and right functions to find the 2 pieces.
    declare @t table(value varchar(10))
    insert into @t(value)
    values
    ('ABC-12C4'), ('BC-A345'), ('CD'), ('XYZ')
    select
    case
    when charindex('-', value) != 0 then left(value, charindex('-', value) - 1)
    else value
    end as col1,
    case
    when charindex('-', value) != 0 then right(value, len(value) - charindex('-', value))
    else ''
    end as col2
    from @t

  • Split one PI System into two new PI systems

    Hello,
    I support one PI System from our company.
    My company would be splitted into 2 new companies.
    My Question about the PI system:
    Alternative 1:
    I will be crate 2 new PI Systems (one for company 1 and one for company 2)
    - I will be move the content from IR and ID to the new Systems (File Level Transport or CMS).
    - Is it possible, to move the messages and the payload of the processed messages (from the past) with the archive function ??
    Alternative 2:
    I use the existing PI system and dont create 2 new PI systems.
    - could I measure the PI traffic for the new company one and the new company two  separately ?? (I will be use differnt message interface names for any company)
    Whats the better way (alternative 1 or alternative 2) ?
    Thank you in advance
    Uwe

    Hi,
    We can create two PI systems for new companies but configure SLD centrally so that we can work/configure SLD objects easily for three systems. meanwhile configure IR/ID objects separately for each system for data flow variation. Meanwhile IR/ID objects we can import/export easily with IR/ID windows import/export option.

  • Splitting one photo book into two?

    Hi, I have prepared one photo book (project) with iPhoto using the maximum of 100 pages (3 weeks US!!). Now, a friend shared his pics with me that I'd like to add. Can I split the one book in two with say 50 pages and continue addingnew pages with the spliited ones?
    Plus: Can I move complete pages from one iPhoto book to another project (book)?
    Thx for your help!
    Frank

    Select the book in the left hand pane and type Command+D (duplicate).  You can then modify each of the copies as needed.
    OT

  • Split one Post OFfice in two parts

    Hi there!
    I have problems with my Poa, because I'm having problems with I/O. Despite of all,
    my POA is about 250 GB and I think that it's pretty big. So I have a lot of "batch users"
    that are receiving a lot of emails with low priority, and I am thinking in split my post office
    in two parts:
    1) personal/phyisical users (humans): my actual post office. With SAN storage (expensive)
    and priority backups.
    2) non humans: batch users, iScsi storage , cheap and only a backup in saturday.
    The question is: I saw that there is a procedure to move an user from one post office
    to another, but these users have a lot of proxy accesses and rules. These options
    are saved in the move? I mean, there are rules for forward emails to users in post office 1).
    Does the system relocalize these users from post office 2) in post office 1) ?
    I know that the best test would test with one test user... but just in case.
    Thank you all!

    In article <[email protected]>,
    Antoniogutierrez wrote:
    > I have problems with my Poa, because I'm having problems with I/O.
    > Despite of all,
    instead of putting a lot of effort into splitting this little
    PostOffice into two, how about looking at the I/O challenges as fixing
    them might be much more effective. Might even help you elsewhere as
    well.
    What plateform are you running on? Hypervisor? What is the storage
    access type?
    What are the particular I/O challenges you are hitting?
    Andy of
    http://KonecnyConsulting.ca in Toronto
    Knowledge Partner
    http://forums.novell.com/member.php/75037-konecnya
    If you find a post helpful and are logged in the Web interface, please
    show your appreciation by clicking on the star below. Thanks!

  • Java Stored Procedure in one database connecting to muntiple databases.

    Hello,
    I created a Java Stored Procedure in one database(Oracle10g) and successfully open a connection to another database(Oracle10g) using Thin JDBC Driver. I want to actually transfer CLOB data from one DB to another DB. I am concern that by opening a connection another database in Java Stored Procedure, might interfere with oracle and destabilize the instance at some point. Oracle JDBC FAQ (Link: http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#34_13) stated that Yes it could be done but then mentioned the workaround.(if it could be done why do we need a workaround!!!)
    I would like to confirm whether connecting to multiple DB using JDBC Thin Driver in a Java Stored Procedure is supported by Oracle10g or not and whether it has any known issue with it.
    Thanks in Advance!
    Edited by: user649261 on Sep 16, 2008 8:05 PM

    hrishy wrote:
    Thanks i have modified the title so its easy to comprehendWrite the two parts mentioned above and post if you get problems with your code.
    First write code that calls the stored procedure and test that to make sure that it works.
    Then write a simple webservice and test it out to make sure it works. The integration should be trivial after that.

  • Splitting my Adobe ID into two accounts / transfering registrations

    How can I split my Adobe ID into two accounts, and transfer registrations from one to another?
    Background: our company has split into two companies.

    You'll need to contact web chat:
    Adobe ID, sign in, and account help

  • How to split one pdf form into multiple forms

    Is it possible to split one PDF form into three separate forms without recreating each one?

    Sure, just extract the pages to a new file. The form fields will stay in
    place.

  • How do I split up a project into two or more projects?

    How do I split up a project into two or more projects?

    Select the Images you want to put in the new Project and then run "File➞New➞Project" and check "Move selected items to new project".

  • One iTunes account into two via home share

    My wife and I have been sharing one iTunes account for years. We now have two iMac and so I'd like to separate into two accounts by retaining my original account on my imac and creating a new itunes account on her iMac. Her iMac is the one with the original account. Her ipod is tied to that computer and my account but I'd like her ipod tied to the new account so she can start making purchases that do not show up under my account and on my imac/ipad.
    I understand that this process is not possible since apps and songs are liscensed under one user. However, I can easily redownload the apps my wife uses (15 or so, most of which are free). It's the iTunes store bought music I am unclear about.
    I've done a bit of researching and have come to an idea that may work but I'd like feedback from those more in the know than I.
    So, I'd like to run this process by all of you out there and ask if this sounds right.
    My imac is all set with my account.
    Wifes iMac: (Core i7, 10.6.8, current iTunes)
    - Set-up wife's iMac with a new itunes account.
    - Turn on that account in iTunes (authorize to computer to this new account)
    - Home Sharing is on (purchased music on her computer under my account but not on my computer... I don't listen to Amy Winehouse)
    - Connect her ipod (Touch gen 2) to her iMac and update as new account.
       -this may delete all songs on her ipod but with home sharing can I just reload the music from the itunes library?
      -Will I be able to load the store purchased music that resides on her imac onto her ipod touch with the new account on it?  
      - Or will she have to "authorize" each and every song as the ipod plays them???
    – Redownload wifes previous free apps (downloaded under my name) under her new account.
    The end result is I'd like any new purchases of songs or apps to be under her new account but still retain the music she purchased under my account on her ipod. Thus she can purchase on the device and it will update in itunes on iMac.
    Does this make sense? Will this work?
    Thanks,

    I just got zapped by this crazy conundrum yesterday. I bought a used ipad1 thru EBay, for my son. He doesn't have home Internet or an up to date Mac so I set it up for him on my computer, unaware of the 90-day lockout rule.  He owns a lot of iTunes downloads and I thought input would be faster to do it wired to my computer rather than via wireless direct onto his iPad, so I logged out of my account and into his. When I was done downloading his stuff I logged out of his account and got the 90-day lockout notice when I logged back into my account!
    Thanks to all the posters here and other similar threads I learned what had happened, but until I got to this thread I thought I was locked out of ALL downloads, including new purchases. Thanks for the info about it just being for re-downloads. Fortunately, I am obsessive about backing up all new purchases in a master iTunes file.  It just seems kinda stupid. What is the point in locking me out of things I already own? Anyway, thanks for the help!
    Just tested on my computer and was indeed able to download a new album from iTunes on my account.
    As far as sharing between devices is concerned, I have separate iTunes folders for each of 4 iOS devices I use, and simply use the "Add to library" feature in iTunes to copy anything I need to from one device's folder to the other. Works well.

  • Help on writing pl/sql stored procedure to accept input in xml format

    Hi All,
    I need to write a pl.sql stored procedure which would be getting the input as an xml.
    The requirement is that xml data recieved in below fashion needs to be inserted to 3 different tables.
    The tags under the root node directly needs to be inserted into Table1
    The tags under the first element of the root node needs to be inserted into Table2
    Can anybody help me on how to write a stored procedure which could take up the below xml as input and insert the data received into 3 different tables.
    Any sample code.pointers to achieve this could be of great help.
    The structure of the xml would be as follows:
    <AssemblyProduct>
    <AssemblyHeader>
    <Name></Name>
    <AssemblyId></AssemblyId>
    <ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
    <ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
    <ListOfHCSIFFs><HCSIFFHeader><Id></Id> </HCSIFFHeader> </ListOfHCSIFFs>
    </AssemblyHeader>
    <AssemblyHeader>
    <Name></Name>
    <AssemblyId></AssemblyId>
    </AssemblyHeader>
    <AssemblyHeader></AssemblyHeader>
    <ApplicationId></ApplicationId>
    <ApplicationName></ApplicationName>
    <ApplicationValidFrom></ApplicationValidFrom>
    <ApplicationValidTo></ApplicationValidTo>
    </AssemblyProduct>

    Well you could write your procedure to accept a parameter of XMLTYPE datatype and then use that value in a query inside the procedure to break the data up as required using something like XMLTABLE e.g.
    -- Nested repeating groups example:
    WITH t as (select XMLTYPE('
    <RECSET>
      <REC>
        <COUNTRY>1</COUNTRY>
        <POINT>1800</POINT>
        <USER_INFO>
          <USER_ID>1</USER_ID>
          <TARGET>28</TARGET>
          <STATE>6</STATE>
          <TASK>12</TASK>
        </USER_INFO>
        <USER_INFO>
          <USER_ID>5</USER_ID>
          <TARGET>19</TARGET>
          <STATE>1</STATE>
          <TASK>90</TASK>
        </USER_INFO>
      </REC>
      <REC>
        <COUNTRY>2</COUNTRY>
        <POINT>2400</POINT>
        <USER_INFO>
          <USER_ID>3</USER_ID>
          <TARGET>14</TARGET>
          <STATE>7</STATE>
          <TASK>5</TASK>
        </USER_INFO>
      </REC>
    </RECSET>') as xml from dual)
    -- END OF TEST DATA
    select x.country, x.point, y.user_id, y.target, y.state, y.task
    from t
        ,XMLTABLE('/RECSET/REC'
                  PASSING t.xml
                  COLUMNS country NUMBER PATH '/REC/COUNTRY'
                         ,point   NUMBER PATH '/REC/POINT'
                         ,user_info XMLTYPE PATH '/REC/*'
                 ) x
        ,XMLTABLE('/USER_INFO'
                  PASSING x.user_info
                  COLUMNS user_id NUMBER PATH '/USER_INFO/USER_ID'
                         ,target  NUMBER PATH '/USER_INFO/TARGET'
                         ,state   NUMBER PATH '/USER_INFO/STATE'
                         ,task    NUMBER PATH '/USER_INFO/TASK'
                 ) y
       COUNTRY      POINT    USER_ID     TARGET      STATE       TASK
             1       1800          1         28          6         12
             1       1800          5         19          1         90
             2       2400          3         14          7          5And then you can extract and insert whatever parts you want into whatever tables as part of the procedure.

  • Creating stored procedure to import csv data into tables

    I am trying to create a stored procedure to import data from a csv file into a table. I tried using sqlldr but could not run it at school due to access permissions that they will not change. So I looked at the utl_package and from what I can see it requires a "virtual" directory, which conflicts with the access permissions again at school. So can I create a stored procedure that will just read data from a csv file into a table without the need to write or create a file/directory.
    Thankyou

    Satyaki_De wrote:
    Since, you are talking about so much restriction - i don't think you will get that.
    One alternative solution can be -> write a java based pl/sql procedure and try load that by parsing it. But, for that you need execute privileges on dbms_java package.
    Do you have that? I doubt.
    Regards.
    Satyaki De.Nope not allowed to use java, and im new to oracle. Why can't a stored procedure in pl/sql just read a file and put the data into a table I create prior?

Maybe you are looking for

  • After Update to 3.2.2 12/10/2011, I can't open...

    I have used aperture for months, it can be buggy, crashes during import and has it's issues, but I have liked the software as a whole....  Today my aperture crashed during use. I restarted my computer and I upgraded to the newest version. After the u

  • How can I deauthorize iTunes on my PC that doesn't have iTunes installed (crashed with latest update)?

    I'm retiring my old PC and want to deauthorize my purchased iTunes library (over 1,000 songs) but have a problem.  The last time I tried to update iTunes on the computer, the installation crashed and iTunes was removed.  My music is still there.  I j

  • Error Landed Cost - Customs rate not valid (SAP B1 9.0 PL10)

    Hello experts, We would like your advise on the following issue. We are currently using SAP Business One 9.0 (PL10) and we are trying to add a Landed Cost document, but the following error occurs: Customs rate not valid.  [Landed Costs - Rows - Duty

  • How to pass command line parameters in calling ant file

    Hi All, I m using a Build file which calls another build file. That build file is run from the command prompt by give ant -lib <path of jars it needs for executing>. Now i m calling this file from main build file but it does not work as i m not able

  • Screen Sequence Groups in SD for VA01 Transaction

    Hi Experts, Are these SD screen sequences configurable?  I need to copy Screen Sequence Group in SD to add additional field.  Is it possible? I've assigned 'AU' screen seq. group in Transaction Flow of VOV8 tcode for my Sales Ord Type. SM31 maintain