Multiple nested statements - searching out erroneus posts

Hi!
I have a problem which occurs when there are connection problems to the database and objects are not saved properly.
I have the following tables:
MEETING
MEETINGID
1
2
3
MEETING_CUSTOMERS
MEETINGID--------CUSTOMERID
1----------------------XXXX
1----------------------YYYY
1----------------------ZZZZ
2----------------------AAAA
3----------------------BBBB
SHOPPINGCART
SHOPPINGCARTID------------CUSTOMERID
1-----------------------------------AAAA
2-----------------------------------BBBB
3-----------------------------------XXXX
4-----------------------------------YYYY
5-----------------------------------ZZZZ
SHOPPINGCART_PRODUCTS
SHOPPINGCARTITEMID----------SHOPPINGCARTID-----------PARENTID
1----------------------------------------1-----------------------------------NULL
2----------------------------------------2-----------------------------------1
3----------------------------------------2-----------------------------------NULL
4----------------------------------------3-----------------------------------5
5----------------------------------------4-----------------------------------NULL
6----------------------------------------5-----------------------------------NULL
MEETINGID is PK in MEETING and FK in MEETING_CUSTOMERS, one meeting can have many customers. One customer can only be in one salesmeeting.
SHOPPINGCARTID is PK i SHOPPINGCART and FK in SHOPPINGCART_PRODUCTS, one shoppingcart can have many products. One customer can only have one shoppingcart. PARENTID is a reference to another SHOPPINGCARTITEMID
So, when the connection problem occurs, the link bonding customers in a salesmeeting is broken so two customers who were in the same salesmeeting when I first started to work with the errand, are now separated. Without going in to details on how this affects my application, it is not good.
So now I want to write a script that in pseudocode does something like this:
List MEETING_CUSTOMERS with customers who has a SHOPPINGCART where there are SHOPPINGCART_PRODUCTS that has a PARENTID-reference to another SHOPPINGCART_PRODUCT which is in a SHOPPINGCART belonging to another customer who is NOT in the same SALESMEETING. Also print rows in the other MEETING_CUSTOMERS.
In the example above, customer AAAA and customer BBBB are i different MEETING's but in customer BBBB's SHOPPINGCART there is a SHOPPINGCART_PRODUCT with a reference (PARENTID) to a SHOPPINGCART_PRODUCT in customer AAAA's SHOPPINGCART. In the other case where PARENTID is not null, everything is correct because the customer with the referenced SHOPPINGCART_PRODUCT is in the same MEETING.
So, the output would be:
2----------------------AAAA
3----------------------BBBB
I hope you follow my thought here, if not, just ask me and I will try to give a better explanation =)
Thanks!
/Paul

Yepps!
MEETING
CREATE TABLE "MEETING"
(     "MEETINGID" NUMBER NOT NULL ENABLE,
     CONSTRAINT "MEETINGID_PK" PRIMARY KEY ("MEETINGID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 1054720 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
ENABLE
MEETING_CUSTOMERS
CREATE TABLE "MEETING_CUSTOMERS"
(     "MEETINGID" NUMBER NOT NULL ENABLE,
     "CUSTOMERID" VARCHAR2(12 BYTE) NOT NULL ENABLE,
     CONSTRAINT "MEETING_CUSTOMERS_PK" PRIMARY KEY ("MEETINGID", "CUSTOMERID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
ENABLE,
     CONSTRAINT "CUSTOMERID_UNIQUE_2" UNIQUE ("CUSTOMERID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
ENABLE,
     CONSTRAINT "MEETING_CUSTOMERS_FK" FOREIGN KEY ("MEETINGID")
     REFERENCES "MEETING" ("MEETINGID") ON DELETE CASCADE ENABLE
CART
CREATE TABLE "CART"
(     "CARTID" NUMBER NOT NULL ENABLE,
     "CUSTOMERID" VARCHAR2(15 BYTE),
     CONSTRAINT "CART_PK" PRIMARY KEY ("CARTID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
ENABLE,
     UNIQUE ("CUSTOMERID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 1048576 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT);
CART_PRODUCT
CREATE TABLE "CART_PRODUCT"
(     "PRODUCTID" NUMBER NOT NULL ENABLE,
     "CARTID" NUMBER,
     "PARENTID" NUMBER,
     PRIMARY KEY ("PRODUCTID")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
ENABLE,
     FOREIGN KEY ("CARTID")
     REFERENCES "CART" ("CARTID") ON DELETE CASCADE ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 4194304 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT);
-- INSERTING into MEETING
Insert into MEETING (MEETINGID) values (1);
Insert into MEETING (MEETINGID) values (2);
Insert into MEETING (MEETINGID) values (3);
-- INSERTING into MEETING_CUSTOMERS
Insert into MEETING_CUSTOMERS (MEETINGID,CUSTOMERID) values (1,'XXXX');
Insert into MEETING_CUSTOMERS (MEETINGID,CUSTOMERID) values (1,'YYYY');
Insert into MEETING_CUSTOMERS (MEETINGID,CUSTOMERID) values (1,'ZZZZ');
Insert into MEETING_CUSTOMERS (MEETINGID,CUSTOMERID) values (2,'AAAA');
Insert into MEETING_CUSTOMERS (MEETINGID,CUSTOMERID) values (3,'BBBB');
-- INSERTING into CART
Insert into CART (CARTID,CUSTOMERID) values (1,'AAAA');
Insert into CART (CARTID,CUSTOMERID) values (2,'BBBB');
Insert into CART (CARTID,CUSTOMERID) values (3,'XXXX');
Insert into CART (CARTID,CUSTOMERID) values (4,'YYYY');
-- INSERTING into CART_PRODUCT
Insert into CART_PRODUCT (PRODUCTID,CARTID,PARENTID) values (1,1,null);
Insert into CART_PRODUCT (PRODUCTID,CARTID,PARENTID) values (2,2,1);
Insert into CART_PRODUCT (PRODUCTID,CARTID,PARENTID) values (3,2,null);
Insert into CART_PRODUCT (PRODUCTID,CARTID,PARENTID) values (4,3,5);
Insert into CART_PRODUCT (PRODUCTID,CARTID,PARENTID) values (5,4,null);
Insert into CART_PRODUCT (PRODUCTID,CARTID,PARENTID) values (6,5,null);
And version of the database....hmm, that I do not know, how do I find out? I'm using SQL-developer 1.2.1
/Paul
Insert into CART (CARTID,CUSTOMERID) values (5,'ZZZZ');

Similar Messages

  • Bank statement search string for posting rule 2

    Hello,
    I created a search string (also activated) for clearing sub legder account. Folowing are the combinations i tried:
    1) ###(.| )#######
    2) (^| )###(.| )#######( |$)
    3) ###.#######
    Open document reference text on header normally carries  3digits followed by a dot and then seven digits. For example:
    123.1234567.  I also want to include 123 1234567 (sometimes it appears like this in bank statement) but the system should intrepret it as 123.1234567.
    I think above string acheived this when i did a TEST (button) next mapping screen on the same screen.
    I uploaded the bank statement and then went to another config where you do simulation for a bank statement (uploaded). There the system checks for first three digits only and the document found coloumn is blank (because it checks only first three digits and there are too many probable customers in partner's field).
    Posting rule - algorithm is  no 21
    search string - algorithm is no 21
    mapping field in search string - i tried with bland and without blank (###.#######) it is all same.
    How to make the system check 3+7 digits with dot? and why it checking only first three digits. Can some help?
    BG

    Hi,
    I also would be interested to know this. If anybody can give a step by step analysis, it would be highly appreciated.
    Regards,
    Ravi

  • How to use statement "search" to find out the asterisk in a string?

    Hi Guys,
       I encouter this question:I need to use "search" statement to find out the asterisk or the underscore in one string,you know these two symbols are wildcards. I don't know how to use statement "search" to find them??
       could you please give me some help!!
    Thanks a lot,Villy.Lv
    Edited by: Villy Lv on Sep 26, 2010 6:50 AM

    Hi,
    You cant usesearch statement, rather did you try with CS using IF condition? even you can go with loop statement too.
    DATA STRING TYPE STRING.
    DATA C TYPE C.
    DATA LEN TYPE I VALUE 0.
    DATA I TYPE I VALUE 0.
    LEN = STRLEN(STRING).
    LOOP LEN > I
         C = STRING+I.
         IF(C == '*' OR C == '_').
         ENDIF.
         I = I + 1.
    ENDLOOP.
    This way also you can use.
    Hope this may help you.
    Regards!
    Sheik

  • Bank Statement Processing - FF_5 - FEBA - Posting Rules

    Hi All SAP Experts !!!
    I am a non SAP expert (I am a tehcnically minded accountant) trying to find out if I can find a SAP solution to my problem.
    I am trying to introduce automatic processing / upload and posting of journals from electronic Bank statements from Citibank.
    My particular problem is in the area of processing Cash/Customer receipts which can come from various
    different external transaction types from my bank statement.
    I have tested a solution whereby the e-bank statement is queried for Invoice numbers with some success but
    my problem is the success depends on the accuracy and completeness of Invoice numbers provided by my cusomters.
    The above solution when it works makes the following accouNting entries
    Level 1 Dr Bank A/c                   Cr Suspense A/c (General Ledger)
    Level 2 Dr Suspense A/c           Cr A/R Subledger (Clearing the Customer Invoices)
    Due to the lack of consistancy in results of testing I now wish to do something different
    Query the same statement on the basis of Customer Name or Customer Bank Details (Bank Orig ID)
    From this I would simply like to make the same level 1 posting as above but for the Level 2 posting I simply
    want to leave the monies received unallocated on the subledger (ie FBO1 or Not clearing anything)
    Is it possible to query the E-Bank statemnent on a name or Bank Originatiing ID and use same to map to a
    Customer No within one of SAP's tables ie "Widget & Co" = Cust No  10001 in the AR subledger?
    Can the above FB01 Level 2 type transaction be carried out just posting and not allocating/clearing?
    Thanks a million
    MJOAP40

    In the definition of the level 2 posting rule, you have a couple of options.  You can leave the posting rule type as a subledger clearing and specify a "Posting on acct key".  With that SAP will attempt to clear, but if it can't it will use the posting key specified to post on account (FB01).
    Another option is to change the posting rule posting type from clearing the subledger to posting to the subledger - in this case, SAP will not attempt to clear anything, but just post everything on account.
    In either scenario, if the system does not have an invoice to clear, then you will probably need to use a search string to assign the customer number so the system knows what account to use for the on account posting.  Search strings look at the remittance information on the bank statement (Note to Payee).  You would need to create search strings specific to each customer.  The search string would map the customer's remittance information to the customer's number in SAP.  There are multiple posts in this forum and the ERP Financials - Treasury Applications forum regarding configuration of search strings.
    Regards,
    Shannon

  • Hi can you please help me to fix my iPhone 5 when I update it to the iOS 6.1.2 my carrier signal indicator states searching all the time please help me what to do

    HiHi can you please help me to fix my iPhone 5 when I update it to the iOS 6.1.2 my carrier signal indicator states searching all the time please help me what to do

    Hi Samantha,
    Are you aware that if you restore your ipad that you will lose all data from your ipad and very difficult to get it back unless you had previously made a back-up of your data on itunes or in the cloud. and that would be on the computer you set those up on. (There are some independent apps out there that might help restore data but I don't have any experience with them...)
    Also, I think if you restore on another computer you're supposed to have administrator rights and have the latest itunes update. And I think if you sync (if restoring is considered syncing with another computer, you'll be locked out of your computer or a new one.)
    I don't know if there is a way for you to safely eject your ipad from your mom's laptop and find another way, but please read this
    http://support.apple.com/kb/ts1275
    Also, I suggest you start a new post and title it something like First, stuck on update and now on Restore on another computer. Please HELP! And then tell the story of your problem that you originally included and your follow-up efforts to restore given a suggestion on previous post (though I think you SHOULD AVOID RSTORE if you can.) And refer them to your original post
    https://discussions.apple.com/message/22050045?ac_cid=tw123456#22050045
    Hope this helps and if you can get back to your ios before the upgrade, stay with it. I hope it all works out for you.
    FYI - If it's a new or refurb bought within the past year you might be able to have it replaced by Apple.

  • Oracle 11g - Nested loops on outer joins

    Hello,
    I have a select query that was working with no problems. The results are used to insert data into a temp table.
    Recently, it would not complete executing. The explain plan shows a cartesian. But, there could be problems with using nested loops on the outer join. Interestingly, when I copy production code and rename the temp table and rename the view, it works.
    Can someone take a look at the code and help. Maybe offer a suggestion on tuning too? Thanks.
    CREATE TABLE "CT"
    ( "TN" VARCHAR2(30) NOT NULL ENABLE,
    "COL_NAME" VARCHAR2(30) NOT NULL ENABLE,
    "CDE" VARCHAR2(5) NOT NULL ENABLE,
    "CDE_DESC" VARCHAR2(80) NOT NULL ENABLE,
    "CDE_STAT" CHAR(1));
    insert into CT (TN, COL_NAME, CDE, CDE_DESC, CDE_STAT)
    values ('INDSD', 'STCD', 'U', 'RF', 'A');
    insert into CT (TN, COL_NAME, CDE, CDE_DESC, CDE_STAT)
    values ('AT', 'TCD', '001', 'RL', 'A');
    insert into CT (TN, COL_NAME, CDE, CDE_DESC, CDE_STAT)
    values ('AT', 'TCD', '033', 'PFR', 'A');
    CREATE TABLE "IPP"
    ( "IND_ID" NUMBER(9,0) NOT NULL ENABLE,
    "PLCD" VARCHAR2(5) NOT NULL ENABLE,
    "CBCD" VARCHAR2(5));
    insert into IPP (IND_ID, PLCD, CBCD)
    values (2007, 'AS', '04');
    insert into IPP (IND_ID, PLCD, CBCD)
    values (797098, 'AS', '34');
    insert into IPP (IND_ID, PLCD, CBCD)
    values (797191, 'AS','04');
    CREATE TABLE "INDS"
    ( "OPCD" VARCHAR2(5) NOT NULL ENABLE,
    "IND_ID" NUMBER(9,0) NOT NULL ENABLE,
    "IND_CID" NUMBER(*,0),
    "GFLG" VARCHAR2(1),
    "HHID" NUMBER(9,0),
    "DOB" DATE,
    "DOB_FLAG" VARCHAR2(1),
    "VCD" VARCHAR2(5),
    "VTDTE" DATE,
    "VPPCD" VARCHAR2(4),
    "VRCDTE" DATE NOT NULL ENABLE,
    "VDSID" NUMBER(9,0),
    "VTRANSID" NUMBER(12,0),
    "VOWNCD" VARCHAR2(5),
    "RCDTE" DATE,
    "LRDTE" DATE
    insert into INDS (OPCD, IND_ID, IND_CID, GFLG, HHID, DOB, DOB_FLAG, VCD, VTDTE, VPPCD, VRCDTE, VDSID, VTRANSID, VOWNCD, RCDTE, LRDTE)
    values ('USST', 2007, 114522319, '', 304087673, to_date('01-01-1980', 'dd-mm-yyyy'), 'F', '2', to_date('06-04-2011 09:21:37', 'dd-mm-yyyy hh24:mi:ss'), '', to_date('06-04-2011 09:21:37', 'dd-mm-yyyy hh24:mi:ss'), 1500016, null, 'USST', to_date('06-04-2011 09:21:37', 'dd-mm-yyyy hh24:mi:ss'), to_date('18-07-2012 21:52:53', 'dd-mm-yyyy hh24:mi:ss'));
    insert into INDS (OPCD, IND_ID, IND_CID, GFLG, HHID, DOB, DOB_FLAG, VCD, VTDTE, VPPCD, VRCDTE, VDSID, VTRANSID, VOWNCD, RCDTE, LRDTE)
    values ('USST', 304087678, 115242519, '', 304087678, to_date('01-01-1984', 'dd-mm-yyyy'), 'F', '2', to_date('06-04-2011 09:21:39', 'dd-mm-yyyy hh24:mi:ss'), '', to_date('06-04-2011 09:21:39', 'dd-mm-yyyy hh24:mi:ss'), 1500016, null, 'USST', to_date('06-04-2011 09:21:39', 'dd-mm-yyyy hh24:mi:ss'), to_date('18-07-2012 21:52:53', 'dd-mm-yyyy hh24:mi:ss'));
    CREATE TABLE "INDS_TYPE"
    ( "IND_ID" NUMBER(9,0) NOT NULL ENABLE,
    "STCD" VARCHAR2(5) NOT NULL ENABLE);
    insert into INDS_type (IND_ID, STCD)
    values (2007, 'U');
    insert into INDS_type (IND_ID, STCD)
    values (313250322, 'U');
    insert into INDS_type (IND_ID, STCD)
    values (480058122, 'U');
    CREATE TABLE "PLOP"
    ( "OPCD" VARCHAR2(5) NOT NULL ENABLE,
    "PLCD" VARCHAR2(5) NOT NULL ENABLE,
    "PPLF" VARCHAR2(1));
    insert into PLOP (OPCD, PLCD, PPLF)
    values ('USST', 'SP', 'Y');
    insert into PLOP (OPCD, PLCD, PPLF)
    values ('PMUSA', 'ST', '');
    insert into PLOP (OPCD, PLCD, PPLF)
    values ('USST', 'RC', '');
    CREATE TABLE "IND_T"
    ( "OPCD" VARCHAR2(5) NOT NULL ENABLE,
    "CID" NUMBER(9,0) NOT NULL ENABLE,
    "CBCD" VARCHAR2(5),
    "PF" VARCHAR2(1) NOT NULL ENABLE,
    "DOB" DATE,
    "VCD" VARCHAR2(5),
    "VOCD" VARCHAR2(5),
    "IND_CID" NUMBER,
    "RCDTE" DATE NOT NULL ENABLE
    insert into IND_T (OPCD, CID, CBCD,PF, DOB, VCD, VOCD, IND_CID, RCDTE)
    values ('JMC', 2007, '04', 'F',to_date('11-10-1933', 'dd-mm-yyyy'), '2', 'PMUSA', 363004880, to_date('30-09-2009 04:31:34', 'dd-mm-yyyy hh24:mi:ss'));
    insert into IND_T (OPCD, CID, CBCD,PF, DOB, VCD, VOCD, IND_CID, RCDTE)
    values ('JMC', 2008, '04', 'N',to_date('01-01-1980', 'dd-mm-yyyy'), '2', 'PMUSA', 712606335, to_date('05-04-2013 19:36:05', 'dd-mm-yyyy hh24:mi:ss'));
    CREATE TABLE "IC"
    ( "CID" NUMBER(9,0) NOT NULL ENABLE,
    "CF" CHAR(1));
    insert into IC (CID, CF)
    values (2007, 'N');
    insert into IC (CID, CF)
    values (100, 'N');
    insert into IC (CID, CF)
    values (200, 'N');
    CREATE OR REPLACE FORCE VIEW "INDSS_V" ("OPCD", "IND_ID", "IND_CID", "GFLG", "HHID", "DOB", "DOB_FLAG", "VCD", "VTDTE", "VPPCD", "VRCDTE", "VDSID", "VTRANSID", "VOWNCD", "RCDTE", "LRDTE") AS
    SELECT DISTINCT a.OPCD, a.IND_ID, a.IND_CID, a.GFLG, a.HHID,
    a.DOB, a.DOB_flag, a.VCD, a.VTDTE,
    a.VPPCD, a.VRCDTE, a.VDSID, a.VTRANSID,
    a.VOWNCD, a.RCDTE, a.LRDTE
    FROM INDS a, INDS_type b
    WHERE a.IND_ID = b.IND_ID
    AND b.STCD in (select CDE
    from CT --database link
    where TN = 'INDSD'
    and COL_NAME = 'STCD'
    and CDE_STAT = 'A') ;
    --insert /*+ parallel(IND_T,2) */ into IND_T
    select /*+ parallel(a,4) */
    a.OPCD as OPCD
    , a.IND_ID as CID
    , b.CBCD as CBCD
    , NULL as BFCD
    , 'N' as PF
    , a.DOB as DOB
    , a.VCD as VCD
    , a.VOWNCD as VOCD
    , a.IND_CID as IND_CID
    , a.RCDTE as RCDTE
    from INDSS_V a
    , (select /*+ parallel(IPP,4) */ * from IPP IPP , PLOP PLO
    where plo.PLCD = ipp.PLCD
    and PPLF='Y') b
    , IC c
    where a.IND_ID = b.IND_ID (+)
    and a.OPCD = b.OPCD (+)
    and a.IND_ID = c.CID
    and c.CF = 'N';

    Please consult
    HOW TO: Post a SQL statement tuning request - template posting
    Also format your code and post it using the [ code ] and [ /code ] tags. (Leave out the extra space after [ and before ])
    Sybrand Bakker
    Senior Oracle DBA
    Edited by: sybrand_b on 10-apr-2013 17:57

  • How to execute entire result set of multiple sql statements via sp_executesql?

    I have a query that generates multiple insert statements (dynamic sql).  So when I execute this my result set is a table of sql insert statements (one insert statment per row in my source data table).  Like so:
                 Select 'INSERT INTO [dbo].[Table_1] ([Col1]) VALUES (' +  SrcData + ')' from SourceDataTbl
    How can I completely automate this and execute all these sql statements via sp_executesql?
    My plan is to completely automate and execute all this via an SSIS package.
    As always any help is greatly appreciated!
    fyi-  This is a very simple version of what I am trying to do.  My query probably plugs in 20+ values from the SourceDataTbl into each of the sql insert statements.

    Ah, a small error in Visakh's post, which I failed to observe, and then I added one on my own.
    DECLARE @SQL Varchar(max)
    SELECT @SQL =
       (SELECT 'INSERT INTO [dbo].[Table_1] ([Col1]) VALUES (' +  SrcData +
                ')' + char(10) + char(13)
        from SourceDataTbl
        FOR XML PATH(''), TYPE).value('.', 'nvarchar(max)')
    EXEC sp_executesql @SQL
    Without ", TYPE" FOR XML returns a string when assigned to a variable. The TYPE thing produces a value of the XML data type, so that we can apply the value method and get string out of the XML.
    And why this? Because:
    DECLARE @str nvarchar(MAX)
    SELECT @str = (SELECT 'Kalle Anka & co' FOR XML PATH(''))
    SELECT @str
    SELECT @str = (SELECT 'Kalle Anka & co' FOR XML PATH(''), TYPE).value('.', 'nvarchar(MAX)')
    SELECT @str
    Although the data type is string when , TYPE is not there, it is still XML and characters special to XML are enticised.
    Confused? Don't worry, for what you are doing, this is mumbo-jumbo.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Multiple Fix Statements

    We have calc scripts that are not fixing on one dimension, hence, every member of that dimension is being calc'd. If we have multiple fix statements throughout the calc script, could I just add the missing dimension member to the first fix statement and it would apply throughout the script instead of updating all of the fix statements throughout the script? In essence, once a dimension member is fixed on, it will remain fixed until another fix statement specifially overrides it? I would appreciate any thoughts. Thanks!

    Hi Glenn, :)
    You are of course and as usual correct re the UNION effect of nested FIX statements that reference the same dimension.
    I think the OP was discussing the same member FIXed upon multiple times within the same calc script/HBR. Maybe he has a union occuring and doesn't realize it.
    Are you referring to his second post where he states:
    Will there be any performance benefits if I change it so that there is one fix statement at the top that's applicable to all calcs, and then change the fix statements subsequently for calcs that need to change their focus?I guess that implies a situation where he first FIXed on Actual and then didn't terminate with an ENDFIX before he went on to FIX on Budget. As you state, that would then cause a union and probably screw his data up in a fairly exciting manner.
    Regards,
    Cameron Lackpour

  • Executing a stored procedure containing multiple Select statements

    Post Author: Beverly
    CA Forum: General
    I am using Crystal  10.0 against a MS SQL 2000 server.
    I am trying to create a report based on a stored procedure that contains multiple select statements.  The sp requires a single parameter (Claim number) and contains 17 Select statements that produce results.
    I am able to use the Add command and execute the sp with the parameter, but I am only getting the results of the first select statement in the sp back in my data set.  Is there a way to have the data from each Select statement returned to my report?
    I have used Crystal for a while, but pretty much for straight-forward reporting.  I am familiar with the basics of SQL.
    I would appreciate any help anyone can offer.
    Thanks.

    Post Author: BISoftware
    CA Forum: General
    I believe Crystal Reports can only handle one recordset at a time, which means it can only handle a single select statement.  The only way I can see around this would be to break up your stored procedure into multiple stored procedures, so that each only contains a single select statement.  Then, use subreports to report on each individual sp. Hope this helps. - Davewww.BusinessSoftwareResource.com

  • Java.sql exception for rs.nesxt() ( nested statements)

    I have a problem with java.sql.I am getting an Invalid handle exception for nested result sets ...
    example:-
    //Conn is the common connection
    Statement s1 = conn.createStatement();
    rs1 = s1.executeQuery(query1);
    while (rs.next){
    Statement s2 = conn.createStatement();
    rs2= s2.executeQuery(query2)
    while (rs2.next){
    The rs2 resultset works fine,but when it gets back into the outer while loop the exception is thrown.
    I know that the problem is becuase the nested statements are usign the same connection.
    I know of two ways to work around this
    (1) use different connections
    (2) remove nesting (save the result rs1,and then retrieve rs2)
    But I wnated to know if anyone knows of any other way to work around this problem.
    let me know.
    Thanks.

    Each connection has a single storage area for iteration, metadata, etc. Obviously you are aware that outer loop is unable to proceed because iteration data is of a different format from the inner sql query. It is not a good idea to do more than a single, or small set of queries on a single connection object. Would you consider a connection pool? They are not for the timid programmer, but they do take advantage of using connection objects much like pointers, with the ability to pop them into and out of a collection, ready to roll once the connection object is setup and ready for action much like a pointer that is properly assigned can be passed and always ready for action. The entire connection object (and metadata) is stored in the collection data structure. My advice is to keep it simple! It is easy to get too carried away with connection pools.

  • FF67 problem, can't change statement date(statement saved but not post)

    I need to change the statement date of a bankstatement. I did not post the statement yet.
    I used a wrong statement date, and I want to change it, but I saved it after booking the second screen(the one with the
    statement items)
    When I look by Manual Bank Statement Overview I see the bankstatement, but it has no Posting complete remark yet, because it has not been postefdofcourse.
    The problem is I can't change the statement date, because when I try to Post then the systems gives an error because it does not accept the new statement date I want to use.
    Is there a way to solve this problem? The statement has not been posted yet, so I suprised I can't change the statement date.
    Anyway I hope somebody can help me out.

    I had to post them first because otherwise it looks I could not delete the statement.
    I saw no Id with only saving, that's why I post them. then the statement got an id.
    What do I have to choose to make it possible to delete statements, not posted yet.
    I guess I have to select something else because I did not see any Id to choose.
    I do a manual input of the bankstatements (no import).
    Whst's the best I can do now?  What do you mean with FI?
    I guess I can do a manual booking on the three(send/receive and general) bankaccounts to get the right position of the accounts?
    The bankstatements are ok(booked with ff67) only the three accounts I mention above have the wrong position.

  • Help with multiple case statements

    Hello,
    I am new to BO.  I am on XI 3.0.  SQL 2005.  In Designer, I am trying to create a measure in a financial universe that would end up being multiple case statements within one select.  This is what I tried to do, but it doesn't work with the two case statements.  Can I use an ELSE leading into the second CASE WHEN somehow?  How can I accomplish this?  Sorry for my ignorance!
    CASE WHEN dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month = 12 THEN dbo.ClientBudgetMonth.Stage1Sales END
    CASE WHEN  dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month = 11 THEN dbo.ClientBudgetMonth.Stage1Sales END
    Any Suggestions?
    Thanks,
    Holly

    Holly,
    I don't know enough about your data or requirement to provide a solution, however, the construct that you post will not work because it causes you to build an object with multiple case statements when only one case statement per object is permitted.  From what I see in your code I would be inclined to combine the two statements into one as such:
    CASE WHEN dbo.ClientBudgetYear.DateStage1Approved > 01/01/1900 AND dbo.ClientBudgetMonth.Month in (11,12) THEN dbo.ClientBudgetMonth.Stage1Sales else null END
    Thanks,
    John

  • Multiple like statements in a query

    Hi,
    I wonder if it's possible to have multiple like statements in a query.
    suppose instead of
    select * from someTable where remarks like '%ab%'
    I want to search for many string patterns such as '%edi%' '%odi%' '%di%' '%gf%' '%od%' '%podi%' etc. in one query.
    BTW, the table contains many millions of records.
    Regards
    Crusoe
    Edited by: Crusoe on 19-Jan-2009 00:25

    Crusoe wrote:
    This regexp_like function does not work with the development server to which I have rights to create tables etc. I guess it only works in 10g or greater. However i tried a quick test in the production server and it worked. It returned rows where the values between the | characters were found anywhere in the field ( I must learn this regex syntax sometime). Yes, regular expressions are 10g upwards. (You really should have your development server reflect your production server)
    There was a thread a while back giving an introduction to regular expressions...
    Introduction to regular expressions ...

  • Multiple SQL statements in Init SQL in WLS 8.1

    How to seperate multiple SQL statements in Init SQL text box ?
    For example, I want to enter following two SQL statements. How do I seperate them.
    I tested with / and ; as seperator, but did not worked..
    alter session set nls_date_format = 'MM/DD/YYYY'
    set role xxx_role identified by xxxx

    Mahendra wrote:
    Thanks Joe.
    Following worked for Oracle 8.1.7Good news.
    but did not for 8.0.6
    SQL BEGIN EXECUTE IMMEDIATE 'ALTER SESSION SET nls_date_format = ''MM/DD/YYYY''';
    EXECUTE IMMEDIATE 'SET ROLE xxx identified xxx'; end;
    Do you know 8.0.6 syntax ?You might try asking oracle, but note that no one is supporting that old version
    of Oracle any longer...
    Joe
    >
    Mahendra
    Joe Weinstein <[email protected]> wrote:
    Hi.
    I found the syntax, I think. Try this:
    BEGIN EXECUTE IMMEDIATE 'ALTER SESSION SET nls_date_format = 'MM/DD/YYYY'';
    EXECUTE IMMEDIATE 'SET ROLE <<role name>> identified
    by <<pwd>>';END;
    Joe
    Mahendra wrote:
    Still getting following exception.
    <Feb 19, 2004 1:47:58 PM EST>
    <Warning>
    <JDBC> <BEA-001164>
    <Unable to initialize connection in pool "XXXX".
    Initialization
    SQL = "BEGIN alter session set nls_date_format = 'MM/DD/YYYY'; setrole xxxx_role
    identified by
    xxxx; END;".
    Received exception: "java.sql.SQLException: ORA-06550: line 1,column7:
    PLS-00103: Encountered the symbol "ALTER" when expecting one of thefollowing:
    begin declare exit for goto if loop mod null pragma raise
    return select update while <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql commit <a single-quoted SQL string>
    The symbol "update was inserted before "ALTER" to continue.
    ORA-06550: line 1, column 61:
    PLS-00103: Encountered the symbol "ROLE" when expecting one of thefollowing:
    transaction
    ".>
    <Feb 19, 2004 1:47:59 PM EST> <Notice> <WebLogicServer> <BEA-000355><Thread "Li
    Joe Weinstein <[email protected]> wrote:
    Mahendra wrote:
    Thanks for reply, but that did not worked.
    Get following exception
    Unable to initialize connection pool "POOL_NAME".
    Initialization SQL = "Select count(*) from ""SQL BEGIN alter sessionset nls_date_format
    = 'MM/DD/YYYY'; set role xxx_role identified by xxxx; END;"". Receivedexception:
    "java.sql.SQLException: ORA-00972: identifier is too long
    Since we have not given SQL before that statement, BEA is treating
    statment "SQL Begin ....." as a table name.
    Then I tried by putting SQL out side quotes, like SQL "Begin .....end;" but the
    same error.
    Is there any way around it ?
    MahendraHi. The full string you should enter into the console when you define
    the
    initSQL parameter is:
    SQL BEGIN alter session set nls_date_format = 'MM/DD/YYYY'; set role
    xxx_role identified by xxxx; END;
    Let me know...
    Joe
    Joe Weinstein <[email protected]> wrote:
    Mahendra wrote:
    How to seperate multiple SQL statements in Init SQL text box ?
    For example, I want to enter following two SQL statements. How do
    I
    seperate them.
    I tested with / and ; as seperator, but did not worked..
    alter session set nls_date_format = 'MM/DD/YYYY'
    set role xxx_role identified by xxxxThis will always be DBMS-specific. If this is for oracle, you can
    try:
    "SQL BEGIN alter session set nls_date_format = 'MM/DD/YYYY'; setrole
    xxx_role identified by xxxx; END;"
    Joe

  • Multiple Select statements in EXECUTE SQL TASK in SSIS

    Can we write multiple select statements in execute sql task(SSIS).
    If possible how to assign them to variables in result statement

    Hi ,
    You can use below steps to set result set to variable.
    1.In the Execute SQL Task Editor dialog box, on the General page, select the Single row, Full result set, or XML result set type(According to your result set).
    2.Click Result Set.
    3.To add a result set mapping, click Add.
    4.From the Variables Name list, select a variable or create a new variable.
    What is multiple selection ? May be below can be used in your scenario !
    http://stackoverflow.com/questions/17698908/how-to-set-multiple-ssis-variables-in-sql-task
    What you want to achieve ?
    Thanks
    Please Mark This As Answer or vote for Helpful Post if this helps you to solve your question/problem. http://techequation.com

Maybe you are looking for