DelphiFan Magazine

Top Menu

Main Menu

  • DELPHI
  • CODE SAMPLES
  • FIREMONKEY
  • DATABASE
  • RELEASES
  • VIDEOS
  • REVIEW
  • TECH NEWS

logo

DelphiFan Magazine

  • DELPHI
  • CODE SAMPLES
  • FIREMONKEY
  • DATABASE
  • RELEASES
  • VIDEOS
  • REVIEW
  • TECH NEWS
  • How to add a server application written in UNIGUI to startup?

  • UniGUI Expiry Link Anonymizer

  • UniGUI Add CAPTCHA to the WEB project

  • UniGui. Unique hybrid of Delphi and JS

  • How to transform a blob field into string lines (varchar) in SQL Firebird?

CODE SAMPLESDATABASE
Home›CODE SAMPLES›How to transform a blob field into string lines (varchar) in SQL Firebird?

How to transform a blob field into string lines (varchar) in SQL Firebird?

By admin
January 13, 2021
582
0
Share:

Hello guys.

In some cases we have BLOB fields in the databases for storing texts.

There are times when it is important to retrieve line by line from this BLOB that acts as
a StringList or Memo.

Cool, but how to do?

To help, we created a procedure that converts a BLOB of plain text (multi lines)
into individual lines.

Let’s go to the code!

 

CREATE OR ALTER PROCEDURE UTIL_SPLIT_BLOB_TO_ROW (
    BLOBTEXT VARCHAR(1000))
RETURNS (
    MNUMBER INTEGER,
    RETSTRING VARCHAR(1000))
AS
DECLARE variable LSTRING VARCHAR(1000);
DECLARE variable POS1 INTEGER;
DECLARE variable POS2 INTEGER;
DECLARE variable INTLEN INTEGER;
BEGIN
  lstring = SUBSTRING( BLOBTEXT FROM 1 FOR 1000);
 
  pos1 =  1 ;
  intlen = CHAR_LENGTH(lstring);
  MNUMBER = 0;
 
  while (pos1 < intlen) do
  BEGIN
    MNUMBER = MNUMBER + 1;
    pos2 = POSITION (ASCII_CHAR(13) IN SUBSTRING(lstring FROM pos1));
 
    IF (pos2 = 0) THEN
    BEGIN
      pos2 = intlen;
    END
 
    retstring = SUBSTRING (lstring FROM pos1 FOR (pos2 - 1));
    pos1 = pos2 + pos1;
 
    suspend;
  END 
END

In the procedure we are using varchar (1000) of parameters, but this can be adapted to your reality.

Now for the usage example:

SELECT
U.MNUMBER,
U.RETSTRING
FROM UTIL_SPLIT_BLOB_TO_ROW(:text) U

By entering the parameter as an example:
DELPHIFAN FORUM
BEST DELPHI COMMUNITY IN WORLD

the return will be

MNUMBER RETSTRING
1 DELPHIFAN FORUM
2 BEST DELPHI COMMUNITY IN WORLD

In conclusion, with a simple procedure it is possible to transform a multi-line text field
into SQL return lines.

I hope it will be useful to everyone! Regards and see you next post.


                                                            
Tagsblob fielddatabasefirebirdsqlsql firebirdstring field
Previous Article

How to add or remove hours from ...

Next Article

UniGui. Unique hybrid of Delphi and JS

0
Shares
  • 0
  • +
  • 0
  • 0
  • 0
  • 0

admin

Related articles More from author

  • CODE SAMPLESDELPHI

    Connect And Manage A SQLite Database For Delphi

    October 8, 2020
    By admin
  • CODE SAMPLESDATABASE

    How to add or remove hours from a SQL Firebird timestamp field

    January 13, 2021
    By admin
  • CODE SAMPLESDELPHI

    How to extract text between HTML or XML tags?

    January 7, 2021
    By admin
  • CODE SAMPLESDELPHI

    View the output function list of DLL

    January 1, 2021
    By admin
  • CODE SAMPLESTECH NEWS

    How to modify the maximum number of tcp connections on the windows server

    October 9, 2020
    By admin
  • CODE SAMPLESDELPHI

    Customize the height of uniGUI Grid header

    October 1, 2020
    By admin

Leave a reply Cancel reply

You may interested

  • CODE SAMPLESDELPHI

    Good code samples for cxGrid Part2

  • CODE SAMPLESDELPHI

    Implementation of uniGUI login-free

  • CODE SAMPLESDELPHI

    Theme setting for Delphi

  • LATEST REVIEWS

  • TOP REVIEWS

Timeline

  • January 27, 2021

    How to add a server application written in UNIGUI to startup?

  • January 27, 2021

    UniGUI Expiry Link Anonymizer

  • January 26, 2021

    UniGUI Add CAPTCHA to the WEB project

  • January 26, 2021

    UniGui. Unique hybrid of Delphi and JS

  • January 13, 2021

    How to transform a blob field into string lines (varchar) in SQL Firebird?

Latest Comments

Find us on Facebook

Follow Us on Instagram

logo

Our website, law, laws, copyright and aims to be respectful of individual rights. Our site, as defined in the law of 5651 serves as a provider of space. According to the law, contrary to the law of site management has no obligation to monitor content. Therefore, our site has adopted the principle of fit and remove. Works are subject to copyright laws and is shared in a manner that violated their legal rights, or professional associations, rights holders who, adsdelphi@gmail.com I can reach us at e-mail address. Complaints considered to be infringing on the examination of the content will be removed from our site.

About us

  • 660 Pennsylvania Avenue Southeast #100 Washington, DC 20003
  • 0123456789
  • adsdelphi@gmail.com
  • Recent

  • Popular

  • Comments

  • How to add a server application written in UNIGUI to startup?

    By admin
    January 27, 2021
  • UniGUI Expiry Link Anonymizer

    By admin
    January 27, 2021
  • UniGUI Add CAPTCHA to the WEB project

    By admin
    January 26, 2021
  • UniGui. Unique hybrid of Delphi and JS

    By admin
    January 26, 2021
  • How to add a server application written in UNIGUI to startup?

    By admin
    January 27, 2021
  • Amazing Cross Platform Email App Sample In Delphi 10.4.1 FireMonkey For Android And IOS

    By admin
    August 13, 2020
  • Critical Update Available For Delphi FireMonkey 10.4.1 On Android, IOS, OSX, Windows, And Linux

    By admin
    September 4, 2020
  • Setting up the IDE for your first Android Application in Delphi

    By admin
    September 7, 2020

Follow us

Find us on Facebook

© Copyright Delphifan Forum. All rights reserved.