Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7925033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T18:05:37+00:00 2026-06-03T18:05:37+00:00

This is the stored procedure I’m using to get 5 digits from an xml:

  • 0

This is the stored procedure I’m using to get 5 digits from an xml:

    CREATE PROCEDURE [dbo].[SP_KINGPRICE_InsertJournalFromPost]
    (
        @ResponseID bigint,
        @TransactionDetailID bigint
    )
    AS
    BEGIN
    DECLARE @info as varchar(max) = '', @Reference as varchar(max) = ''
    SET @info = (SELECT SUBSTRING(Response, CHARINDEX('<GlJournal>',Response) + 11,5) 
                 FROM SysproIntegration..ifmTransactionDetailResponse 
                 WHERE TransactionDetailResponseID = @ResponseID)
    SET @Reference = (SELECT DISTINCT Reference 
                      FROM GenJournalDetail 
                      WHERE Journal = CAST(@info as DECIMAL(5,0)))
    INSERT INTO ZJournalRecords
    (JournalNumber,Reference)

    VALUES (@info,@Reference)
    END

The XML has a tag like this:

    <GLJournal>12345</GLJournal>

If the XML document has only one of these tags, I have no worries. The SP works fine. The problem comes in when there are two nested <GLJournal> tags. The xml would then look something like:

    <GLJournal>
        <SomeTag/>
        <SomeTag2/>
        <GLJournal>12345</GLJournal>
    </GLJournal>

How can I get the 5 digit value of the nested tag? (It will always be 5 digits)
I have thought of using a try catch, but that doesn’t seem like an elegant solution.

EDIT:
Also, part of the problem is, I don’t know when there will be one GlJournal tags, or two.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T18:05:40+00:00Added an answer on June 3, 2026 at 6:05 pm

    I decided to count the number of occurrences of the tag, and based on that, substring a certain position.

    DECLARE @info as varchar(max) = '', @Reference as varchar(max) = '', @inputString as varchar(max), @searchString as varchar(max), @numberOfTags as int
    
    SET @searchString = '<GlJournal>'
    SET @inputString = (SELECT Response FROM SysproIntegration..ifmTransactionDetailResponse WHERE TransactionDetailResponseID = @ResponseID)
    SET @numberOfTags = (LEN(@inputString) - 
                     LEN(REPLACE(@inputString, @searchString, ''))) /
                     LEN(@searchString)
    
    IF @numberOfTags = 1 
    BEGIN
    SET @info = (SELECT SUBSTRING(Response, CHARINDEX('<GlJournal>',Response) + 11,5) FROM SysproIntegration..ifmTransactionDetailResponse WHERE TransactionDetailResponseID = @ResponseID)
    SET @Reference = (SELECT DISTINCT Reference FROM GenJournalDetail WHERE Journal = CAST(@info as DECIMAL(5,0)))
    END
    ELSE
    BEGIN
    SET @info = (SELECT SUBSTRING(Response, CHARINDEX('<GlJournal>',Response) + 69,5) FROM SysproIntegration..ifmTransactionDetailResponse WHERE TransactionDetailResponseID = @ResponseID)
    SET @Reference = (SELECT DISTINCT Reference FROM GenJournalDetail WHERE Journal = CAST(@info as DECIMAL(5,0)))
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this stored procedure, that reads data from xml and make some inserts
I have this stored procedure which get data from excell and then update status:
I have this stored procedure CREATE PROCEDURE [dbo].[TestProcedure] @param1 int = 0 ,@param2 int
Is this stored procedure considered Dynamic SQL or a Parameterised query? CREATE PROCEDURE [dbo].[my_dodgy_sp]
I Create this stored procedure ALTER PROCEDURE [dbo].[Stock_Master_Sp] @common nvarchar(1)='', @PK_ID int=0, @FK_StoneCategory_Master int=0,
I use this code to define my stored procedure CREATE PROCEDURE [dbo].[SP] (@Country NVARCHAR(20))
I have this stored procedure: CREATE OR REPLACE PROCEDURE LIQUIDACION_OBTENER ( p_Cuenta IN NUMBER,
I have this stored procedure for Oracle: create or replace procedure bns_saa_message_get() <--- PROBLEM
In stored procedure I have: @parameter int based on this parameter I get some
I have a mysql stored procedure from this ( google book ), and one

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.