First thanks to Tom Lane who helped me promptly.
Now let's come to the problem:
create or replace function testa( )
returns char(32) as
'
begin
if 1=2 then
if 1=2 then
select 1;
elseif 1=3 then
select 2;
elseif 1=4 then
if 1=5 then
select 3;
else
select 4;
end if;
end if;
end if;
return md5(''aaaa'');
end;
' language plpgsql;
test1=# select * from testa();
ERROR: syntax error at or near "if"
CONTEXT: compile of PL/pgSQL function "testa" near line 14
I made several test functions with similar structure with no
improvements.
I can't even figure a pattern. I get errors on if, else, and elseif.
Till now the culprit seems to be elseif. Whenever I write test
functions without elseif I get no errors.
Did I misinterpreted the docs (37.7.2.4)?
I really can't see the problem.
I'm running 7.4.2-1 on Debian Sarge.
To be less annoying to the list, could anyone point me to somewhere
where I could look at functions written by others.
Any good project with enough complicated functions to be useful to
learn.
thx
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives? http://archives.postgresql.org 6 3149
Dear Ivan:
On Mon, 10 May 2004, Ivan Sergio Borgonovo wrote: First thanks to Tom Lane who helped me promptly.
Now let's come to the problem:
create or replace function testa( ) returns char(32) as ' begin if 1=2 then if 1=2 then select 1; elseif 1=3 then select 2; elseif 1=4 then if 1=5 then select 3; else select 4; end if; end if; end if; return md5(''aaaa''); end; ' language plpgsql;
test1=# select * from testa(); ERROR: syntax error at or near "if" CONTEXT: compile of PL/pgSQL function "testa" near line 14
I made several test functions with similar structure with no improvements. I can't even figure a pattern. I get errors on if, else, and elseif. Till now the culprit seems to be elseif. Whenever I write test functions without elseif I get no errors. Did I misinterpreted the docs (37.7.2.4)?
I really can't see the problem.
I'm running 7.4.2-1 on Debian Sarge.
Is this the literal function? If so, try changing the "elseif" to "elsif".
No 2nd 'e'.
-frank
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)
Ivan Sergio Borgonovo wrote: First thanks to Tom Lane who helped me promptly.
Now let's come to the problem:
create or replace function testa( ) returns char(32) as ' begin if 1=2 then if 1=2 then select 1; elseif 1=3 then select 2; elseif 1=4 then if 1=5 then select 3; else select 4; end if; end if; end if; return md5(''aaaa''); end; ' language plpgsql;
test1=# select * from testa(); ERROR: syntax error at or near "if" CONTEXT: compile of PL/pgSQL function "testa" near line 14
This is odd, I replaced the else ifs with elsif and it worked on 7.4. My
7.3 documentation says that else if and elsif are equivalent.
imp=# select * from testa();
testa
----------------------------------
74b87337454200d 4d33f80c4663dc5 e5
(1 row)
My test code (yours, slightly modified):
drop function testa( );
create or replace function testa( )
returns char(32) as
'
begin
if 1=2 then
if 1=2 then
select 1;
elsif 1=3 then
select 2;
elsif 1=4 then
if 1=5 then
select 3;
else
select 4;
end if;
end if;
end if;
return md5(''aaaa'');
end;
' language plpgsql;
select * from testa();
I made several test functions with similar structure with no improvements . I can't even figure a pattern. I get errors on if, else, and elseif. Till now the culprit seems to be elseif. Whenever I write test functions without elseif I get no errors. Did I misinterpreted the docs (37.7.2.4)?
I really can't see the problem.
I'm running 7.4.2-1 on Debian Sarge.
To be less annoying to the list, could anyone point me to somewhere where I could look at functions written by others. Any good project with enough complicated functions to be useful to learn.
thx
---------------------------(end of broadcast)--------------------------- TIP 6: Have you searched our list archives?
http://archives.postgresql.org
Ron
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)
On Mon, 10 May 2004, Ivan Sergio Borgonovo wrote: Now let's come to the problem:
create or replace function testa( ) returns char(32) as ' begin if 1=2 then if 1=2 then select 1; elseif 1=3 then select 2; elseif 1=4 then
Don't you mean ELSIF, not ELSEIF?
Kris Jurka
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
On Mon, 10 May 2004 13:56:39 -0500 (EST)
Kris Jurka <bo***@ejurka.c om> wrote: On Mon, 10 May 2004, Ivan Sergio Borgonovo wrote:
Now let's come to the problem:
create or replace function testa( ) returns char(32) as ' begin if 1=2 then if 1=2 then select 1; elseif 1=3 then select 2; elseif 1=4 then
Don't you mean ELSIF, not ELSEIF?
thanks to everyone.
Curiously enough, trying to figure out what was wrong with my code,
I've been able to write versions with the wrong spelling that didn't
complain. That brought me astray.
Anyway does anyone know any public big enough project written in
plpgsql from which I could learn lurking at the code?
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
On Tue, May 11, 2004 at 12:58:55AM +0200, Ivan Sergio Borgonovo wrote: thanks to everyone. Curiously enough, trying to figure out what was wrong with my code, I've been able to write versions with the wrong spelling that didn't complain. That brought me astray.
Anyway does anyone know any public big enough project written in plpgsql from which I could learn lurking at the code?
OpenACS (from openacs.org) is a huge web application framework with
the vast majority of the business logic written in PL/SQL. It has
a wide selection of PL/SQL functions, with equivalents for both
Oracle and PostgreSQL.
Cheers,
Steve
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
On 11/05/04, Ivan Sergio Borgonovo (ma**@webthatwo rks.it) wrote: Anyway does anyone know any public big enough project written in plpgsql from which I could learn lurking at the code?
Hi Ivan
I've written a small demo app in PHP and postgres. Whether or not you
use php, the bugadb.php file shows different ways of calling the plpgsql
functions.
You can see a (slightly out of date) version of the small demo running
here: http://campbell-lange.net/bugaboo/
You can download the source from the bottom of my index page under the
link "Download the 24K zip file of bugaboo sources".
Bear in mind that I'm not an expert. However we have been doing webapps
for the last 2.5 years with a huge amount of success using plpgsql
functions handling the spatial arrangement of data and perl or php to do
the formatting and data verification.
Comments and corrections gratefully received.
Rory
--
Rory Campbell-Lange
<ro**@campbel l-lange.net>
<www.campbell-lange.net>
---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Angelina |
last post by:
Hi,
I need some help in writing a 'if-then-else' statement.
I currently have wrote one that looks something like this..
If Combobox1 = xxx and textbox1 <> "" then
'run stored procedure 1 to obtain the relevant
records and place them in a datagrid.
elseif combox1 = yyy and textbox2 <> "" or textbox3 <> ""
then
|
by: Dthmtlgod |
last post by:
Could someone please look at my code below, I am trying to nest a couple of
if statements together and it is not working. I think I am close.
if len(rsMove("MonitorID1")) > 0 and len(rsMove("MonitorID2")) > 0 then
response.write ("Dual Monitors")
else if len(rsMove("MonitorID1")) > 1 and len(rsMove("MonitorID2")) = 0 then
response.write ("Single Monitor")
else
response.write ("No Monitor")
end if
|
by: Thanks2U |
last post by:
I have 2 if statements that are unrelated to each other,
but the outcome of the variable of each of these are.
Here is my first one:
If sToEMail = "" Then
sTo = "DT" & CStr(lDistrictNbr)"@microsoft.com"
Else
sTo = sToEMail
End If
|
by: hdogg |
last post by:
Scope Woes - IF statement nested in WHILE statement -PHP
I have an array $actuals_sum.
<?php
while(conditions)
{
if($i == '24)
{
|
by: rupalirane07 |
last post by:
Both grids displays fine. But the problem is only parent datagrid sorting works fine but when i clik on child datagrid for sorting it gives me error:
NullReferenceException error
Any help........pls urgent
=========================================================
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm3.aspx.vb" Inherits="TestDatagrids.WebForm3"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">...
| |
by: JRough |
last post by:
I got lost on formatting the nested if/else's on the bottom of the
file right up the last else/if there seems to be a stray bracket. I'm
trying to line up the brackets so I can read it. Is it okay to split
a long line setting a variable on two lines at the equals sign? That
is so you can read it in google groups.
<?
//Send payement advices
$TPL_auction_id = $auction_id;
$user_id=$userrec;
|
by: Patrick A |
last post by:
All,
I rely on nested IF statements with multiple conditions heavily, and
someone suggested recently writing the statements (and especially
reading them months later) would be much easier if I used Case
statements instead.
I've read several different examples of Case statements, but can't
quite figure out the syntax, or if they can be used when you need to
test for a pair of conditions, as I am doing below.
|
by: scottbouley |
last post by:
HELP!
I'm trying to check a form for missing values. Two of the fields are required and therefore the corresponding message boxes are VBOkOnly. The other two are for warning purposes and their message boxes are VBYesNo.
First the code asks if the user wants to save the record. If the user answers Yes, the code should proceed to check for errors and allow the user to correct them. Once all of the errors are corrected a message box...
|
by: henry |
last post by:
Folks:
Using Dreamweaver CS3...
Consider a home page, "index.php" which conditionally REQUIREs one of 'N'
HTML files of pure content. All site styles are specified in a master CSS
file, "siteformatting.css"
The home page, "index.php" must link to the master CSS file, so that HTML
elements in this file can conform to site-wide standards, right? (Or
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |