Question

I have written a query in an SQL script (to be run on a Unix system) where I have to insert a few rows in a table in a column named 'funcs' and the name of the functions which I am inserting in this column have to all be in a new line (as shown below):

func1()

func2()

The problem I am facing here is that there are a few functions which start with a '#' like #func3() and my query looks like this:

INSERT INTO TABLE (FUNCS) 
VALUE ( 'func1()

func2()

#func3()

func4()

#func5()'

);

When I execute the above query in WinSQL application, it executes fine, but while executing the above query in a script I get the following error:

unknown command beginning "func3..." - rest of line ignored.

unknown command beginning "func5..." - rest of line ignored.

As a result finally I can see only func1(), func2() and func4() in this field while #func3() and #func5() are ignored.

Hence I can think of only 2 solutions:

  1. It can be achieved if I can tell the compiler to not consider a statement with a '#' as a comment as it would normally do; or

  2. if I can write the name of all the functions in a single line separating them with a new line character like this :

    'func1() [newline char] func2() [newline char] #func3() [newline char] func4() [newline char] #func5()'.

Please tell me how to solve this problem.

Was it helpful?

Solution

I was able to solve this problem by changing the insert query in the following manner:

insert into table (funcs)
values('func1()'||
'func2()'||
'#func3()'||
'func4()'||
'#func5()');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top