-1

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.

MK Singh
  • 706
  • 1
  • 13
  • 36
  • @Damodaran how could you edit my post so stupidly. When I am saying that my query looks like what I said then that is it. How could you change it to something else. – MK Singh Dec 11 '13 at 12:21
  • @a_horse_with_no_name: Same thing goes to you. the query may look very wrong to you in the question but why do you change it by adding a '\' before #func3 and #func4. Please somebody tell me how can I restrict someone from editing my post. – MK Singh Dec 12 '13 at 05:21
  • Your post is the problem their edits are correct. – Albert Laure Dec 12 '13 at 05:55

1 Answers1

0

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()');
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
MK Singh
  • 706
  • 1
  • 13
  • 36