Embedded Firebird and "Memo" type fields

Q: When I used HSQL, I frequently used the “Memo” data type.

It isn’t available with the Firebird embedded engine, which I believe is “the future”.

What can I use instead to store multi-line fragments of text? I can’t find the CLOB[BLOB SUB_TYPE TEXT] which some say is the answer, and which seems to have very little documentation.

(Answers have been provided! (^_^) For them, see BELOW this explanation of ways the of ways I was going wrong.)

======
The following essay will put flesh on those bare bones. Maybe you too have been going wrong where I was in my hours of trying something that others say is no problem?

This isn’t the first time I have struggled with this. (This follows on from How do I create field for multi-line text? (Firebird) - #3 by Ratslinger[link text](How do I create field for multi-line text? (Firebird) - #3 by Ratslinger. That no longer works for me, and it uses CBLOG, which I have been warned brings its own problems for some users.)

Below there is an explanation of a tiresome road that has taken much of a day to travel. I am leaving it, to help others in the future to FIND this information. I HAVE searched… both the forum and with Google search. Found little already available. Thanks to madMatt and a kind person who sent private messages, I finally got “there”!

All this on Windows 10. Earlier, which some of this comes from, I was using Libre Office 7.0.3.1 Throughout, I am using Firebird as an EMBEDDED engine. Not connecting to an external Firebird engine.

AFAIK, you can only put a CBLOB [BLOB] field in a table during the table’s initial creation. I mean you can only make it part of the schema then. Once it is there, you can, of course, put data into that field when and as you create records in the table. (That was true under LO 7.0.3.1. PLEASE KARMA it has been fixed!) Happily, for multi-line text, it turns out you don’t need any variant of CBLOB. (I don’t like using obscure elements of any system.)

Discovered along the way, but irrelevant to final answer… maybe:

If I create a table and then work directly with the table… not a good idea, remember… I can “do things”. A field consisting of multiple lines of text can be entered. You use ctrl-enter to start a new line within the CBLOB field…

… and then drag the bottom edge of the bottom row of the table down, to make the cells higher, so you can SEE your multi-line data.

Some say that should be shift-enter. Maybe “the answer” for Linux or Mac? It’s ctrl-enter that works for Windows 10.

Sigh. So… “works”. I can get part-way down the road.

I couldn’t when I wrote the above, get a form to “work” for that table.

More seriously, mistakes can be costly and extremely inconvenient. There’s not always a simple way to cancel out of where you can be taken when attempting this stuff.

Under LO 7.0.3.1. It’s early days, but 7.0.5.2 seems LESS prone to that, but still crashes my system far more often and more intractably than any other app I’ve spent time with in the past 20 years.) There wasn’t for me, anyway. I got questions about “do I want to convert some HSLQ stuff in my database to Firebird” (that’s not a perfect quote). (Neither “yes” nor “later” got me anywhere… except maybe deeper.) Even Device Manager has trouble “killing” a crashed LO sometimes. (Don’t give up too soon, if you have other things open that you don’t want to re-start… End Task multiple times, and be patient.)

For no reason I can grasp, before 7.0.5.2 I was asked sometimes for the password for a SQL database on the computer. As with the HSQL modal dialog, neither option worked… in any sensible way.

Now… SOMETIMES, if I said “cancel” or “later” again and again… including to a dialog (“insert field”? I forget)… I could get out" without Device Manager. 10 to 20 such “cancels” to get out of a database with 1 table, two fields, recently opened from scratch… not a happy bunny. And sometimes it either wouldn’t work or needed more cancels than I was going to try.

So why bother with LO? Because for many things it works BRILLIANTLY. I only have these hassles when trying to learn the right way to do new things.


So- Lesson 1- update your LO to at least 7.0.5.2 to get this to “work”… well, work better.

I don’t think I did anything differently the first time I tried again under LO 7.0.5.2, but somehow, the field for notes had CBLOB[BLOB SUB_TYPE TEXT] as an option. That sub-type has been mentioned to me before, but I could never find/ access it until now.

(Remember: the final answer for me doesn’t involve CBLOB, but it isn’t widely discussed. May have a place for other things.)


Immediately after restarting my machine after upgrading to 7.0.5.2, I did a new table from scratch. Some of the following may seem “obvious”… but something has been getting in the way of success, so maybe my “obvious” includes bad ideas. I’m going to this effort so the person who tries this next doesn’t have to “guess” at the forks along the road to where I seem to have found success.

Used the “old”, pre-upgrade to 7.0.5.2 Windows “Start” menu LO Base button on my start menu… and the database wizard opened. Apparently, my “download/ install” took care of “re-attaching” it to the right thing. (I did nothing to “clear” my old LO before installing 7.0.5.2)

Said create a new database, using embedded Firebird, clicked “Next”, NOT “Finish”. Beware that one.

I said, “Yes, register”. (Newbies: Just Do it. Don’t worry, it isn’t going to “register” your database with Big Brother.)

…and say “Open the table for editing after file saved”. (Newbies: You are only “creating a container” at the moment. Setting up tables, etc, IN the “container” is to come.

And NOW you click “Finish”, and save it in a sensible folder, under a sensible name.

The main Base project management window opens, in the “Tables” section.

Invoke “Create table in design view”

First field: “ID”/ Integer/ AutoValue… it will be made the table’s primary key for you… the “key” icon in the narrow left column will tell you that this has been made the primary key.)

(PS- TURNS OUT THIS isn’t the answer… well, not the one I will try to “make work”. But it “works” on some levels, and is what some people recommend. Explained further, when you read on.)

Second field: “MultiLine”: CBLOB[BLOB SUB_TYPE TEXT]

! ! ! That’s the only type of CBLOB on offer now! THAT is NEW in 7.0.5.2 (This is good… it is the type of CBLOB that was previously recommended by someone who wasn’t having trouble with multi-line text) ! ! !

(Don’t try to change the length of the field (you can’t)… or worry about it… Each record will only use the storage space it needs.)

Save your design. Close the dialog.

Double-click on the newly created table in the main Base project management window… yes, at first I am going to work directly with the table. Bad practice.

Make the cells of the grid about 6 lines high by dragging the bottom edge of the bottom row of the grid down.

Enter two records. Use ctrl-enter to start a new line in the data you supply to each record’s “MultiLine” field. (It may be shift-enter in some environments.)

Close the table. Agree to the save, if it asks you, which it should if you didn’t save the second record after altering it.

Double click on your new table’s name in the main Base project management window.

Presto! A table! WITH multi-line “memos” (old skool name).

===
Onward…

(By the way- there are other ways to the same destination. I am giving ONE of the ways that SEEMS to work, now… it didn’t more than an hour ago when I started this, but it does now, after the LO version update. If YOU are having trouble, try EXACTLY this route through the quagmire.)

Go to the “Forms” part of the main Base project management window, and invoke “Use wizard to create new form”.

As you only have one table so far, it will assume that the form is for that table. When you have more, or maybe some queries, it will ask you which table(s)/ query(s) you want the form to display.

Use the double “>” to “move” all of the table’s fields into the “Fields in the form” column.

After Field Selection click “Next”.
Do nothing in “Subforms”, just click “Next”.

IN ARRANGE CONTROLS, go for “Columnar-labels on top”… first alternative to the left of the default “As Data Sheet”.

NOW you can click “Finish”.

Give the form a name that is DIFFERENT from the table’s name. (I usually just add “DE”, for “Data Entry”, to the table’s name… which is offered as a default name. Another Just Do It.)

Try “Work with the form”.

Either that didn’t work for me, or it “worked” after a 20 second hiatus, during which time I tried to cancel the first attempt before doing what is above again. Sigh. (Eventually, I did save it, and haven’t seen that behavior since.)

The form should open… and you can move between records… BUT YOU WON’T SEE YOUR DATA in the “box” labeled “MultiLine”. Sigh. But we can fix that!! (^_^)

Open the form for edit.

You’ll need the “Form Controls” toolbar. (Use “View/Toolbars” to be sure you have that.)

Click the “Text Box” add-control icon and then “drag out” a textbox on the form.

Rt-click. Control properties. Data tab.

Set the control’s Data Field to be the field in your table named “MultiLine”.

Run the form. Presto! You should be able see your data! (^_^) Fingers crossed that it worked for you.


Don’t, by the way, try to work with the data in your table BOTH via the table directly and via your form at the same time. Or even edit anyting when it is also open (in a separate window) for viewing. That seems to be a trigger of the really awful crashes. You can often get away with it for a while, which tempts me, again and again, to go down that road.

Remember: The data isn’t “in” the table just because it is on your screen, either by using the table view or the form view. Each is just some stuff on the screen that intially came from the table… but may have been changed by you in the meantime.

Why is it a really bad idea to have a table “open” via both, at the same time? What if you change what’s in a field… twice… one via each interface to the table? (to different values, without saving your changes. (Either “by hand”, or by moving to a different record (which does an automatic “save record”.)

It is a nuisance, but if you want to go back and forth, SHUT table (direct access) or form (mediated access) BEFORE opening a view into the table by the other route.


So… solved!

But.

But if you go the CBLOB route, madMatti kindly warns us that we will be in a world of hurt if we try to use data from the database in a report, or with Writer. (Apparently, Writer is unable to deserialize the datatype. (And reports output to Writer.)

Thankfully, he has an answer that solves two problems… but it causes another.

Please award his answer some Karma points by giving it a “thumbs up”.

He said (words to the effect)…

I switched from using CBLOB for multiline data to using VARCHAR
With VCHAR I
can save multiline data just
fine.

He also identified some problems with using the CBLOB datatype for storing text.

You probably CAN “save” an old form with some editing, but I’ll write up how to do a new one from scratch, to display multiline data from a VARCHAR-type field.

Obviously, you need a table with at least one VARCHAR-type field. Be sure the “length” property for that control is set to something high enough for your needs.

Put just few very simple records in your table, with single-line data in the VARCHAR field. You can do this the “basic” way: access the table directly.

CLOSE the table.

Go to the “Forms” section of the main Base project management window.

Invoke "Use Wizard to create a form for the table. Proceed as before. You should get something that almost works.

Close the newly created form.

Re-open it in “Edit” mode.

Tricky Bit! Beware! Without this, what comes after it “won’t work”.

In a wizard-created simple form, the parts (text boxes) that display what is in each field are grouped with labels for those text boxes.

You need to access the properties of the text box.

Use ctrl-click to select just the text box. Then right-click on it, and ask for the CONTROL properties. (Not the FORM properties.)

((Digression starts…
Alternatively, you can ungroup the two as follows:

Right-click on the control that is for displaying the field you want to use for multi-line data. Invoke “Ungroup”.

The label and the textbox for the field were “grouped” because usually that is helpful… but it means you can’t access some properties.

…Digression ENDS))

On the General tab, scroll down to “text type”; specify “multi-line”. (You may want to turn scrollbars on while you’re at it.)

I found that for me the “Text lines end” property was already set to “LF (Unix)”, which is recommended by someone who knows more about these things than I do.

((“Unnecessary” frill: If people may be using your form to ENTER data into the database, it may be helpful to set the viewing control’s text length limit to whatever limit you set on that datum in the specification of the table. But I found something weird going on:

My TABLE was set up to allow 30 characters in that field. My FORM, in a deliberate “mistake”, was set up to allow 40 characters in the box for that field. I entered a datum that consisted of 35 characters. Closed down the database, doing saves all along. Re-opened it. The field that had been… and still was… set up with a “length” value of 30 was quite happily holding a 35 character value. Hmm. (I double checked that by looking at the table directly, too. ((“Frill” ends))

Click the “x” in the upper right of the Control Properties dialog to close it. Use the normal “drag a corner” method to change the size of the control to what will be needed for the data you intend to enter.

And now you have a database with a multi-line field, and a form for viewing or entering such data!

While entering or editing a datum, you only need to press enter to start a new line. (Not the easily-forgotten “ctrl-enter” I used under the system I started with.)


But now I have a (small) new problem.

Though I know I shouldn’t, I often work with the data in a table “directly”, i.e. I open the table from the “Table” part of the main Base project management window, and work on the data there. Shouldn’t be “neccessary”. Just make yourself a form using the “data sheet” template. Working with that will LOOK like working with the table directly. I would do that! But in the past, I’ve sometimes found that the form didn’t always work as well as direct access. Maybe the nice programming people have fixed that!

Working with the table directly, I can introduce new-lines into the text of a CLBLOB multi-line field. (You use ctrl-enter, as mentioned a while back. OR maybe shift-enter, on some systems.) I haven’t (yet!) found a way to insert a new-line into the text of a VARCHAR field. Sigh.

Furthermore, if I look at the data via direct access to the table, I don’t see the new-lines. They aren’t LOST, but with “direct” access to a table,

The quick
brown fox
jumped over

… is displayed as…

The quick brown fox jumped over

Thoughts?


What a relief! After HOURS on the above, I then went off to see if the result would “play nicely” with Writer.

I’m delighted to tell you that it did… at least it did well enough for my wants!


After writing the above, I foolishly I tried to get a report out of the system. (I say “foolishly” because my brain was mush after the long day fighting with these things.)

And it looked like my multi-line data was being squashed to a single line!

Not the problem it seemed!

I only needed to make the control the multi-line text was to be displayed in high enough, and all was well. WHEW!

See

http://sheepdogguides.com/fdb/fdb1addrlab.htm

For the details of generating address labels from a database.

===============================
Comments, questions, etc would be VERY WELCOME!

Hello,

Too much non-essential text. Got tired of looking at it around your 2nd or 3rd pause. This caught my eye as it was partly in bold:

Tricky Bit! Beware! Without this, what comes after it "won't work".

Right-click on the control that is for displaying the field you want to use for multi-line data. Invoke "Ungroup".

(The label and the textbox for that field were "grouped" because usually that is helpful... but it means you can't access some properties.)

When controls are grouped together, to select only one you do not need to Ungroup. Simply hold down the Ctrl key when selecting the control wanted then you can right click it to get the what you want.

This reads like you had too much coffee :smiley:

I hope I understood your problem correctly.

Tested with version: 7.1.3.2 (x64) / LibreOffice Community

Yeah, I can reproduce your steps. CLOB is not being displayed in the form even if you add data into the table manually.

The problem is:
The form assistant thinks all BLOBS are images. So you have to change the field type from “image” to “text field”.

Steps to fix this:

  1. Enable form navigator
  2. Select memo field
  3. Replace with text field type
  4. Go into properties of the memo field
  5. Set text type to “multiline”


Just a warning in case you’re planning to generate reports in the Writer:

I stopped using CLOB altogether because it does not work in Writer reports. It is unable to deserialise the datatype. I switched to VARCHAR instead and I can save multiline in VARCHAR just fine.

If you really need the size CLOB has to offer you will probably have to use casting, macros or calc tables.

THANK YOU MadMatti! It would delight be to just STAY AWAY from CBLOB. I will be exploring what you’ve suggested from this moment, Will update question as the quest goes on…

It’s looking good, MatMatti… a question (not a deal breaker!)… if I go down the “use VARCHAR” route, can I still (even if it isn’t a good idea) work directly with the TABLE? I couldn’t find a way to cause a line there to break into multiple lines. (Oh… and even when a field DOES have a multi-likne value, looking at the data “at” the “table” level, they are stripped out, and

The quick
Brown
Fox

… becomes…

The quick Brown Fox

Can this be overcome?

Oh, regarding linebreaks see the answer from Ratslinger

And it seems this question is a duplicate of another one of your questions that had previously been answered by The Slinger of Rats.

Ratslinger’s answer on linebreaks wasn’t enough to help me find the bit I’m doing wrong. And the previous answer didn’t work for me when I went back to it after these many months, and anyway used CLOBs which you said didn’t work well in reports.

Hello,

Thought this was answered in a previous question here → How do I create field for multi-line text? (Firebird)

Have no problem:

If you want to enter directly in Table Data View, a new line is Shift + Enter.

In my text box properties, the Text type is Multi-line and Text lines end with is LF (Unix)

Which OS do you use?

For me, under Windows, I’m happy to say that the Text Lines End With property was as suggested by default… but that shift-enter didn’t work.

Silly question… I assume the answer for you is yes, but will CLOB’s work in reports? (They don’t for me… yet. Maybe when the stable release catches up to where you are they will.)

Just tested Win 10 with Shift + Enter - no problems.

No, CLOB does not work in Report Builder (have not tried other report generators yet). Another Firebird bug which holds it back.

(Please forgive me, everyone, if there was a way to send this “private” message without cluttering everyone’s feeds.) Dear Ratslinger- many thanks for your clear, thorough answers… to this thread, and to many of mine in the past, and many I’ve studied in the past. I’m committed to Libre Office and Base for the long haul, whatever the frustrations! Having assistance with things I can’t get to work is an enormous help and encouragement. Your willingness to try again when first answer doesn’t make problem go away is particularly appreciated.

In a nutshell…

Upgrade your LO to at least version 7.0.5.2

Use VARCHAR fields to display multi-line text. Don’t use any variety of BLOB/CLOB for text.

Don’t expect to be able to work with multi-line text via a “direct” view of a table. (You can look at the data that way, but all line-feeds will be missing.)

You will have to tweak the properties of the text box on a form or report to make it display multi-line text. (And change the area they occupy on forms and reports, to make the display area “high” enough for multiple lines.)

Details of those things in the above.