0

I'm new to writing functions in Postgres..

I don't want to exit PSQL entirely, (I know CTRL+D will do that,) but I seem to be stuck in the CREATE FUNCTION screen.

mattswheels=# CREATE OR REPLACE FUNCTION 99_cents(money)
mattswheels-#  RETURNS money
mattswheels-#  LANGUAGE plpgsql
mattswheels-#  LEAKPROOF
mattswheels-# AS $function$
mattswheels$# DECLARE
mattswheels$#     new_price money;
mattswheels$#     size int;
mattswheels$# BEGIN
mattswheels$#     size := char_length(money);
mattswheels$#     RETURN size;
mattswheels$# END;
mattswheels$# 
mattswheels$# \q
mattswheels$# halp
mattswheels$# ;
mattswheels$# ;
mattswheels$# ;
mattswheels$# ;
mattswheels$# help
mattswheels$# ;
mattswheels$# \?
some1
  • 1,547
  • 8
  • 26
  • 45

2 Answers2

1

Try CTRL+C. It discards last query with not terminated quotes.

Tomasz Myrta
  • 1,114
  • 8
  • 10
0

First, I figured out that postgres functions can't start with a number.

ERROR:  syntax error at or near ".99"
LINE 1: CREATE OR REPLACE FUNCTION public.99cents(money)

Secondly, to exit out of the issue above the $function$ declaration needed to be closed with this:

$function$;

As far as I can tell, there is no other keystroke that can exit one out of the CREATE FUNCTION screen, unless PSQL is exited entirely with CTRL+D.

some1
  • 1,547
  • 8
  • 26
  • 45