Create_SMMessage()

Prototype:
Create_SMMessage( number OUT_RetCode, number OUT_idSMMessage, number IN_idChan, number IN_tMotion, number IN_tLoad, number IN_tAlt, number IN_iAltCode, number IN_tPGA, number IN_tPGV, number IN_tPGA, number IN_idEvent);
Description: This procedure creates a new strong motion message(SMMessage) record in the EW DBMS. It returns the DB ID(idSMMessage) of the newly created record. To put a complete strong motion message into an Earthworm DBMS, the caller should first call Create_SMMessage() to load the base message(complete with timestamps), and then call Create_SMMotion() for each acceleration, velocity, and displacement measurement in the message.

RETURN CODE INFO
Return Type: NUMBER
Return Arg: 1
Return Value Description
0 Success
-1 Unknown error
-2 Duplicate Key idSMMessage. This indicates an internal error, as the key should be uniquely generated by this procedure. If you receive this error, you should scratch your head and contact your guardian angel.
-3 Invalid IN_idChan. IN_idChan must contain a valid idChan value that represents a primary key in the Chan table.
-1X Error in Create_Core_idKey(), where X indicates error returned by that proc.
-1XX The SMMessage record was successfully created, but IN_idEvent was specified as non-NULL so this procedure attempted to bind the new SMMessage record to the event specified by IN_idEvent, using Create_Bind(). Create_Bind() returned error XX. *NOTE: The newly create SMMessage record was subsequently deleted, since it could not be bound to the specified event.

PARAMETER INFO
Parameter Type Description
OUT_RetCode number This parameter holds the return value for the procedure.
OUT_idSMMessage number The DB ID of the newly created SMMessage record. This number is only valid if OUT_RetCode = 0 upon completion of the procedure.
IN_idChan number The idChan of the channel with which the new message is associated.
IN_tMotion number Approximate time of the motions upon which the new message is based. This is the primary time and should be the one provided by the instrument/person/program that detected the motion. More specific times for PGA(Peak Ground Acceleration), PGV, and PGD may optionally be specified in the IN_tPGA, IN_tPGV, and IN_tPGD fields. (seconds since 1970)
IN_tLoad number Time that the record was first loaded into and EW DBMS. Caller must calculate this parameter. (seconds since 1970)
IN_tAlt number Optional time that might specify a more accurate time of motion than IN_tMotion. IN_iAltCode specifies how this time was derived. (seconds since 1970)
IN_iAltCode number A code to describe how IN_tAlt was derived. This should contain the numeric value of one of the SM_ALTCODE_* constants defined in rw_strongmotionII.h. (Should be set to SM_ALTCODE_NONE if IN_tAlt is NULL).
IN_tPGA number Optional value that specifies the time of the Peak Ground Acceleration(PGA) associated with this message. (seconds since 1970)
IN_tPGV number Optional value that specifies the time of the Peak Ground Velocity(PGV) associated with this message. (seconds since 1970)
IN_tPGA number Optional value that specifies the time of the Peak Ground Displacement(PGD) associated with this message. (seconds since 1970)
IN_idEvent number Optional DB idEvent that identifies an Event with which the new SMMessage should be associated. Set to NULL if the message should not be associated with an event.

Group: EWDB_API_LIB
Sub Group: STRONG_MOTION-INTERNAL
Language: SQL
Location: ./src/oracle/schema-working/sql_scripts/ewdb_create_smmessage.sql



Create_SMMotion()

Prototype:
Create_SMMotion( number OUT_RetCode, number OUT_idSMMotion, number IN_idSMMessage, number IN_iMotionType, number IN_dPeriod, number IN_dMeasurement);
Description: This procedure creates a new strong motion measurement(SMMotion) record in the EW DBMS. It returns the DB ID(idSMMotion) of the newly created record. To put a complete strong motion message into an Earthworm DBMS, the caller should first call Create_SMMessage() to load the base message(complete with timestamps), and then call Create_SMMotion() for each acceleration, velocity, and displacement measurement in the message.

RETURN CODE INFO
Return Type: NUMBER
Return Arg: 1
Return Value Description
0 Success
-1 Unknown error
-2 Duplicate Key idSMMessage. This indicates an internal error, as the key should be uniquely generated by this procedure. If you receive this error, you should scratch your head and contact your guardian angel.
-3 Invalid IN_idSMMessage. IN_idSMMessage must contain a valid idSMMessage value that represents a primary key in the SMMessage table.
-4 Unknown NO_DATA_FOUND error. Time to revisit the guardian angel.
-1X Error in Create_Core_idKey(), where X indicates error returned by that proc.

PARAMETER INFO
Parameter Type Description
OUT_RetCode number This parameter holds the return value for the procedure.
OUT_idSMMotion number The DB ID of the newly created SMMotion record. This number is only valid if OUT_RetCode = 0 upon completion of the procedure.
IN_idSMMessage number The idSMMessage of the strong motion message with which the new motion is associated.
IN_iMotionType number This specifies the type or category of motion. It should be one of the P3DB_SMMOTION_TYPE_* constants defined in ewdb_ora_api.h, such as P3DB_SMMOTION_TYPE_ACC
IN_dPeriod number Either the period associated with a spectral response measurment or a code (-1) indicating that the measurement is of a peak value, such as PGA.
IN_dMeasurement number The measurment value of the motion. Measurements should be in terms of centimeters and seconds, so cm/s/s for acceleration, cm/s for velocity, and cm for displacement. The caller is responsible for conversion of data from it's native format to the EWDB format of centimeters and seconds. Other known formats(not support by EWDB) are meters, g's, and digital counts.

Group: EWDB_API_LIB
Sub Group: STRONG_MOTION-INTERNAL
Language: SQL
Location: ./src/oracle/schema-working/sql_scripts/ewdb_create_smmotion.sql



Delete_SMMessage()

Prototype:
NUMBER Delete_SMMessage( number IN_idSMMessage, number IN_bForce);
Description: This procedure deletes a strong motion message from the DB, including: 1)Deleting all of the SMMotions associated with the message; 2)Deleting any bindings of the message to an Event; and 3)Deleting the SMMessage record itself.

RETURN CODE INFO
Return Type: NUMBER
Return Value Description
0 Success
-1 Unknown error
-2 IN_idSMMessage was not valid. No SMMessage record with a matching idSMMessage was found.
-3 The deletion request violated a Foreign Key constraint. Please see the DEBUG table for more debugging information.

PARAMETER INFO
Parameter Type Description
IN_idSMMessage number The DB ID of the SMMessage to delete.
IN_bForce number Flag indicating whether or not the function should force the delete of an SMMessage, even if it is still bound to existing events.

Group: EWDB_API_LIB
Sub Group: STRONG_MOTION-INTERNAL
Language: SQL
Location: ./src/oracle/schema-working/sql_scripts/ewdb_delete_smmessage.sql