Forum > Databases

[SOLVED] How to send line breaks to database?

(1/3) > >>

Slawek:
I use code like this to write MariaDB stored procedures:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TDataBase.ExecuteDirect(sSQL: String): Boolean;var err: Integer;begin  Result := False;  try    FConn.Open;    try        if FConn.Connected then begin          FTrans.StartTransaction;          FConn.ExecuteDirect(sSQL);          FTrans.Commit;          Result := True;        end;    except      on E : Exception do ShowMessage(E.Message);    end;  finally   FConn.Close;  end;end;
Where:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---sSQL := 'CREATE PROCEDURE `zm_SET_COMPUTER`(IN `p_pcname` VARCHAR(64)) '+              'NO SQL '+              'BEGIN '+               'END';Unfortunately, in PhPMyAdmin this procedure is displayed in one long line.
But when I insert line breaks I get an syntax error

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---sSQL := 'CREATE PROCEDURE `zm_SET_COMPUTER`(IN `p_pcname` VARCHAR(64))'+Lineending+              'NO SQL'+Lineending+              'BEGIN'+Lineending+              Lineending+              'END';Is there any way to fix this?

cdbc:
Hi
Could it be as simple as forgetting the spaces, when you introduce linebreaks?
Something like this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---sSQL := 'CREATE PROCEDURE `zm_SET_COMPUTER`(IN `p_pcname` VARCHAR(64)) '+Lineending+              'NO SQL '+Lineending+              'BEGIN '+Lineending+' '+              Lineending+              'END'; Added space:
- after procedure signature
- after NO SQL
- after BEGIN
- between the 2 linebreaks
Dunno, but might help  %)
Regards Benny

Slawek:
Hi,
Unfortunately, that doesn't work either. I tried with spaces.


--- Quote from: cdbc on June 06, 2023, 02:07:20 pm ---Something like this:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---sSQL := 'CREATE PROCEDURE `zm_SET_COMPUTER`(IN `p_pcname` VARCHAR(64)) '+Lineending+              'NO SQL '+Lineending+              'BEGIN '+Lineending+' '+              Lineending+              'END'; 
--- End quote ---

All I have to do is add one LineEnding or #13 or #10 and I get a syntax error.


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---    sSQL := 'CREATE PROCEDURE `zm_SET_COMPUTER`(IN `p_pcname` VARCHAR(64))  '+Lineending+' '+                  ' NO SQL '+                  'BEGIN '+                       'END'; Adding a space doesn't help. I also tried '\'#13 :(

rvk:

--- Quote from: Slawek on June 06, 2023, 01:54:50 pm ---But when I insert line breaks I get an syntax error

--- End quote ---
WHAT syntax error do you get?

(Always mention the exact errors.)

Reference manual for CREATE PROCEDURE in MySQL: https://dev.mysql.com/doc/refman/8.0/en/create-procedure.html

Slawek:
But there is no syntax error in the procedure itself.
The syntax error only appears after adding LineEnding.

When I'm not using LineEnding (or #13 or #10), the procedure is executed correctly (also empty). It's just hard to modify in phpMyAdmin because it comes in one line. I would like this routine to be written in multiple lines and formatted with proper indentation.

Navigation

[0] Message Index

[#] Next page

Go to full version